Sha256: fb9a91168a2bf95eeb89a82fb6d4048ed59d1e45f4b2cd7b3f1a1f15fd59c5fe

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true
module Helpers
  def stub_metadata(additional_metadata)
    stub_metadata = metadata_with(additional_metadata)
    allow(RSpec::Core::ExampleGroup).to receive(:metadata) { stub_metadata }
  end

  def metadata_with(additional_metadata)
    m = RSpec::Core::Metadata.new
    m.process("example group")

    group_metadata = additional_metadata.delete(:example_group)
    if group_metadata
      m[:example_group].merge!(group_metadata)
    end
    m.merge!(additional_metadata)
    m
  end

  def with_isolated_config
    original_config = RSpec.configuration
    RSpec.configuration = RSpec::Core::Configuration.new
    RSpec.configure do |c|
      c.include RSpec::Rails::FixtureSupport
      c.add_setting :use_transactional_fixtures, :alias_with => :use_transactional_examples
      c.add_setting :use_instantiated_fixtures
      c.add_setting :global_fixtures
      c.add_setting :fixture_path
    end
    yield
    RSpec.configuration = original_config
  end

  RSpec.configure {|c| c.include self}
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rspec-activemodel-mocks-1.2.1 spec/support/helpers.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rspec-activemodel-mocks-1.2.0/spec/support/helpers.rb
rspec-activemodel-mocks-1.2.0 spec/support/helpers.rb