Sha256: d1ee24515187c2a5d2ab680ab0dd3e2f4daad509034d5231c49125e428fd8776

Contents?: true

Size: 1.99 KB

Versions: 41

Compression:

Stored size: 1.99 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

module SharedExampleGroupExample
  class OneThing
    def what_things_do
      "stuff"
    end
  end
  
  class AnotherThing
    def what_things_do
      "stuff"
    end
  end
  
  class YetAnotherThing
    def what_things_do
      "stuff"
    end
  end
  
  # A SharedExampleGroup is an example group that doesn't get run.
  # You can create one like this:
  share_examples_for "most things" do
    def helper_method
      "helper method"
    end
    
    it "should do what things do" do
      @thing.what_things_do.should == "stuff"
    end
  end

  # A SharedExampleGroup is also module. If you create one like this
  # it gets assigned to the constant AllThings
  share_as :MostThings do
    def helper_method
      "helper method"
    end
    
    it "should do what things do" do
      @thing.what_things_do.should == "stuff"
    end
  end
  
  describe OneThing do
    # Now you can include the shared example group like this, which 
    # feels more like what you might say ...
    it_should_behave_like "most things"
    
    before(:each) { @thing = OneThing.new }
    
    it "should have access to helper methods defined in the shared example group" do
      helper_method.should == "helper method"
    end
  end

  describe AnotherThing do
    # ... or you can include the example group like this, which
    # feels more like the programming language we love.
    it_should_behave_like MostThings
    
    before(:each) { @thing = AnotherThing.new }

    it "should have access to helper methods defined in the shared example group" do
      helper_method.should == "helper method"
    end
  end

  describe YetAnotherThing do
    # ... or you can include the example group like this, which
    # feels more like the programming language we love.
    include MostThings
    
    before(:each) { @thing = AnotherThing.new }

    it "should have access to helper methods defined in the shared example group" do
      helper_method.should == "helper method"
    end
  end
end

Version data entries

41 entries across 41 versions & 7 rubygems

Version Path
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
picolena-0.1.1 rails_plugins/rspec/examples/pure/shared_example_group_example.rb
picolena-0.1.0 rails_plugins/rspec/examples/pure/shared_example_group_example.rb
picolena-0.1.4 rails_plugins/rspec/examples/pure/shared_example_group_example.rb
picolena-0.1.3 rails_plugins/rspec/examples/pure/shared_example_group_example.rb
picolena-0.1.2 rails_plugins/rspec/examples/pure/shared_example_group_example.rb
picolena-0.1.5 rails_plugins/rspec/examples/pure/shared_example_group_example.rb
pictrails-0.5.0 vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
radiant-0.6.5.1 vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
radiant-0.6.5 vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
radiant-0.6.7 vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
radiant-0.6.6 vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
radiant-0.6.8 vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
radiant-0.6.9 vendor/plugins/rspec/examples/pure/shared_example_group_example.rb
rspec-0.0.10 examples/pure/shared_example_group_example.rb
rspec-1.1.1 examples/pure/shared_example_group_example.rb