Bugs: Browse | Submit New | Admin

[#26403] MockExpectationError can b ecaught by code and prevent spec from failing

Date:
2009-06-23 17:59
Priority:
3
Submitted By:
Arnon Moscona (arnonmoscona)
Assigned To:
Nobody (None)
Category:
expectation module
State:
Open
Summary:
MockExpectationError can b ecaught by code and prevent spec from failing

Detailed description
Example:

...
describe "MockExpectationError can be caught by code and prevent spec from failing" do
  it "should fail, but does not" do
    s = "string"
    s.should_not receive(:length)
    begin
      l=s.length
    rescue Exception
    end
  end
end


Note that while not generally good to do, in some cases digesting Exception is necessary (especially when designing
resilient frameworks). One must still validate some behavior that may not float the exception back to the spec.

A temporary hack to work around it used in our code base is attached.

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
rspec_hacks.rb rspec_hacks.rb Download

Changes:

Field Old Value Date By
File Added4574: rspec_hacks.rb2009-06-23 17:59arnonmoscona