doh...dammit, i thought i'd tried that. I'm losing it...<br><br>thanks!<br><br><div><span class="gmail_quote">On 22/02/2008, <b class="gmail_sendername">David Chelimsky</b> <<a href="mailto:dchelimsky@gmail.com">dchelimsky@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Fri, Feb 22, 2008 at 7:26 AM, Max Williams<br> <<a href="mailto:toastkid.williams@gmail.com">toastkid.williams@gmail.com</a>> wrote:<br> > I'm already successfully testing before_filters in application_controller<br>
> courtesy of this blog post:<br> > <a href="http://www.movesonrails.com/articles/2008/01/23/spec-ing-your-application-controller">http://www.movesonrails.com/articles/2008/01/23/spec-ing-your-application-controller</a><br>
><br> > However, i can;'t work out how to test the sort of method that is added to<br> > application_controller so that all controllers can use it. It must be<br> > something simple that i'm doing wrong/omitting, can anyone help?<br>
><br> > eg if i have this empty method in application_controller<br> ><br> > def andreplace(str)<br> > end<br> ><br> > and my spec looks like this:<br> ><br> > describe ApplicationController do<br>
> describe "andreplace(str)" do<br> > it "should format ands for ferret search" do<br> > andreplace("foo and bar").should eql("+foo +bar")<br> <br> <br>Try this:<br>
<br> controller.andreplace("foo and bar").should eql("+foo +bar")<br> <br><br> > end<br> > end<br> > end<br> ><br> > Currently, the test breaks, saying:<br> > NoMethodError in 'ApplicationController andreplace(str) should format ands<br>
> for ferret search'<br> > undefined method `andreplace' for<br> > #<Spec::Rails::Example::ControllerExampleGroup::Subclass_1::Subclass_1:0xb64f7160><br> <br> <br>This is a pointer to the problem - the error is telling you that the<br>
#andreplace message is going to the ExampleGroup, not the controller.<br> <br> HTH,<br> David<br> <br><br> ><br> ><br> > What's going wrong here, anyone know?<br> ><br> ><br> <br>> _______________________________________________<br>
> rspec-users mailing list<br> > <a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br> > <a href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a><br>
><br> _______________________________________________<br> rspec-users mailing list<br> <a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br> <a href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a><br>
</blockquote></div><br>