[rspec-users] Testing misc methods in ApplicationController
dchelimsky at gmail.com
Fri Feb 22 08:46:15 EST 2008
On Fri, Feb 22, 2008 at 7:26 AM, Max Williams
<toastkid.williams at gmail.com> wrote:
> I'm already successfully testing before_filters in application_controller
> courtesy of this blog post:
> However, i can;'t work out how to test the sort of method that is added to
> application_controller so that all controllers can use it. It must be
> something simple that i'm doing wrong/omitting, can anyone help?
> eg if i have this empty method in application_controller
> def andreplace(str)
> and my spec looks like this:
> describe ApplicationController do
> describe "andreplace(str)" do
> it "should format ands for ferret search" do
> andreplace("foo and bar").should eql("+foo +bar")
controller.andreplace("foo and bar").should eql("+foo +bar")
> Currently, the test breaks, saying:
> NoMethodError in 'ApplicationController andreplace(str) should format ands
> for ferret search'
> undefined method `andreplace' for
This is a pointer to the problem - the error is telling you that the
#andreplace message is going to the ExampleGroup, not the controller.
> What's going wrong here, anyone know?
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users