On Wed, Feb 11, 2009 at 2:52 PM, nat...@pivotalsf.com <nwil...@gmail.com> wrote:
> On Feb 10, 8:49 pm, David Chelimsky <dchelim...@gmail.com> wrote:
>> On Tue, Feb 10, 2009 at 2:02 PM, Nathan Wilmes <nat...@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
>  end
>  attr_reader :bar
>
>  def ==(other)
>    self.bar == other.bar
>  end
> end
>
> 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
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to