authlogic flash 没有显示在黄瓜webrat步骤中
我正在使用黄瓜运行BDD步骤来实现我的autlogic登录行为。
Scenario: log in Given a registered user: "test@test.com" with password: "p@ssword" exists And I am on the homepage When I follow "Log in" And I fill in "Username" with "test@test.com" 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"
这是我的情景,当我击中
Then I should see "Login successful!"
我的黄瓜步骤失败但只在webrat中。 我使用launchy调试,当网页显示确实没有消息但是在开发模式下,当我运行脚本/服务器时,我看到了我的消息。 我的控制器看起来像这样
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
结束
是的,我看到这个http://github.com/binarylogic/authlogic/issuesearch?state=open&q=cucumber+flash#issue/142并且不明白这对我有什么帮助,这也没有帮助
Rails / Cucumber / Webrat:redirect_to,flash [:notice]无效
我的设置是
*** LOCAL GEMS ***
动作制作者(2.3.8)
actionpack(2.3.8)
activerecord(2.3.8)
activeresource(2.3.8)
activesupport(2.3.8)
authlogic(2.1.5)
建设者(2.1.2)
配置(1.1.0)
黄瓜(0.8.4,0.8.3)
黄瓜栏杆(0.3.2)
database_cleaner(0.5.2)
declarative_authorization(0.4.1)
差异(1.1.2)
小黄瓜(2.1.2,2.0.2)
json_pure(1.4.3)
发射(0.3.5)
mysql(2.8.1)
nokogiri(1.4.2)
回形针(2.3.3)
泡菜(0.3.0)
机架(1.2.1,1.1.0)
机架测试(0.5.4)
铁轨(2.3.8)
耙子(0.8.7)
rspec(1.3.0)
rspec-rails(1.3.2)
语法(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在Ubuntu上运行
我该怎么办才能让我的黄瓜步骤通过!
谢谢你的帮助
而不是线
flash[:notice] = "Login successful!" redirect_to root_url
只是尝试渲染它而不是重定向它。
flash[:notice] = "Login successful!" render :action => :root_url
在这样做,它似乎记得闪光[:通知]
我无法得到 – > redirect_to root_url,:flash => {:notice =>’not found’},:notice =>登录成功!’ < - 完全工作
看起来像rails 2.3.8改变了显示通知的方法。
redirect_to(root_url, :notice => 'Login successful!')
可能就是你要找的东西。
我相信这个问题将在Rails 2.3.9中修复。 它与在同一请求中设置cookie和会话有关。 有关详细信息,请参阅此票
在此期间,您可以将此要点用作临时修复。
感谢raynb指出了我正确的方向。 但不幸的是,这个解决方案没有用,但是我发现这个页面把所有东西都放在了cucumber.rb …这让它疯狂了…