Class: BaseControllerTest

Inherits:
Minitest::Test
  • Object
show all
Includes:
Rack::Test::Methods
Defined in:
lib/tests/controllers/base_controller_test.rb

Instance Method Summary collapse

Instance Method Details

#appObject



28
29
30
# File 'lib/tests/controllers/base_controller_test.rb', line 28

def app
  Rubee::Application.instance
end

#setupObject



32
33
34
35
36
37
38
# File 'lib/tests/controllers/base_controller_test.rb', line 32

def setup
  Rubee::Router.draw do |route|
    route.get('/test', to: 'test_redirect#test')
    route.get('/index', to: 'test_redirect#index')
    route.get('/test_me', to: 'test_redirect#test_me')
  end
end

#test_hijacked_test_by_aroundObject



62
63
64
65
66
67
# File 'lib/tests/controllers/base_controller_test.rb', line 62

def test_hijacked_test_by_around
  get('/test_me')

  assert_equal(200, last_response.status)
  assert_equal({ "hijacked" => "yes" }, JSON.parse(last_response.body))
end

#test_redirectObject



54
55
56
57
58
59
60
# File 'lib/tests/controllers/base_controller_test.rb', line 54

def test_redirect
  get('/index')

  assert_equal(302, last_response.status)
  assert_equal('/test', last_response.headers['Location'])
  assert_equal('', last_response.body)
end

#test_retrieve_imageObject



40
41
42
43
44
45
# File 'lib/tests/controllers/base_controller_test.rb', line 40

def test_retrieve_image
  get('/images/rubee.svg')

  assert_equal(200, last_response.status, "Unexpected response: #{last_response.body}")
  refute_equal('Image not found', last_response.body, "Unexpected response: #{last_response.body}")
end

#test_retrieve_non_existant_imageObject



47
48
49
50
51
52
# File 'lib/tests/controllers/base_controller_test.rb', line 47

def test_retrieve_non_existant_image
  get('/images/rubee2.svg')

  assert_equal(200, last_response.status, "Unexpected response: #{last_response.body}")
  assert_equal('Image not found', last_response.body, "Unexpected response: #{last_response.body}")
end