Hi all, Hoping you can help. I have a project using rspec 1.1.3 and rails 2.0.2. I''ve run into a small problem. Said project has a method in application_helper.rb named "description". Whenever a spec test fails, I see a message like so: *snip*/vendor/plugins/rspec/lib/spec/runner/reporter.rb:37:in `description'': wrong number of arguments (0 for 2) (ArgumentError) It just so happens that my description method takes 2 arguments. It seems that this method is clashing with one of the methods in rspec. Is there a workaround for this situation? It''s a pain to have to rename my method everytime I want to see a proper failure message from rspec. I''m attaching a full backtrace run with --trace. Thanks, e. -- ericw at xmtp.net "If the answer isn''t violence, neither is your silence!" -- Pop Will Eat Itself, "Ich Bin Ein Auslander" -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: failure.txt URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080514/dd856473/attachment.txt> -------------- next part --------------
On Wed, May 14, 2008 at 1:17 AM, EAW <ericw at xmtp.net> wrote:> Hi all, > > Hoping you can help. I have a project using rspec 1.1.3 and rails 2.0.2. > I''ve run into a small problem. Said project has a method in > application_helper.rb named "description". Whenever a spec test fails, I > see a message like so: > > *snip*/vendor/plugins/rspec/lib/spec/runner/reporter.rb:37:in > `description'': wrong number of arguments (0 for 2) (ArgumentError) > > It just so happens that my description method takes 2 arguments. It seems > that this method is clashing with one of the methods in rspec. Is there a > workaround for this situation? It''s a pain to have to rename my method > everytime I want to see a proper failure message from rspec. > > I''m attaching a full backtrace run with --trace.If the first argument to describe() is a module it gets included in the resulting example group. To avoid this, just make it a String: describe ''MyHelperModule'' do ... end In the next release there is a helper object you can use in your helper examples: describe HelperModule do it "should describe something by default" do helper.description.should == "something" end end In some future release, that is the only way it will work as we will no longer include the module in the example group. That might be a way off though. Cheers, David> > Thanks, > > e. > -- > ericw at xmtp.net > > "If the answer isn''t violence, neither is your silence!" > -- Pop Will Eat Itself, "Ich Bin Ein Auslander" > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Wed, May 14, 2008 at 2:17 AM, EAW <ericw at xmtp.net> wrote:> It seems that this method is clashing with one of the methods in rspec. Is > there a workaround for this situation? It''s a pain to have to rename my > method everytime I want to see a proper failure message from rspec.Not to be glib, but you could just rename it one time. :) Seriously though, ''description'' is an awfully generically named method to have exposed to every view in your app. Is that the best name for it? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080514/94c6ba39/attachment.html>
I followed your advice, with one slight addition. Inside of my describe block I included the ApplicationHelper manually, so that I could call the methods in it. Everything is working fine now. Thanks for your help. e. On May 14, 2008, at 6:44 AM, David Chelimsky wrote:> On Wed, May 14, 2008 at 1:17 AM, EAW <ericw at xmtp.net> wrote: >> Hi all, >> >> Hoping you can help. I have a project using rspec 1.1.3 and rails >> 2.0.2. >> I''ve run into a small problem. Said project has a method in >> application_helper.rb named "description". Whenever a spec test >> fails, I >> see a message like so: >> >> *snip*/vendor/plugins/rspec/lib/spec/runner/reporter.rb:37:in >> `description'': wrong number of arguments (0 for 2) (ArgumentError) >> >> It just so happens that my description method takes 2 arguments. >> It seems >> that this method is clashing with one of the methods in rspec. Is >> there a >> workaround for this situation? It''s a pain to have to rename my >> method >> everytime I want to see a proper failure message from rspec. >> >> I''m attaching a full backtrace run with --trace. > > If the first argument to describe() is a module it gets included in > the resulting example group. To avoid this, just make it a String: > > describe ''MyHelperModule'' do > ... > end > > In the next release there is a helper object you can use in your > helper examples: > > describe HelperModule do > it "should describe something by default" do > helper.description.should == "something" > end > end > > In some future release, that is the only way it will work as we will > no longer include the module in the example group. That might be a way > off though. > > Cheers, > David > >> >> Thanks, >> >> e. >> -- >> ericw at xmtp.net >> >> "If the answer isn''t violence, neither is your silence!" >> -- Pop Will Eat Itself, "Ich Bin Ein Auslander" >> >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users-- ericw at xmtp.net "If the answer isn''t violence, neither is your silence!" -- Pop Will Eat Itself, "Ich Bin Ein Auslander"