module Minimalizer::ControllerTestHelpers
Private Instance Methods
assert_flash(variant, key)
click to toggle source
Assert that the flash variant (e.g. :notice) is equal to the local translation for the given key.
# File lib/minimalizer/controller_test_helpers.rb, line 30 def assert_flash(variant, key) assert_equal I18n.t(key, scope: local_translation_scope), flash[variant] end
assert_redirect(location, status: 302, alert: nil, notice: nil)
click to toggle source
Assert the correct redirect location is given; optionally test the response status and flash messages.
# File lib/minimalizer/controller_test_helpers.rb, line 12 def assert_redirect(location, status: 302, alert: nil, notice: nil) assert_redirected_to location assert_response status assert_flash :alert, alert if alert assert_flash :notice, notice if notice end
assert_render(template, status: 200, alert: nil, notice: nil)
click to toggle source
Assert the correct template is rendered; optionally test the response status and flash messages.
# File lib/minimalizer/controller_test_helpers.rb, line 21 def assert_render(template, status: 200, alert: nil, notice: nil) assert_template template assert_response status assert_flash :alert, alert if alert assert_flash :notice, notice if notice end
local_translation_scope()
click to toggle source
Local translation scope for the current controller and action.
# File lib/minimalizer/controller_test_helpers.rb, line 35 def local_translation_scope [@controller.controller_path.split('/'), @controller.action_name].flatten.compact.join('.') end