ruby-on-railsrspecchewy-gem

Rspec - bypass strategy on Chewy


Chewy documentation recommend set up the :bypass strategy for tests, with:

RSpec.configure do |config|
  config.before(:suite) do
    Chewy.strategy(:bypass)
  end
end

But I get a:

undefined method `strategy' for Chewy:Module (NoMethodError)

Here my spec_helper.rb

require 'devise'
require 'support/controller_macros'
require 'chewy/rspec'


RSpec.configure do |config|

  config.before(:suite) do
    Chewy.strategy(:bypass)
  end

  config.include Devise::TestHelpers, :type => :controller
  config.extend ControllerMacros, :type => :controller

 end

Any suggestion here ?

Thanks in advance

chewy version: 0.6.2

rails version: 4.1.7

rspec version: 3.1.0


Solution

  • Looks like bypass wasn't added until version 0.7.0. You're looking at documentation for a later version. If you click on the dropdown on github and select tags and select your version you'll see there's no mention of strategy.

    https://github.com/toptal/chewy/blob/v0.7.0/lib/chewy/strategy/bypass.rb