rspec: undefined local variable or method `be_true'

自作多情 提交于 2019-12-22 13:48:31

问题


I am using rspec 2.4.0 and cucumber 0.6.4. I am running a simple scenario (for the sake of this question):

Scenario: Simple Test
When I test something

with step definition:

require 'rspec'
require 'rspec/expectations'

When /^I test something$/ do
  result = (1==1)
  result.should be_true
end

When I run this scenario I get the following problems:

 undefined local variable or method `be_true' for #<Object:0x1b3b424> (NameError)

I am also using bundler to manage my dependencies.

Am I doing something obviously wrong here?

Regards,

Mark


回答1:


From the cucumber documentation:

To use RSpec’s 2.x.x expectations (should), make sure the following is in features/support/env.rb:

require 'rspec/expectations'
World(RSpec::Matchers)

https://github.com/cucumber/cucumber/wiki/RSpec-Expectations



来源:https://stackoverflow.com/questions/11760528/rspec-undefined-local-variable-or-method-be-true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!