Sha256: a9b39c051d001f282fbe84d72c968d5a8b168608fb10f93e1158a9ea301be25f

Contents?: true

Size: 1.92 KB

Versions: 27

Compression:

Stored size: 1.92 KB

Contents

require 'spec_helper'

describe RSpec do
  describe "::configuration" do
    it "returns the same object every time" do
      expect(RSpec.configuration).to equal(RSpec.configuration)
    end
  end

  describe "::configuration=" do
    it "sets the configuration object" do
      configuration = RSpec::Core::Configuration.new

      RSpec.configuration = configuration

      expect(RSpec.configuration).to equal(configuration)
    end
  end

  describe "::configure" do
    it "yields the current configuration" do
      RSpec.configure do |config|
        expect(config).to equal(RSpec::configuration)
      end
    end
  end

  describe "::world" do
    it "returns the same object every time" do
      expect(RSpec.world).to equal(RSpec.world)
    end
  end

  describe "::world=" do
    it "sets the world object" do
      world = RSpec::Core::World.new

      RSpec.world = world

      expect(RSpec.world).to equal(world)
    end
  end

  describe "::reset" do
    it "resets the configuration and world objects" do
      config_before_reset = RSpec.configuration
      world_before_reset  = RSpec.world

      RSpec.reset

      expect(RSpec.configuration).not_to equal(config_before_reset)
      expect(RSpec.world).not_to equal(world_before_reset)
    end
  end

  # This is hard to test :(. Best way I could come up with was starting
  # fresh ruby process w/o this stuff already loaded.
  it "loads mocks and expectations when the constants are referenced" do
    code = "$LOAD_PATH.replace(#{$LOAD_PATH.inspect}); " +
           'require "rspec"; ' +
           "puts RSpec::Mocks.name; " +
           "puts RSpec::Expectations.name"

    result = `ruby -e '#{code}'`.chomp
    expect(result.split("\n")).to eq(%w[ RSpec::Mocks RSpec::Expectations ])
  end

  it 'correctly raises an error when an invalid const is referenced' do
    expect {
      RSpec::NotAConst
    }.to raise_error(NameError, /uninitialized constant RSpec::NotAConst/)
  end
end

Version data entries

27 entries across 27 versions & 8 rubygems

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