[rspec-users] story runner on restful_authentication question

steven shingler shingler at gmail.com
Mon Apr 28 11:31:21 EDT 2008

Hi all,
Have been following:
..as an introduction into the story runner.

It shows how to get a couple of scenarios going to test the
restful_authenticated plugin from plain text stories.

I thought I'd go completely bonkers and try and add a story of my own :)

  Scenario: Registered user logs in
        Given a username 'jdoe'
        And a password 'letmein'
        And an existing user with these credentials
        When the user logs in with username and password
        Then  should redirect to '/'

And I added these steps to try and make this pass:

 Given "an existing user with these credentials" do
    @user = User.new({ :login => @username,
      :password => @password,
      :password_confirmation => @password,
      :email => "jdoe at test.comm" })
    User.find_by_login(@username).should_not be_nil

  When "the user logs in with username and password" do
    post "/sessions/create", :user => { :login => @username, :password
=> @password }

  Then "should redirect to '$path'" do |path|
    response.should redirect_to(path)

However, I'm getting a
 Spec::Expectations::ExpectationNotMetError: expected redirect to "/",
got no redirect

So the user is definitely being created in the test database, but the
login doesn't seem to work, or to do the redirect.
I must be doing something silly. If anyone could point me in the right
direction, I'd be very grateful.
Thanks very much,

More information about the rspec-users mailing list