vendor/rails/actionpack/test/controller/assert_select_test.rb in radiant-0.6.9 vs vendor/rails/actionpack/test/controller/assert_select_test.rb in radiant-0.7.0
- old
+ new
@@ -1,12 +1,12 @@
#--
# Copyright (c) 2006 Assaf Arkin (http://labnotes.org)
# Under MIT and/or CC By license.
#++
-require "#{File.dirname(__FILE__)}/../abstract_unit"
-require "#{File.dirname(__FILE__)}/fake_controllers"
+require 'abstract_unit'
+require 'controller/fake_controllers'
unless defined?(ActionMailer)
begin
$:.unshift(File.dirname(__FILE__) + "/../../../actionmailer/lib")
@@ -343,14 +343,21 @@
# Test that non-ascii characters (which are converted into \uXXXX in RJS) are decoded correctly.
render_rjs do |page|
page.replace "test", "<div id=\"1\">\343\203\201\343\202\261\343\203\203\343\203\210</div>"
end
assert_select_rjs do
- assert_select "#1", :text => "\343\203\201\343\202\261\343\203\203\343\203\210"
- assert_select "#1", "\343\203\201\343\202\261\343\203\203\343\203\210"
- assert_select "#1", Regexp.new("\343\203\201..\343\203\210",0,'U')
- assert_raises(AssertionFailedError) { assert_select "#1", Regexp.new("\343\203\201.\343\203\210",0,'U') }
+ str = "#1"
+ assert_select str, :text => "\343\203\201\343\202\261\343\203\203\343\203\210"
+ assert_select str, "\343\203\201\343\202\261\343\203\203\343\203\210"
+ if str.respond_to?(:force_encoding)
+ str.force_encoding(Encoding::UTF_8)
+ assert_select str, /\343\203\201..\343\203\210/u
+ assert_raises(AssertionFailedError) { assert_select str, /\343\203\201.\343\203\210/u }
+ else
+ assert_select str, Regexp.new("\343\203\201..\343\203\210",0,'U')
+ assert_raises(AssertionFailedError) { assert_select str, Regexp.new("\343\203\201.\343\203\210",0,'U') }
+ end
end
end
def test_assert_select_rjs_with_id
# Test that we can pick up all statements in the result.
@@ -559,10 +566,15 @@
end
assert_select_rjs :insert_html do
assert_select "div", 4
end
end
-
+
+ def test_assert_select_rjs_raise_errors
+ assert_raises(ArgumentError) { assert_select_rjs(:destroy) }
+ assert_raises(ArgumentError) { assert_select_rjs(:insert, :left) }
+ end
+
# Simple selection from a single result.
def test_nested_assert_select_rjs_with_single_result
render_rjs do |page|
page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
end