[rspec-users] issues with the trunk of rspec-rails
dchelimsky at gmail.com
Thu Feb 12 00:40:29 EST 2009
On Wed, Feb 11, 2009 at 2:52 PM, nathan at pivotalsf.com <nwilmes at gmail.com> wrote:
> On Feb 10, 8:49 pm, David Chelimsky <dchelim... at gmail.com> wrote:
>> On Tue, Feb 10, 2009 at 2:02 PM, Nathan Wilmes <nat... at pivotallabs.com> wrote:
>> > (4) assigns(:xxx) will give really bad errors if your class doesn't happen
>> > to define == in such a way that it can equate to FalseClass.
>> Can you provide an example?
> Let's say I have a simple object class Foo, defined as:
> class Foo
> def initialize(bar)
> @bar = bar
> attr_reader :bar
> def ==(other)
> self.bar == other.bar
> and a controller that sets a model variable @foo to Foo.new.
> If you run an rspec controller spec and ask it about assigns(:foo), it
> will complain with
> an error about how it doesn't know what the 'bar' method is on
> FalseClass. It does this
> the moment you ask for assigns(:foo).
> Not the biggest deal once you understand what's going on (you can
> solve it by making the == method smart
> enough to return false unless other is a Foo class) but a very
> confusing error to track down.
Well - you shouldn't have to do such a workaround. Fixed: 3 down, 1 left
More information about the rspec-users