public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Improve assert_select_rjs failure messages for show, hide, toggle, and remove

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#931 state:committed]
timhaines (author)
Fri Aug 29 03:09:51 -0700 2008
NZKoz (committer)
Fri Aug 29 11:51:47 -0700 2008
commit  d0b949d87375ae351757adffd192d8cb1f3dbf8d
tree    4c485a7daf4e3274e428407a53d14d2eabddeb14
parent  a200c67611ed3bb2d276a9a1d1eb67b5c926f22a
...
472
473
474
475
 
 
 
 
 
 
 
476
477
478
...
472
473
474
 
475
476
477
478
479
480
481
482
483
484
0
@@ -472,7 +472,13 @@ module ActionController
0
           matches
0
         else
0
           # RJS statement not found.
0
-          flunk args.shift || "No RJS statement that replaces or inserts HTML content."
0
+          case rjs_type
0
+            when :remove, :show, :hide, :toggle
0
+              flunk_message = "No RJS statement that #{rjs_type.to_s}s '#{id}' was rendered."
0
+            else
0
+              flunk_message = "No RJS statement that replaces or inserts HTML content."
0
+          end
0
+          flunk args.shift || flunk_message
0
         end
0
       end
0
 
...
433
434
435
 
 
 
 
 
 
 
 
 
 
 
436
437
438
...
454
455
456
 
 
 
 
 
 
 
 
 
 
 
457
458
459
...
475
476
477
 
 
 
 
 
 
 
 
 
 
 
478
479
480
...
496
497
498
 
 
 
 
 
 
 
 
 
 
 
499
500
501
...
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
...
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
...
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
...
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
0
@@ -433,6 +433,17 @@ class AssertSelectTest < Test::Unit::TestCase
0
     assert_select_rjs :remove, "test1"
0
   end
0
 
0
+  def test_assert_select_rjs_for_remove_offers_useful_error_when_assertion_fails
0
+    render_rjs do |page|
0
+      page.remove "test_with_typo"
0
+    end
0
+
0
+    assert_select_rjs :remove, "test1"
0
+
0
+    rescue Test::Unit::AssertionFailedError
0
+      assert_equal "No RJS statement that removes 'test1' was rendered.", $!.message
0
+  end
0
+
0
   def test_assert_select_rjs_for_remove_ignores_block
0
     render_rjs do |page|
0
       page.remove "test1"
0
@@ -454,6 +465,17 @@ class AssertSelectTest < Test::Unit::TestCase
0
     assert_select_rjs :show, "test1"
0
   end
0
 
0
+  def test_assert_select_rjs_for_show_offers_useful_error_when_assertion_fails
0
+    render_rjs do |page|
0
+      page.show "test_with_typo"
0
+    end
0
+
0
+    assert_select_rjs :show, "test1"
0
+
0
+    rescue Test::Unit::AssertionFailedError
0
+      assert_equal "No RJS statement that shows 'test1' was rendered.", $!.message
0
+  end
0
+
0
   def test_assert_select_rjs_for_show_ignores_block
0
     render_rjs do |page|
0
       page.show "test1"
0
@@ -475,6 +497,17 @@ class AssertSelectTest < Test::Unit::TestCase
0
     assert_select_rjs :hide, "test1"
0
   end
0
 
0
+  def test_assert_select_rjs_for_hide_offers_useful_error_when_assertion_fails
0
+    render_rjs do |page|
0
+      page.hide "test_with_typo"
0
+    end
0
+
0
+    assert_select_rjs :hide, "test1"
0
+
0
+    rescue Test::Unit::AssertionFailedError
0
+      assert_equal "No RJS statement that hides 'test1' was rendered.", $!.message
0
+  end
0
+
0
   def test_assert_select_rjs_for_hide_ignores_block
0
     render_rjs do |page|
0
       page.hide "test1"
0
@@ -496,6 +529,17 @@ class AssertSelectTest < Test::Unit::TestCase
0
     assert_select_rjs :toggle, "test1"
0
   end
0
 
0
+  def test_assert_select_rjs_for_toggle_offers_useful_error_when_assertion_fails
0
+    render_rjs do |page|
0
+      page.toggle "test_with_typo"
0
+    end
0
+
0
+    assert_select_rjs :toggle, "test1"
0
+
0
+    rescue Test::Unit::AssertionFailedError
0
+      assert_equal "No RJS statement that toggles 'test1' was rendered.", $!.message
0
+  end
0
+
0
   def test_assert_select_rjs_for_toggle_ignores_block
0
     render_rjs do |page|
0
       page.toggle "test1"

Comments