method

it_should_behave_like

Importance_2
it_should_behave_like(*shared_example_groups) public

Use this to pull in examples from shared example groups.

Show source
Register or log in to add new notes.
June 1, 2009
1 thank

Shared examples

Use it together with share_examples_for like this:

  share_examples_for "a shape" do
    it "should have a color" do
      # ...
    end

    it "should have a center point" do
      # ...
    end
  end

  describe "a circle" do
    it_should_behave_like "a shape"

    it "should be round" do
      # ...
    end
  end
June 12, 2009
0 thanks

Reusing shared examples

 share_examples_for "a shape" do
    it "should have a color" do
      @shape.color.should == :black
    end
  end

 describe "a circle" do
   before(:all) do
     @shape = Circle.new
   end
   it_should_behave_like "a shape"
 end