Sha256: 02b2659328ef8fc93805bb5cb61984b83d2f048e9cdb74bc8936e91c9b4e0d0e

Contents?: true

Size: 931 Bytes

Versions: 5

Compression:

Stored size: 931 Bytes

Contents

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

  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
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
rspec-instructure-1.3.3 examples/passing/shared_example_group_example.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/examples/passing/shared_example_group_example.rb
rspec-1.3.2 examples/passing/shared_example_group_example.rb
rspec-1.3.1 examples/passing/shared_example_group_example.rb
rspec-1.3.1.rc examples/passing/shared_example_group_example.rb