https://github.com/nulogy/screengem
A simple Ruby implementation of the Screenplay Pattern.
https://github.com/nulogy/screengem
ruby screenplay-pattern
Last synced: 7 months ago
JSON representation
A simple Ruby implementation of the Screenplay Pattern.
- Host: GitHub
- URL: https://github.com/nulogy/screengem
- Owner: nulogy
- License: mit
- Created: 2018-12-14T03:15:00.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-10-03T23:59:53.000Z (over 1 year ago)
- Last Synced: 2025-05-31T02:45:01.829Z (8 months ago)
- Topics: ruby, screenplay-pattern
- Language: Ruby
- Size: 157 KB
- Stars: 9
- Watchers: 20
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Screengem
A simple Ruby implementation of the [Screenplay Pattern](https://ideas.riverglide.com/page-objects-refactored-12ec3541990).
Screengem promotes writing step definitions in terms of actors, the tasks that the actor performs,
and the questions that the actor asks.
## Example Step Definitions
```ruby
Given("that they are signed in and viewing the {section_name}") do |section_name|
actor.performs(task.sign_in, task.remember_signature_counter(section_name))
end
Then("their signature is captured") do
actor.asks(question.signature_captured)
end
```
## Core Domain Model
An Actor asks questions and performs tasks.
An Actor is able to remember and recall key-value pairs.
A Question responds to answer.
A Task responds to perform.

## Actor Memory
Actors are able to remember and recall facts. This is the recommended way to pass state
between steps. To clear every actor's memory before each scenario add a hook:
```
Before do
Screengem::ActorMemory.instance.clear
end
```
## Performing Tasks
Actors are able to perform tasks. A task may be implemented by interacting with domain services,
domain models, application databases, and the application via screen elements.
Capybara is available to all screen elements and is the recommended way to interact with a browser.
## Answering Questions
Actors are able to answer questions. A question is considered to be answered affirmatively
when no exception is thrown and negatively when an exception is thrown.
[RSpec expectations](https://github.com/rspec/rspec-expectations) are available in all questions and are the recommended way to implement a question.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'screengem'
```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/nulogy/screengem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the Screengem project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/nulogy/screengem/blob/master/CODE_OF_CONDUCT.md).