0

I have a peculiar situation - an rspec file fails when run independently, but run okay when run as part of the entire suite.

Failure/Error: visit oauth_callback_path
     NoMethodError:
       undefined method `action' for MyController:Class
     # <internal:prelude>:10:in `synchronize'
     # ./spec/requests/login_spec.rb:xx:in `block (5 levels) in <top (required)>'
     # ./spec/requests/login_spec.rb:xx:in `block (4 levels) in <top (required)>'

Simplified spec:

require 'spec_helper'

class MyController
  def oauth_response
    sign_in(
        ENV['TEST_ACCESS_TOKEN'],
        ENV['TEST_ACCESS_SECRET'])
    redirect_to root_path
  end
end


describe 'logging in' do
  it 'login' do
    visit oauth_callback_path
    response.should be_success
  end
end
2
  • What does your route for oauth_callback_path look like? Commented May 26, 2011 at 15:28
  • basic match 'oauth_callback' => 'my#oauth_response' Commented May 26, 2011 at 15:52

2 Answers 2

2

I believe the problem is that MyController is not extending ApplicationController. That's why the method action is not defined for MyController.

Sign up to request clarification or add additional context in comments.

Comments

0

The class MyController appears to be blocking Rails magic class loading. Either the test should explicitly require the controller, or the extension should be defined with MyController.class_eval

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.