[rspec-users] Reusing story snippets

Mikel Lindsaar raasdnil at gmail.com
Sat Jun 14 06:03:02 EDT 2008

I find myself doing this:

Scenario "logged in user visiting the home page" do
  Given "A logged in user" do

  When "..."
  Then "..."

The a_logged_in_user method is a helper method in helper.rb which sets
up the state so that the user can browse the website.

Later in the story of course, I can just do 'Given "A logged in user"
and it will get the previous definition.

Is there any way to avoid that duplicated Given call at the top of
almost every story?


More information about the rspec-users mailing list