blob: 47e44ce084389eca2ff941c58c72eabe4f0531b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
require 'test_helper'
class ErrorHandlingTest < ActionController::TestCase
tests HomeController
def setup
HomeController.any_instance.stubs(:index).raises
end
def test_json_error
get :index, format: :json
assert_equal 'application/json', @response.content_type
assert json = JSON.parse(@response.body)
assert_equal ['error'], json.keys
end
def test_html_error_reraises
assert_raises RuntimeError do
get :index
end
end
end
|