authlogic flash[:notice] 没有出现在 Cucumber Webrat 步骤中

发布于 2024-09-09 04:04:44 字数 2494 浏览 4 评论 0原文

我正在使用 Cucumber 运行 BDD 步骤来实现我的自动逻辑登录行为。

 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"

这是我的场景,当我点击

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[ :通知]不工作

我的设置是

*** 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)

配置(1.1.0)

黄瓜(0.8.4,0.8.3)

黄瓜轨道(0.3.2)

database_cleaner(0.5.2)

declarative_authorization(0.4.1)

diff-lcs(1.1.2)小黄瓜

( 2.1.2,2.0.2)

json_pure(1.4.3)

launchy(0.3.5)

mysql(2.8.1)

nokogiri(1.4.2)

回形针(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)

语法(1.0.0)

term-ansicolor(1.0.1) 5)

thoughtbot-factory_girl(1.2.2)

trollop(1.16.2)

webrat(0.7.1)

ruby 1.8.7(2010-01-10补丁级别249)[i486-linux] 宝石1.3.7 在 Ubuntu 上运行

我该怎么做才能让我的黄瓜步骤通过!

感谢您的帮助

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

Rails/Cucumber/Webrat: redirect_to, flash[:notice] 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

懵少女 2024-09-16 04:04:44

而不是该行,

flash[:notice] = "Login successful!"   
redirect_to root_url

只需尝试渲染它而不是重定向它。

flash[:notice] = "Login successful!"   
render :action => :root_url

在这样做时,它似乎记住了 flash[:notice]

我无法得到 --> redirect_to root_url, :flash =>; {:通知=> '未找到' }, :notice =>登录成功!' <-- 完全工作

instead of the line

flash[:notice] = "Login successful!"   
redirect_to root_url

just try rendering it instead of redirecting it.

flash[:notice] = "Login successful!"   
render :action => :root_url

in doing this, it seems to remember flash[:notice]

i could not get --> redirect_to root_url, :flash => { :notice => 'not found' }, :notice => Login successful!' <-- to work at all

心舞飞扬 2024-09-16 04:04:44

看起来 Rails 2.3.8 已经改变了显示通知的方法..

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

可能就是您正在寻找的。

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.

饮湿 2024-09-16 04:04:44

我相信这个问题将在 Rails 2.3.9 中得到解决。它与在同一请求中设置 cookie 和会话有关。请参阅 此票了解详细信息。

同时,您可以使用此要点作为临时修复。

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.

弥枳 2024-09-16 04:04:44

感谢 Raynb 为我指明了正确的方向。但不幸的是,这个解决方案不起作用,但我发现这个页面将所有内容都放在 cucumber.rb 中...这让它现在正在运行...

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文