【问题标题】:RSpec - WrongScopeError: expect is not available on an example groupRSpec - WrongScopeError:期望在示例组中不可用
【发布时间】:2015-05-09 01:33:23
【问题描述】:

我收到此错误:

method_missing':expect 在示例组中不可用(例如 describecontext 块)。它只能从内部获得 单个示例(例如it 块)或来自运行的构造 示例的范围(例如beforelet 等)。 (RSpec::Core::ExampleGroup::WrongScopeError)

对于这个规范:

describe 'canary test' do
    expect(true).to be true
end

【问题讨论】:

    标签: ruby-on-rails rspec


    【解决方案1】:

    您需要将测试包装在一个块中,例如你可以:

    describe 'canary test' do
      it 'it true' do
        expect(true).to be true
      end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多