1 require File.dirname(__FILE__) + '/spec_helper'
3 module SharedExampleGroupExample
22 # A SharedExampleGroup is an example group that doesn't get run.
23 # You can create one like this:
24 share_examples_for "most things" do
29 it "should do what things do" do
30 @thing.what_things_do.should == "stuff"
34 # A SharedExampleGroup is also module. If you create one like this
35 # it gets assigned to the constant AllThings
36 share_as :MostThings do
41 it "should do what things do" do
42 @thing.what_things_do.should == "stuff"
47 # Now you can include the shared example group like this, which
48 # feels more like what you might say ...
49 it_should_behave_like "most things"
51 before(:each) { @thing = OneThing.new }
53 it "should have access to helper methods defined in the shared example group" do
54 helper_method.should == "helper method"
58 describe AnotherThing do
59 # ... or you can include the example group like this, which
60 # feels more like the programming language we love.
61 it_should_behave_like MostThings
63 before(:each) { @thing = AnotherThing.new }
65 it "should have access to helper methods defined in the shared example group" do
66 helper_method.should == "helper method"
70 describe YetAnotherThing do
71 # ... or you can include the example group like this, which
72 # feels more like the programming language we love.
75 before(:each) { @thing = AnotherThing.new }
77 it "should have access to helper methods defined in the shared example group" do
78 helper_method.should == "helper method"