palkan / n_plus_one_control

RSpec and Minitest matchers to prevent N+1 queries problem
MIT License
553 stars 20 forks source link

undefined method `include_context' #34

Closed rubyconvict closed 4 years ago

rubyconvict commented 4 years ago

Hi, having this code:

  describe "#orders" do
    context "n+1", :n_plus_one do
      populate { |n|
        create_list(:order, n)
      }

      specify do
        expect do
          described_class.orders
        end.to(
          perform_constant_number_of_queries.
            with_scale_factors(1, 2)
        )
      end
    end

when I run the spec I get this error:

/Users/me/.rvm/gems/ruby-2.6.2/gems/n_plus_one_control-0.3.1/lib/n_plus_one_control/rspec/context.rb:28:in `block in <top (required)>': undefined method `include_context' for #<RSpec::Core::Configuration:0x00007fd299134b88> (NoMethodError)
Did you mean?  inclusion_filter

I have these rspec gems versions:

    rspec (3.4.0)
      rspec-core (~> 3.4.0)
      rspec-expectations (~> 3.4.0)
      rspec-mocks (~> 3.4.0)
    rspec-activemodel-mocks (1.0.3)
      rspec-mocks (>= 2.99, < 4.0)
    rspec-core (3.4.2)
      rspec-support (~> 3.4.0)
    rspec-expectations (3.4.0)
      rspec-support (~> 3.4.0)
    rspec-mocks (3.4.1)
      rspec-support (~> 3.4.0)
    rspec-rails (3.4.2)
      rspec-core (~> 3.4.0)
      rspec-expectations (~> 3.4.0)
      rspec-mocks (~> 3.4.0)
      rspec-support (~> 3.4.0)
    rspec-support (3.4.1)
    rspec_junit_formatter (0.2.3)
      rspec-core (>= 2, < 4, != 2.12.0
palkan commented 4 years ago

include_context has been added in RSpec 3.5.

If you cannot upgrade RSpec, try to downgrade n_plus_one_control to 0.2.1, which doesn't use this method.

rubyconvict commented 4 years ago

@palkan Thank you very much for a quick and helpful answer! May I suggest an improvement with the PR above?