Sha256: 8012de5d458632e6ebaa52cfe4695c2bfd1f4620033c52d52af0964ef5ac653f

Contents?: true

Size: 510 Bytes

Versions: 4

Compression:

Stored size: 510 Bytes

Contents

# frozen_string_literal: true

::RSpec.shared_context "n_plus_one_control", n_plus_one: true do
  # Helper to access populate block from within example/matcher
  let(:n_plus_one_populate) do |ex|
    if ex.example_group.populate.nil?
      raise(
        <<~MSG
          Populate block is missing!

          Please provide populate callback, e.g.:

            populate { |n| n.times { create_some_stuff } }
        MSG
      )
    end
    ->(n) { ex.instance_exec(n, &ex.example_group.populate) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
n_plus_one_control-0.1.2 lib/n_plus_one_control/rspec/context.rb
n_plus_one_control-0.1.1 lib/n_plus_one_control/rspec/context.rb
n_plus_one_control-0.1.0 lib/n_plus_one_control/rspec/context.rb
n_plus_one_control-0.0.3 lib/n_plus_one_control/rspec/context.rb