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)
end
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”)
end
end
end
describe ApplicationController do
describe “andreplace(str)” do
it “should format ands for ferret search” do
andreplace(“foo and bar”).should eql(“+foo +bar”)
Try this:
controller.andreplace(“foo and bar”).should eql(“+foo +bar”)
How do you spec protected controller methods such as before_filters
and
helpers that with the params and session hashes?
I cannot call controller.my_method if my_method is protected.
Try this:
controller.andreplace(“foo and bar”).should eql("+foo +bar")
Hey Fernando. As Mark said, the idea behind BDD is to spec the
behaviour of your controller, rather than each specific method. So
write specs for all of the different behaviours that your controller
can exhibit. This will result in your protected and private methods
being called.