我有一个新的repo(非rails)和rspec 2.8.0。
由于一些奇怪的原因,我无法使用expect语法。
这个荒谬的规范:
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
答案 0 :(得分:1)
这里说的是期望语法来自rspec 2.11,所以我猜2.8是旧的http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax