How to avoid deprecation warning for stub_chain in RSpec 3.0?

后端 未结 4 1830
清歌不尽
清歌不尽 2020-12-13 09:26

When I run a test with stub_chain, I\'ll get a deprecation warning.

describe \"stubbing a chain of methods\" do
  subject { Object.new }

  context \"given s         


        
4条回答
  •  失恋的感觉
    2020-12-13 09:55

    Here's a solution that worked for me - I'm using Rails 4.1.7 :

    Inside spec/spec_helpber.rb, set rspec-expectations’ and/or rspec-mocks’ syntax as following:

    RSpec.configure do |config|
      config.mock_with :rspec do |mocks|
        mocks.syntax = [:should, :expect]
      end
      config.expect_with :rspec do |expectations|
        expectations.syntax = [:should, :expect]
      end
    end
    

    Hope this helps someone else :)

提交回复
热议问题