RSpec"失败/错误:无法从回溯中找到匹配的行"每次测试

时间:2014-09-29 19:23:22

标签: ruby rspec rbenv

我正在处理一些Ruby问题集。我使用的是Ubuntu 14.04,rbenv 0.4.0-98-g13a474c,rspec 3.1.4和ruby 2.0.0p353。对于我运行的每个测试,我都遇到了以下错误,我希望有人能指导我找到解决方案的正确方向。

我过去成功运行了rspec测试,但我似乎无法弄清楚当前设置的问题。

以下是我为每次测试收到的消息:

 6) age is an integer
 Failure/Error: Unable to find matching line from backtrace
 ArgumentError:
   wrong number of arguments (0 for 1)
 # /usr/lib/ruby/vendor_ruby/rspec/mocks.rb:10:in `setup'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/mocking_adapters/rspec.rb:19:in `setup_mocks_for_rspec'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example.rb:366:in `run_before_example'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example.rb:150:in `block in run'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example.rb:328:in `with_around_example_hooks'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example.rb:148:in `run'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example_group.rb:500:in `block in run_examples'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example_group.rb:496:in `map'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example_group.rb:496:in `run_examples'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/example_group.rb:463:in `run'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:111:in `block (2 levels) in run_specs'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:111:in `map'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:111:in `block in run_specs'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/reporter.rb:53:in `report'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:107:in `run_specs'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:85:in `run'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:69:in `run'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:37:in `invoke'
 # /var/lib/gems/1.9.1/gems/rspec-core-3.1.4/exe/rspec:4:in `<top (required)>'
 # /usr/local/bin/rspec:23:in `load'
 # /usr/local/bin/rspec:23:in `<main>'
 # 
 #   Showing full backtrace because every line was filtered out.
 #   See docs for RSpec::Configuration#backtrace_exclusion_patterns and
 #   RSpec::Configuration#backtrace_inclusion_patterns for more information.

编辑:以下是其中一个规范文件的示例,然而,问题出现在大约20个spec文件上。我知道我的解决方案是正确的,我的同事也没有同样的问题:

first_name = "M"
last_name = "R"
age = 23

describe 'first_name' do
  it "is defined as a local variable" do
    expect(defined?(first_name)).to eq 'local-variable'
  end

  it "is a String" do
    expect(first_name).to be_a String
  end
end

describe 'last_name' do
  it "is defined as a local variable" do
    expect(defined?(last_name)).to eq 'local-variable'
  end

  it "be a String" do
    expect(last_name).to be_a String
  end
end

describe 'age' do
  it "is defined as a local variable" do
    expect(defined?(age)).to eq 'local-variable'
  end

  it "is an integer" do
     expect(age).to be_a Fixnum
  end
end

0 个答案:

没有答案