ruby-on-rails – 如何使用Cucumber-Capybara断言是否存在闪存变量?

ruby-on-rails – 如何使用Cucumber-Capybara断言是否存在闪存变量?,第1张

概述我正在使用Cucumber和Capybara运行Rails 3.0.7项目,我有一个步骤定义,检查是否存在flash [:error]: Then /^I should be able to see the main page properly$/ do current_path.should == "/" flash[:error].should == nilend 当我进行黄 我正在使用Cucumber和Capybara运行Rails 3.0.7项目,我有一个步骤定义,检查是否存在flash [:error]:

Then /^I should be able to see the main page properly$/ do    current_path.should == "/"    flash[:error].should == nilend

当我进行黄瓜测试时,我收到一个错误

And I should be able to see the main page properly # features/step_deFinitions/user_auth_steps.rb:17  undefined method `flash' for nil:NilClass (NoMethodError)  ./features/step_deFinitions/user_auth_steps.rb:19:in `/^I should be able to see the main page properly$/'  features/user_auth.feature:10:in `And I should be able to see the main page properly'

这是处理变量断言的正确方法吗?我注意到如果我使用会话[:某事],就会发生同样的错误.

解决方法 您应该检查页面上实际可见的内容,例如在这种情况下:

page.should_not have_CSS('.flash')
总结

以上是内存溢出为你收集整理的ruby-on-rails – 如何使用Cucumber-Capybara断言是否存在闪存变量?全部内容,希望文章能够帮你解决ruby-on-rails – 如何使用Cucumber-Capybara断言是否存在闪存变量?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1272285.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存