Sha256: 929a6090944a414eae0c4368d77b70367d6c3048889c40f869b94d75abf7772e

Contents?: true

Size: 1.41 KB

Versions: 40

Compression:

Stored size: 1.41 KB

Contents

shared_examples_for "metadata hash builder" do
  context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to true" do
    let(:hash) { metadata_hash(:foo, :bar, :bazz => 23) }

    before(:each) do
      RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = true }
    end

    it 'treats symbols as metadata keys with a true value' do
      expect(hash[:foo]).to be(true)
      expect(hash[:bar]).to be(true)
    end

    it 'still processes hash values normally' do
      expect(hash[:bazz]).to be(23)
    end
  end

  context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to false" do
    let(:warning_receiver) { Kernel }

    before(:each) do
      RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = false }
      warning_receiver.stub(:warn)
    end

    it 'prints a deprecation warning about any symbols given as arguments' do
      warning_receiver.should_receive(:warn).with(/In RSpec 3, these symbols will be treated as metadata keys/)
      metadata_hash(:foo, :bar, :key => 'value')
    end

    it 'does not treat symbols as metadata keys' do
      expect(metadata_hash(:foo, :bar, :key => 'value')).not_to include(:foo, :bar)
    end

    it 'does not print a warning if there are no symbol arguments' do
      warning_receiver.should_not_receive(:warn)
      metadata_hash(:foo => 23, :bar => 17)
    end
  end
end

Version data entries

40 entries across 40 versions & 12 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/spec/support/shared_example_groups.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/spec/support/shared_example_groups.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/spec/support/shared_example_groups.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/spec/support/shared_example_groups.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/spec/support/shared_example_groups.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/spec/support/shared_example_groups.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/spec/support/shared_example_groups.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/spec/support/shared_example_groups.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-core-2.14.8/spec/support/shared_example_groups.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-core-2.13.0/spec/support/shared_example_groups.rb
dxruby_rp5-0.0.4 spec/vendor/rspec-core-2.14.7/spec/support/shared_example_groups.rb
rspec-core-2.14.8 spec/support/shared_example_groups.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-core-2.14.7/spec/support/shared_example_groups.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-core-2.14.7/spec/support/shared_example_groups.rb
dxruby_rp5-0.0.3 spec/vendor/rspec-core-2.14.7/spec/support/shared_example_groups.rb
tuktuk-rails-0.0.10 vendor/bundle/ruby/2.0.0/gems/rspec-core-2.14.7/spec/support/shared_example_groups.rb
tuktuk-rails-0.0.9 vendor/bundle/ruby/2.0.0/gems/rspec-core-2.14.7/spec/support/shared_example_groups.rb
tuktuk-rails-0.0.8 vendor/bundle/ruby/2.0.0/gems/rspec-core-2.14.7/spec/support/shared_example_groups.rb
tuktuk-rails-0.0.7 vendor/bundle/ruby/2.0.0/gems/rspec-core-2.14.7/spec/support/shared_example_groups.rb
dxruby_rp5-0.0.2 spec/vendor/rspec-core-2.14.7/spec/support/shared_example_groups.rb