[rspec-users] Weird failing spec
dchelimsky at gmail.com
Sat Oct 27 01:18:12 EDT 2007
On 10/26/07, Tarsoly András <tarsolya at gmail.com> wrote:
> On 2007.10.26., at 21:28, Ashley Moran wrote:
> > First, like David said earlier, you're putting too much into one spec:
> > Also I don't think you need '@option = ' in front of
> > @option.update_attributes!, as that method call modifies the object
> > in-place. But that's a Rails issue.
> > One other thing - you aren't stubbing CalcumOption.find in
> > 'Admin::OptionsController, "#update (POST) with valid params"'. Are
> > you sure this isn't loading real models?
> Yes, I was aware of this as I was just messing around, trying to
> figure out where could this failed specs could come from, I pastied
> the real stuff with a rake spec --trace output here:
> > As for the actual problem you asked about... sorry but I am lost.
> > I've looked over it about 5 times and everything I thought was wrong
> > was me not paying attention. I can't see ANY reason it should fail.
> > Is it still not working?
> In the link above, you can see, that the specs still fail. Looks like
> it has to do something with exception handling as only those examples
> fail which should raise errors (eg. doing :create!
> or :update_attributes! with invalid and/or missing attributes and
> specing :and_raise())
> The test.log sample in the pastie shows unfinished requests in all
> the :update! specs, where the :update_attributes! is stubbed on the
> However, one example at #create raises an Exception properly, which
> can be seen in the log too, only where I'm using :and_raise().
> I believe I stubbed everything out properly in the above example. I'm
> using edge rspec with the latest rspec_on_rails and using autotest
> for convenient coding.
> The problem is, I'm rather new to rspec / ruby / rails, so I can't
> just start to track this down, however I went into the rspec source
> already, but got lost pretty much :)
wrong number of arguments (0 for 1)
That's coming from ActiveRecord::RecordInvalid, which takes an
argument in its constructor. I think I left this out in my example to
you earlier. If you pass raise_error a class, it instantiates in order
to throw an instance of it. To solve your problem, you just need to
create an instance and pass it the mock_model:
Sorry if I led you astray on that one.
More information about the rspec-users