Skip to content

A simple Ruby implementation of the Screenplay Pattern.

License

Notifications You must be signed in to change notification settings

nulogy/screengem

Repository files navigation

Screengem

A simple Ruby implementation of the Screenplay Pattern.

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

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.

Core Domain Model

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 are available in all questions and are the recommended way to implement a question.

Installation

Add this line to your application's Gemfile:

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.

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 code of conduct.

License

The gem is available as open source under the terms of the MIT License.

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.

About

A simple Ruby implementation of the Screenplay Pattern.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •