Reputation: 3905
I have a controller which has some special authentication as it is really an API available to a specific remote system.
In RSpec (2.7), I want to bypass that authentication, but I can't seem to get it working. From what I read, I should be doing something like this:
controller.stub!(:restrict_soa_access).and_return(true)
But if I do that, I just get:
spec/controllers/soa/user_controller_spec.rb:42: undefined method `stub!'
for #<RSpec::Core::Hooks::AfterHooks:0xb673a8dc> (NoMethodError)
In response to the comments, I have also tried using Soa::UserController.stub!
which gives an identical error, and also @controller.stub!
, when I get undefined method for nil:NilClass.
I'm not stubbing any other stuff. Is there something I need to do to enable stubbing or is my stub code just wrong?
Upvotes: 4
Views: 5900
Reputation: 6354
i had a similar problem, solved it with following requires:
require 'rspec/mocks'
require 'rspec/mocks/spec_methods'
require 'rspec/mocks/standalone'
could you report back if that works for you?
Upvotes: 3