views:

109

answers:

3

Hi, I am running BDD steps with cucumber to implement my autlogic login behavior.

 Scenario: log in
Given a registered user: "[email protected]" with password: "p@ssword" exists
And I am on the homepage
When I follow "Log in"
And I fill in "Username" with "[email protected]"
And I fill in "Password" with "p@ssword"
And I open the page
And I press "Login"
And I open the page
Then I should see "Login successful!"
And I should see "Logout"

this is my scenario and when I hit

Then I should see "Login successful!"

my cucumber step fails but only in webrat. I debugged with launchy and when the web-page appeard there is indeed no message but in development mode, when I run script/server I see my messages. My controller looks like this

 def create
@user_session = UserSession.new(params[:user_session])
  if @user_session.save
    flash[:notice] = "Login successful!"
   redirect_to root_url
  else
    render :action => 'new'
  end

end

And yes I saw this http://github.com/binarylogic/authlogic/issuesearch?state=open&q=cucumber+flash#issue/142 and did not understand how this could help me and this also did not help

http://stackoverflow.com/questions/2136334/rails-cucumber-webrat-redirect-to-flashnotice-not-working

my setup is

*** LOCAL GEMS ***

actionmailer (2.3.8)

actionpack (2.3.8)

activerecord (2.3.8)

activeresource (2.3.8)

activesupport (2.3.8)

authlogic (2.1.5)

builder (2.1.2)

configuration (1.1.0)

cucumber (0.8.4, 0.8.3)

cucumber-rails (0.3.2)

database_cleaner (0.5.2)

declarative_authorization (0.4.1)

diff-lcs (1.1.2)

gherkin (2.1.2, 2.0.2)

json_pure (1.4.3)

launchy (0.3.5)

mysql (2.8.1)

nokogiri (1.4.2)

paperclip (2.3.3)

pickle (0.3.0)

rack (1.2.1, 1.1.0)

rack-test (0.5.4)

rails (2.3.8)

rake (0.8.7)

rspec (1.3.0)

rspec-rails (1.3.2)

syntax (1.0.0)

term-ansicolor (1.0.5)

thoughtbot-factory_girl (1.2.2)

trollop (1.16.2)

webrat (0.7.1)

ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux] gem 1.3.7 running on Ubuntu

What can I do to make my cucumber steps pass!

Thanks for any help

A: 

Looks like rails 2.3.8 has changed the method in which is displays notices..

redirect_to(root_url, :notice => 'Login successful!')

might be what you're looking for.

Rabbott
Thanks, but did not help it looks like this is only a conjunction of the two steps =( In my opinion the problem sits in the way webrat handles redirects and the flash message
server info
A: 

I believe this issue will be fixed in Rails 2.3.9. It has to do with setting both a cookie and a session in the same request. See this ticket for details.

In the meantime you can use this gist as a temporary fix.

ryanb
thanks for the reply but I did not get the gist to work. I added the config.after_initialize do ActionController::Dispatcher.middleware.insert_before(ActionController::Base.session_store, RackRailsCookieHeaderHack) end this to my environment.rb and created a another file called rack_rails_cookie_header_hack.rb and placed it in config folder. I receive ... I'll get a uninitilialized constant RackRailsCookieHeaderHack... any pointer? Thanks for helping, though =)
server info
A: 

thanks to raynb who pointed me into the right direction. But unfurtunatly this solution did not work but I found this page which puts everything in cucumber.rb... which mad it running now ...

https://webrat.lighthouseapp.com/projects/10503-webrat/tickets/383-reset_session-and-webrat-dont-play-nicely-with-one-another

server info