【发布时间】:2011-09-09 06:06:35
【问题描述】:
我正在使用 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 == nil
end
当我运行我的黄瓜测试时,我得到一个错误
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'
这是处理变量断言的正确方法吗?我注意到,如果我要使用 session[:something],则会发生相同类型的错误。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 cucumber capybara web