Created
January 4, 2013 04:45
-
-
Save roydq/4449997 to your computer and use it in GitHub Desktop.
ApplicationController test example
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
class ApplicationController < ActionController::Base | |
def something | |
'derp' | |
end | |
end |
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 'minitest_helper' | |
class TestableApplicationController < ApplicationController | |
def test_something | |
@something = something | |
render :nothing => true | |
end | |
end | |
class TestableApplicationControllerTest < MiniTest::Rails::ActionController::TestCase | |
before do | |
MyApp::Application.routes.draw do | |
match 'test_something' => "testable_application#test_something" | |
end | |
end | |
after do | |
MyApp::Application.reload_routes! | |
end | |
test 'something should return derp' do | |
get :test_something | |
assert_response :success | |
assert_equal 'derp', assigns(:something) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment