gpt4 book ai didi

rspec:未定义的局部变量或方法 `be_true'

转载 作者:行者123 更新时间:2023-12-01 20:13:06 25 4
gpt4 key购买 nike

我正在使用 rspec 2.4.0 和 cucumber 0.6.4。我正在运行一个简单的场景(为了这个问题):

Scenario: Simple Test
When I test something

带有步骤定义:

require 'rspec'
require 'rspec/expectations'

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

当我运行此场景时,我遇到以下问题:

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

我还使用 bundle 程序来管理我的依赖项。

我在这里做了明显错误的事情吗?

问候,

标记

最佳答案

来自 cucumber 文档:

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

关于rspec:未定义的局部变量或方法 `be_true',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11760528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com