Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby Rspec块(3层)位于<;顶部(必需)>;错误_Ruby_Rspec_Travis Ci - Fatal编程技术网

Ruby Rspec块(3层)位于<;顶部(必需)>;错误

Ruby Rspec块(3层)位于<;顶部(必需)>;错误,ruby,rspec,travis-ci,Ruby,Rspec,Travis Ci,提交项目时,我在travis ci中遇到以下错误: Failures: 1) salt on unsupported distributions we fail Failure/Error: expect { subject }.to raise_error(/Unsupported platform: Unsupported/) expected Exception with message matching /Unsupported platform: Unsu

提交项目时,我在travis ci中遇到以下错误:

Failures:

  1) salt on unsupported distributions we fail
     Failure/Error: expect { subject }.to raise_error(/Unsupported platform: Unsupported/)
       expected Exception with message matching /Unsupported platform: Unsupported/ but nothing was raised
     # ./spec/classes/salt_spec.rb:9:in `block (3 levels) in <top (required)>'

Finished in 6.5 seconds
47 examples, 1 failure

Failed examples:

rspec ./spec/classes/salt_spec.rb:8 # salt on unsupported distributions we fail
/home/travis/.rvm/rubies/ruby-2.0.0-p598/bin/ruby -S rspec spec/classes/salt_spec.rb --color failed
如果我正确理解了中的
块(3个级别),那么缩进在第5行和第11行之间的某个地方是错误的,但是我觉得它是正确的。任何与此相关的帮助都将不胜感激,因为这是我第一次与rspec打交道,我正在努力学习

编辑 这是我自己修好的。我更改了以下代码:

  context 'on unsupported distributions' do
    let(:facts) {{ :osfamily => 'Unsupported' }}

    it 'we fail' do
      expect { subject }.to raise_error(/Unsupported platform: Unsupported/)
    end
  end
为此:

  context 'on unsupported distributions' do
    let(:facts) {{ :osfamily => 'Unsupported' }}

    it 'we fail' do
      should compile.and_raise_error(/Unsupported platform: Unsupported/)
    end
  end

现在它似乎正在过去。我想我的问题是:这是正确的还是我错误地通过了考试?

通过更改以下内容解决了这一问题:

上下文“在不支持的发行版上”不支持 let(:facts){{osfamily=>'Unsupported'}

it 'we fail' do
  expect { subject }.to raise_error(/Unsupported platform: Unsupported/)
end
it 'we fail' do
  should compile.and_raise_error(/Unsupported platform: Unsupported/)
end
为此:

  context 'on unsupported distributions' do
    let(:facts) {{ :osfamily => 'Unsupported' }}

    it 'we fail' do
      should compile.and_raise_error(/Unsupported platform: Unsupported/)
    end
  end
上下文“在不支持的发行版上”不支持 let(:facts){{osfamily=>'Unsupported'}

it 'we fail' do
  expect { subject }.to raise_error(/Unsupported platform: Unsupported/)
end
it 'we fail' do
  should compile.and_raise_error(/Unsupported platform: Unsupported/)
end

不知道这为什么会被否决。答案不是很明显,我不得不搜索git问题以找到解决方案。