Created
February 21, 2012 20:48
-
-
Save robertsosinski/1878824 to your computer and use it in GitHub Desktop.
Test controller mixins in isolation (http://pivotallabs.com/users/jdean/blog/articles/1370-adding-routes-for-tests-specs-with-rails-3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe Api::V9::Authenticatable, :type => :controller do | |
before do | |
class EndpointsController < ActionController::Base | |
include Api::V9::Authenticatable | |
def index | |
render :text => 'foo' | |
end | |
end | |
@controller = EndpointsController.new | |
Rails.application.routes.draw do | |
match '/endpoint' =>'endpoints#index' | |
end | |
end | |
after do | |
# be sure to reload routes after the tests run, otherwise all your other controller specs will fail | |
Rails.application.reload_routes! | |
end | |
it 'should a valid request' do | |
get :index | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great! 💯