I use the latest oauth-plugin with Rails 3.1. I want to test my OAuth2 API controllers with rspec tests. After trying a bunch of things to authorize my request I simply want to stub the oauthenticate filter to get rid of any authentication issues. But I still get a 401 Unauthorized . Why??
users_controller.rb:
class UsersController
oauthenticate
def update
<do something>
end
end
users_controller_spec.rb:
describe UsersController do
describe "POST 'update'" do
before :each do
controller.stub!(:oauthenticate).and_return true
end
it "should be a successful request" do
post :update, { "user_id" => "some id" }
response.should be_ok
end
end
Expected ActionController::TestResponse to have a response code of 200, but got 401.
Rspec testing for oauth provider doesn't help. With cucumber test everything works fine when setting a valid access token Authorization header.