How to get a handle/reference to the current controller object inside a rails functional test?
- by Dave Paroulek
I must be missing something very simple, but can't find the answer to this. I have a method named foo inside bar_controller. I simply want to call that method from inside a functional test.
Here's my controller:
class BarsController < ApplicationController
def foo
# does stuff
end
end
Here's my functional test:
class BarsControllerTest << ActionController::TestCase
def "test foo" do
# run foo
foo
# assert stuff
end
end
When I run the test I get:
NameError: undefined local variable or method `foo' for #<BarsControllerTest:0x102f2eab0>
All the documentation on functional tests describe how to simulate a http get request to the bar_controller which then runs the method. But I'd just like to run the method without hitting it with an http get or post request. Is that possible?
There must be a reference to the controller object inside the functional test, but I'm still learning ruby and rails so need some help.