【发布时间】:2018-07-19 12:49:05
【问题描述】:
我正在使用 RSpec 和 rspec-mocks 为一些对象制作一个模拟。 我反对的是以下内容。
在规范文件中
describe 'foo' do
before do
Mock.start
end
end
在模拟文件中
module Mock
def self.start
SomeClass.stub_chain(:foo).and_return(Mock.mock_create)
end
def self.mock_create
return json
end
end
但如果我使用stub_chain,则会出现以下弃用警告。
Using `stub_chain` from rspec-mocks' old `:should` syntax without explicitly enabling the syntax is deprecated. Use the new `:expect` syntax or explicitly enable `:should` instead.
您有解决此警告的任何想法吗?
allow 方法看起来没用,因为我想要像 Object.something_instead_of_stub_chain(:create).and_return(Mock.mock_create) 这样的代码。
【问题讨论】:
标签: rspec ruby-on-rails-5 rspec-mocks