[rspec-users] testing multiple sessions in cucumber/webrat

Eric Kramer lists at ruby-forum.com
Wed Apr 22 16:50:27 EDT 2009


Joe Van Dyk wrote:
> Is it possible to have a scenario where you are testing the
> interaction between two different session?

Not sure if this is exactly what you need, but I found this technique to 
be very handy:

   http://erikonrails.snowedin.net/?p=159

It involves mixing in a method to ActionController::Integration::Session 
so that you can create a step definition that happens "outside" the 
current session:

module ActionController
  module Integration
    class Session
      def in_a_separate_session
        old = @response.clone
        yield
        @response = old
      end
    end
  end
end

Here's a sample usage from his page:

Then /^I should be logged in$/ do
  in_a_separate_session do
    Given "I visit /users/me"
    Then "I should see \"You are logged in\""
  end
end
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list