Sha256: 63d0bed8cc6b1c4d247c3c38101727c70d5252a7cd10109298b6ec040992e9e3

Contents?: true

Size: 1.59 KB

Versions: 143

Compression:

Stored size: 1.59 KB

Contents

require "spec_helper"

describe RSpec::SharedContext do
  it "is accessible as RSpec::Core::SharedContext" do
    RSpec::Core::SharedContext
  end

  it "is accessible as RSpec::SharedContext" do
    RSpec::SharedContext
  end

  it "supports before and after hooks" do
    before_all_hook = false
    before_each_hook = false
    after_each_hook = false
    after_all_hook = false
    shared = Module.new do
      extend RSpec::SharedContext
      before(:all) { before_all_hook = true }
      before(:each) { before_each_hook = true }
      after(:each)  { after_each_hook = true }
      after(:all)  { after_all_hook = true }
    end
    group = RSpec::Core::ExampleGroup.describe do
      include shared
      example { }
    end

    group.run

    before_all_hook.should be_true
    before_each_hook.should be_true
    after_each_hook.should be_true
    after_all_hook.should be_true
  end

  it "supports let" do
    shared = Module.new do
      extend RSpec::SharedContext
      let(:foo) { 'foo' }
    end
    group = RSpec::Core::ExampleGroup.describe do
      include shared
    end

    group.new.foo.should eq('foo')
  end

  %w[describe context].each do |method_name|
    it "supports nested example groups using #{method_name}" do
      shared = Module.new do
        extend RSpec::SharedContext
        send(method_name, "nested using describe") do
          example {}
        end
      end
      group = RSpec::Core::ExampleGroup.describe do
        include shared
      end

      group.run

      group.children.length.should eq(1)
      group.children.first.examples.length.should eq(1)
    end
  end
end

Version data entries

143 entries across 90 versions & 14 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rspec-core-2.10.0/spec/rspec/core/shared_context_spec.rb
classiccms-0.7.5 vendor/bundle/gems/rspec-core-2.9.0/spec/rspec/core/shared_context_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-core-2.9.0/spec/rspec/core/shared_context_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rspec-core-2.10.0/spec/rspec/core/shared_context_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-core-2.9.0/spec/rspec/core/shared_context_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rspec-core-2.10.0/spec/rspec/core/shared_context_spec.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-core-2.11.1/spec/rspec/core/shared_context_spec.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/rspec-core-2.11.1/spec/rspec/core/shared_context_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-core-2.10.0/spec/rspec/core/shared_context_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rspec-core-2.9.0/spec/rspec/core/shared_context_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-core-2.10.0/spec/rspec/core/shared_context_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rspec-core-2.9.0/spec/rspec/core/shared_context_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-core-2.9.0/spec/rspec/core/shared_context_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rspec-core-2.10.0/spec/rspec/core/shared_context_spec.rb
remq-0.0.4 vendor/bundle/gems/rspec-core-2.12.2/spec/rspec/core/shared_context_spec.rb
remq-0.0.3 vendor/bundle/gems/rspec-core-2.12.2/spec/rspec/core/shared_context_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-core-2.10.1/spec/rspec/core/shared_context_spec.rb
classiccms-0.6.9 vendor/bundle/gems/rspec-core-2.9.0/spec/rspec/core/shared_context_spec.rb
classiccms-0.6.9 vendor/bundle/gems/rspec-core-2.10.0/spec/rspec/core/shared_context_spec.rb
rspec-core-2.12.2 spec/rspec/core/shared_context_spec.rb