[rspec-devel] [ rspec-Patches-14255 ] Fixed examples in mock_spec.rb and shared_behaviour_spec.rb

noreply at rubyforge.org noreply at rubyforge.org
Wed Sep 26 13:11:10 EDT 2007


Patches item #14255, was opened at 2007-09-26 19:11
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=14255&group_id=797

Category: mock module
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Antti Tarvainen (tarvaina)
Assigned to: Nobody (None)
Summary: Fixed examples in mock_spec.rb and shared_behaviour_spec.rb

Initial Comment:
A recurring pattern in rspec internal examples is this:

it "should fail with a meaningful error message" do
  begin
    @object.failing_operation
  rescue PanicExceptionError => e
    e.message.should == "Something went wrong!"
  end
end


The problem with this pattern is that it gives a false positive when @object.failing_operation doesn't raise a PanicExceptionError.


This patch fixes these examples by using the raise_error matcher. The above example thus becomes:

it "should fail with a meaningful error message" do
  lambda {
    @object.failing_operation
  }.should raise_error(PanicExceptionError, "Something went wrong!")
end


These changes revealed one false positive in mock_spec.rb. I marked the example pending and added another example that demonstrates the current behavior.


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=14255&group_id=797


More information about the rspec-devel mailing list