jimweirich / rspec-given

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

have_failed matcher needs description #37

Closed jimweirich closed 10 years ago

jimweirich commented 10 years ago

Using the "have_failed" matcher with flexmock invokes an RSpec warning. For example, the following spec:

require 'rspec/given'
require 'flexmock/rspec/configure'

class Dog
  def initialize(tail)
    @tail = tail
  end
  def happy
  end
end

describe Dog do
  Given(:tail) { flexmock() }
  Given(:fido) { Dog.new(tail) }
  When { fido.happy }
  Then { tail.should have_received(:wag).once }
end

gives the following output:

F

Failures:

  1) Dog 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.
     Failure/Error: Then { tail.should have_received(:wag).once }
       expected wag(...) to be received by <FlexMock:unknown> once.
       No messages have been received
     # /Users/jim/pgm/ruby/testexample/missing_description_spec.rb:16:in `block (2 levels) in <top (required)>'
     # /Users/jim/pgm/ruby/testexample/missing_description_spec.rb:16:in `block in Then'

Finished in 0.00042 seconds
1 example, 1 failure
jimweirich commented 10 years ago

Nevermind ... wrong project. This is a flexmock problem with the have_received matcher, not a problem with rspec/given's have_failed matcher.