[rspec-users] multiple scenarios problem

Ivo Dancet ivo.dancet at gmail.com
Sun Dec 23 07:38:03 EST 2007

Hi all

I just recently started to use rspec and I'm having a problem using  
multple scenarios in one story. These are the two scenarios, trying to  
test my implemenation of the new http authentication in rails 2:

   Scenario "user has to authenticate" do
     Given "an anonymous user" do
     When "visiting", "working_page" do |page|
       get page
     Then "it should return 401 Unauthorized on each request" do
       response.headers["Status"].should == "401 Unauthorized"

   Scenario "user authenticates so the page should return 200" do
     Given "a user"; end
     When "visiting", "working_page" do |page|
       get page, nil, :authorization =>  
     Then "I'm logged in" do
       response.should be_success

What happens is that the second scenario's response is also returning  
401 and if I switch the order of the two scenarios, the second  
scenario (now the one that should return 401) returns 200. Each  
scenario works if I remove the other one.

thanks for any help!
Ivo Dancet

More information about the rspec-users mailing list