[rspec-users] weirdness with rake spec!
David Chelimsky
dchelimsky at gmail.com
Wed Jun 23 13:55:42 EDT 2010
On Jun 23, 2010, at 12:07 PM, Patrick J. Collins wrote:
> Hi everyone.
>
> I am totally confused by this... If I run rake spec, I get a bunch of failures
> in a particular file, but if I run script/spec on that individual file, all
> examples pass.
>
> The error I am getting is with the pluralize method. I put a debugger
> statement in my code to inspect what is happening:
>
> (rdb:1) pluralize(5, 'foo')
> ArgumentError Exception: wrong number of arguments (2 for 0)
>
> ...
>
> This is a situation where I am doing the "self-shunt" method, because I don't
> know of a better way to accomplish this. In other words, I am doing:
>
> class Foo
>
> def initialize(template, number)
> @template = template
> @number = number
> end
>
> def bar
> pluralize(@number, 'foo')
> end
>
> def bar_link
> link_to bar, foo_bar_path
> end
>
> def method_missing(*args, &block)
> @template.send(*args, &block)
> end
>
> end
>
> .........
>
> Then in my spec I do:
>
> Foo.new(self, 2).bar.should == "foos"
>
> ..........
>
> And like I said, if I run this spec individually, it passes, but with rake
> spec, it gives me that wrong number of arguments error.
>
> I would love to structure this differently so that I don't need to pass self
> into the class initializer, but I am at a total loss for how to do that.
>
> If I do:
>
> include ActionView::Helpers
> include ActionController::UrlWriter
>
> Then I get "can't convert string into hash" errors when ever I try to access a
> named route with link_to.
>
> This is a problem I have had to face over and over, and has proven to be quite
> frustrating. The only solution I have found is to pass self into the method..
> So if anyone has any other suggestions, I'd love to hear it.
Is this a rails helper module? Is the spec in spec/helpers?
More information about the rspec-users
mailing list