mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04:00
Improve assert_select_rjs failure messages for show, hide, toggle, and remove
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#931 state:committed]
This commit is contained in:
committed by
Michael Koziarski
parent
a200c67611
commit
d0b949d873
@@ -472,7 +472,13 @@ module ActionController
|
||||
matches
|
||||
else
|
||||
# RJS statement not found.
|
||||
flunk args.shift || "No RJS statement that replaces or inserts HTML content."
|
||||
case rjs_type
|
||||
when :remove, :show, :hide, :toggle
|
||||
flunk_message = "No RJS statement that #{rjs_type.to_s}s '#{id}' was rendered."
|
||||
else
|
||||
flunk_message = "No RJS statement that replaces or inserts HTML content."
|
||||
end
|
||||
flunk args.shift || flunk_message
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -433,6 +433,17 @@ class AssertSelectTest < Test::Unit::TestCase
|
||||
assert_select_rjs :remove, "test1"
|
||||
end
|
||||
|
||||
def test_assert_select_rjs_for_remove_offers_useful_error_when_assertion_fails
|
||||
render_rjs do |page|
|
||||
page.remove "test_with_typo"
|
||||
end
|
||||
|
||||
assert_select_rjs :remove, "test1"
|
||||
|
||||
rescue Test::Unit::AssertionFailedError
|
||||
assert_equal "No RJS statement that removes 'test1' was rendered.", $!.message
|
||||
end
|
||||
|
||||
def test_assert_select_rjs_for_remove_ignores_block
|
||||
render_rjs do |page|
|
||||
page.remove "test1"
|
||||
@@ -454,6 +465,17 @@ class AssertSelectTest < Test::Unit::TestCase
|
||||
assert_select_rjs :show, "test1"
|
||||
end
|
||||
|
||||
def test_assert_select_rjs_for_show_offers_useful_error_when_assertion_fails
|
||||
render_rjs do |page|
|
||||
page.show "test_with_typo"
|
||||
end
|
||||
|
||||
assert_select_rjs :show, "test1"
|
||||
|
||||
rescue Test::Unit::AssertionFailedError
|
||||
assert_equal "No RJS statement that shows 'test1' was rendered.", $!.message
|
||||
end
|
||||
|
||||
def test_assert_select_rjs_for_show_ignores_block
|
||||
render_rjs do |page|
|
||||
page.show "test1"
|
||||
@@ -475,6 +497,17 @@ class AssertSelectTest < Test::Unit::TestCase
|
||||
assert_select_rjs :hide, "test1"
|
||||
end
|
||||
|
||||
def test_assert_select_rjs_for_hide_offers_useful_error_when_assertion_fails
|
||||
render_rjs do |page|
|
||||
page.hide "test_with_typo"
|
||||
end
|
||||
|
||||
assert_select_rjs :hide, "test1"
|
||||
|
||||
rescue Test::Unit::AssertionFailedError
|
||||
assert_equal "No RJS statement that hides 'test1' was rendered.", $!.message
|
||||
end
|
||||
|
||||
def test_assert_select_rjs_for_hide_ignores_block
|
||||
render_rjs do |page|
|
||||
page.hide "test1"
|
||||
@@ -496,6 +529,17 @@ class AssertSelectTest < Test::Unit::TestCase
|
||||
assert_select_rjs :toggle, "test1"
|
||||
end
|
||||
|
||||
def test_assert_select_rjs_for_toggle_offers_useful_error_when_assertion_fails
|
||||
render_rjs do |page|
|
||||
page.toggle "test_with_typo"
|
||||
end
|
||||
|
||||
assert_select_rjs :toggle, "test1"
|
||||
|
||||
rescue Test::Unit::AssertionFailedError
|
||||
assert_equal "No RJS statement that toggles 'test1' was rendered.", $!.message
|
||||
end
|
||||
|
||||
def test_assert_select_rjs_for_toggle_ignores_block
|
||||
render_rjs do |page|
|
||||
page.toggle "test1"
|
||||
|
||||
Reference in New Issue
Block a user