Skip to content

Instantly share code, notes, and snippets.

@senny
Created January 6, 2014 13:46
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 senny/8283076 to your computer and use it in GitHub Desktop.
Save senny/8283076 to your computer and use it in GitHub Desktop.
class UsersController < ApplicationController
def show
raise ActiveRecord::RecordNotFound
end
end
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
test "exception behavior" do
get :show, id: 1
end
end
require 'test_helper'
class RootTest < ActionDispatch::IntegrationTest
test "exception behavior" do
get "/users/1"
end
end
@senny
Copy link
Author

senny commented Jan 6, 2014

Functional

rails_master » ruby -Itest test/controllers/users_controller_test.rb
Run options: --seed 29368

# Running:

E

Finished in 0.022488s, 44.4682 runs/s, 0.0000 assertions/s.

  1) Error:
UsersControllerTest#test_exception_behavior:
ActiveRecord::RecordNotFound: ActiveRecord::RecordNotFound
    app/controllers/users_controller.rb:3:in `show'
    test/controllers/users_controller_test.rb:5:in `block in <class:UsersControllerTest>'

1 runs, 0 assertions, 0 failures, 1 errors, 0 skips

Integration

rails_master » ruby -Itest test/integration/root_test.rb
Run options: --seed 24369

# Running:

E

Finished in 0.050185s, 19.9263 runs/s, 0.0000 assertions/s.

  1) Error:
RootTest#test_exception_behavior:
ActiveRecord::RecordNotFound: ActiveRecord::RecordNotFound
    app/controllers/users_controller.rb:3:in `show'
    test/integration/root_test.rb:5:in `block in <class:RootTest>'

1 runs, 0 assertions, 0 failures, 1 errors, 0 skips

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment