Search code examples
ruby-on-railsrubyruby-on-rails-3rspecrspec-rails

Rspec Ruby on Rails controller question


I'm currently using ruby 1.9.2 and rails 3 and I'm in the middle of rspec testing. Basically, I have a function that is called by a before filter in the application controller such that it obviously gets run every time a controller action is made anywhere on my site. For testing purposes, I'm writing tests for a different controller but my actions do not set off my before filter function call. Is there any way to specifically call functions from a specific controller within rspec tests? I can't post the code online, so no use asking for it :P.
Thanks


Solution

  • Inside an it or before(:each) block in a controller spec:

    controller.send( :your_method_name )
    

    And your function is going to be called.