aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/mime/responders_test.rb
blob: 032b4c0ab1cf29abef4147a16d3b9e876a161220 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'abstract_unit'
require 'controller/fake_models'

class ResponderTest < ActionController::TestCase
  def test_class_level_respond_to
    e = assert_raises(NoMethodError) do
      Class.new(ActionController::Base) do
        respond_to :json
      end
    end

    assert_includes e.message, '`responders` gem'
    assert_includes e.message, '~> 2.0'
  end

  def test_respond_with
    klass = Class.new(ActionController::Base) do
      def index
        respond_with Customer.new("david", 13)
      end
    end

    @controller = klass.new

    e = assert_raises(NoMethodError) do
      get :index
    end

    assert_includes e.message, '`responders` gem'
    assert_includes e.message, '~> 2.0'
  end
end