Update_attributes fails in rake spec but not in script/spec?

Hi,

So I just wrote a spec, and tested it by running script/spec
models/result_list_spec.rb

I get:

Finished in 28.558841 seconds

5 examples, 0 failures


So then I did: rake spec

and I get a bunch of errors on that same file “wrong number of arguments
(0 for 3)”

I then threw a debugger into the code to try to see where it was
failing, and
it was failing when I was doing self.update_attributes in the model…

I tried assigning this myself in the debugger console:

(rdb:1) self.update_attribute(:job_item_count, 4)
ArgumentError Exception: wrong number of arguments (0 for 3)

(rdb:1) self
#<ResultList id: 1, table_id: nil, newsletter_id: 3, type: nil,
job_start:
“2010-04-30 10:25:17”, job_finish: “2010-04-30 10:25:17”,
job_item_count: 0,
job_action_count: -5, job_error: nil, attachment_file_name: nil,
attachment_content_type: nil, attachment_file_size: nil,
attachment_updated_at:
nil, created_at: “2010-04-30 18:01:41”, updated_at: “2010-04-30
18:01:41”>

… ???

Can anyone please explain to me why this is behaving this way?

Patrick J. Collins
http://collinatorstudios.com

Well, after some investigating, I discovered than another one of my spec
files
was causing this behavior. When removing this other spec file, the one
that
was failing via rake spec no longer failed… Totally bizarre.

This is the spec that fails:
http://gist.github.com/386129

And this is the spec that when I delete, the other one that failed now
passes:
http://gist.github.com/386125

This is so weird, I would really love it if someone could shed some
light on
this.

Patrick J. Collins
http://collinatorstudios.com

On May 1, 2010, at 2:29 AM, Patrick J. Collins wrote:

This is so weird, I would really love it if someone could shed some light on
this.

Hey Patrick,

This is just a guess, but on line 3 of http://gist.github.com/386125,
ActionView::Helpers is being mixed in to the main object, which means
it’s methods are made accessible to every single object in the system.
It’s very likely that it is overriding methods that are deeper down the
stack. Try moving that include statement inside the ExampleGroup (i.e.
inside the describe block).

If that doesn’t work, please run the specs with the -b flag, which
produces a full backtrace, and then gist the output for us.

HTH,
David

ActionView::Helpers is being mixed in to the main object, which means it’s
methods are made accessible to every single object in the system. It’s very
likely that it is overriding methods

Hi David,

Ahh… Thank you very much, that was indeed the problem. rake spec now
passes
all test.

Patrick J. Collins
http://collinatorstudios.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs