psyho / bogus

Fake library for Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unfriendly output on expectation failure

skwp opened this issue · comments

Here's an example..it seems like this expectation doesn't have a good to_s version of itself, as this is pretty unreadable

       Expected #<#<Class:0x007fa98af43810>:0x007fa98af62288 @__shadow__=#<Bogus::Shadow:0x007fa98af62148 @calls=[#<struct Bogus::Interaction method=:auction_ended_with_winner, args=[#<#<Class:0x007fa98afa25b8>:0x007fa98c40ff50 @__shadow__=#<Bogus::Shadow
:0x007fa98c40ff28 @calls=[#<struct Bogus::Interaction method=:id, args=[], return_value=nil, error=nil, has_result=nil>, #<struct Bogus::Interaction method=:end_time, args=[], return_value=nil, error=nil, has_result=nil>, #<struct Bogus::Interaction metho
d=:end, args=[], return_value=nil, error=nil, has_result=nil>, #<struct Bogus::Interaction method=:has_high_bidder?, args=[], return_value=nil, error=nil, has_result=nil>, #<struct Bogus::Interaction method=:method_missing, args=[:stub, :has_high_bidder?]
, return_value=nil, error=nil, has_result=nil>], @stubs=[], @required=#<Set: {}>>>], return_value=nil, error=nil, has_result=nil>], @stubs=[], @required=#<Set: {}>>> to have received auction_ended_no_bids(#<#<Class:0x007fa98afa25b8>:0x007fa98c40ff50 @__sh
adow__=#<Bogus::Shadow:0x007fa98c40ff28 @calls=[#<struct Bogus::Interaction method=:id, args=[], return_value=nil, error=nil, has_result=nil>, #<struct Bogus::Interaction method=:end_time, args=[], return_value=nil, error=nil, has_result=nil>, #<struct Bo
gus::Interaction method=:end, args=[], return_value=nil, error=nil, has_result=nil>, #<struct Bogus::Interaction method=:has_high_bidder?, args=[], return_value=nil, error=nil, has_result=nil>, #<struct Bogus::Interaction method=:method_missing, args=[:st
ub, :has_high_bidder?], return_value=nil, error=nil, has_result=nil>], @stubs=[], @required=#<Set: {}>>>), but it didn't.

This results from expecting messages on fakes.

  let(:listener) { fake(NotificationListener)}
      it "publishes an ended_no_bids event" do
        listener.should have_received.auction_ended_no_bids(auction)
      end

Any ideas if something unexpected is happening here? I could dig in and fix this..just want to know if maybe the usage is not anticipated?

Strange, I've got much simpler error in your example:

Expected #<NotificationListener:0xceb044> to have received auction_ended_no_bids(#<Auction:0xd6a7f4>), but it didn't.

What version of bogus/ruby are you using?

I'm closing the issue as it looks like it is fixed in the current version. Feel free to reopen it if you spot it again.