Skip to content

Instantly share code, notes, and snippets.

@roydq
Created January 4, 2013 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roydq/4449997 to your computer and use it in GitHub Desktop.
Save roydq/4449997 to your computer and use it in GitHub Desktop.
ApplicationController test example
class ApplicationController < ActionController::Base
def something
'derp'
end
end
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