本文介绍了Rspec 2.8.0,expect(something) 导致 ArgumentError:参数数量错误(1 代表 0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有 rspec 2.8.0 的新仓库(非 Rails).
I have a fresh repo (non-rails) with rspec 2.8.0.
由于某些奇怪的原因,我不能使用 expect 语法.
For some strange reason I can´t use the expect syntax.
这个荒谬的规范:
require "spec_helper"
describe "The Truth" do
it "is true" do
expect(true).to be_true
end
end
原因:
Failure/Error: expect(true).to be_true
ArgumentError:
wrong number of arguments (1 for 0)
spec_helper
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'
config.expect_with :rspec do |c|
c.syntax = :expect
end
end
推荐答案
这里说期望语法来自 rspec 2.11,所以我猜 2.8 是旧的 http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
Here it says that expect syntax comes in rspec 2.11, so I guess 2.8 is old http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
这篇关于Rspec 2.8.0,expect(something) 导致 ArgumentError:参数数量错误(1 代表 0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!