jimweirich / rspec-given

Given/When/Then keywords for RSpec Specifications
https://github.com/jimweirich/rspec-given
MIT License
653 stars 61 forks source link

Named When clause catches all errors / exceptions, not reraising them, hiding them from developer #23

Closed idrozd closed 11 years ago

idrozd commented 11 years ago

Hehe

Hello again ) I'm starting to worry, that`s something is wrong with my setup

Anyway,

    ...
    When(:request_attempt) { EAI.export_signature signature }
    ...
        describe 'successful export causes signature to be saved with S status' do
          Given(:response) { {status: 200} }
          Then { signature.status  ==  Signature::STATUS_SUCCESS }
        end

Gives me

...
     successful export causes signature to be saved with S status
        should When you call a matcher in an example without a String, like this:

 specify { object.should matcher }

 or this:

it {  should matcher }

RSpec expects the matcher to have a #description method. You should either
add a String to the example this matcher is being used in, or give it a
description method. Then you won't have to suffer this lengthy warning again. (FAILED - 1)

)) REALLY annoying if you have 20 of them While

    ...
    When { EAI.export_signature signature }
    ...
        describe 'successful export causes signature to be saved with S status' do
          Given(:response) { {status: 200} }
          Then { signature.status  ==  Signature::STATUS_SUCCESS }
        end

Gives

Failures:

  1) EAI.export_signature ANC accept signature behaves like it handles response handled cases successful export causes signature to be saved with S status 
     Failure/Error: When { EAI.export_signature signature }
     NameError:
       undefined local variable or method `asghxgasjxhaxgjxgj' for EAI:Class

Once again, I really like rspec-given ) Thank you!

jimweirich commented 11 years ago

Named When will capture exceptions and store them in the named result (ie. the result of the When IS an error). Referencing the result will rethrow the error. If you never reference the result, then why are you capturing it?

The behavior is as designed.