From 2c690edb940b55366bc479fc7e51fc620fd85d5b Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 9 Sep 2007 23:03:32 +0000 Subject: Random hits from the style nazi git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7437 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/assertions/dom_assertions.rb | 8 +++++--- .../lib/action_controller/assertions/response_assertions.rb | 2 +- .../lib/action_controller/assertions/selector_assertions.rb | 9 +++++++-- actionpack/lib/action_controller/assertions/tag_assertions.rb | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_controller/assertions/dom_assertions.rb b/actionpack/lib/action_controller/assertions/dom_assertions.rb index 355080fe54..0b8c78d9b3 100644 --- a/actionpack/lib/action_controller/assertions/dom_assertions.rb +++ b/actionpack/lib/action_controller/assertions/dom_assertions.rb @@ -2,21 +2,23 @@ module ActionController module Assertions module DomAssertions # Test two HTML strings for equivalency (e.g., identical up to reordering of attributes) - def assert_dom_equal(expected, actual, message="") + def assert_dom_equal(expected, actual, message = "") clean_backtrace do expected_dom = HTML::Document.new(expected).root - actual_dom = HTML::Document.new(actual).root + actual_dom = HTML::Document.new(actual).root full_message = build_message(message, " expected to be == to\n.", expected_dom.to_s, actual_dom.to_s) + assert_block(full_message) { expected_dom == actual_dom } end end # The negated form of +assert_dom_equivalent+. - def assert_dom_not_equal(expected, actual, message="") + def assert_dom_not_equal(expected, actual, message = "") clean_backtrace do expected_dom = HTML::Document.new(expected).root actual_dom = HTML::Document.new(actual).root full_message = build_message(message, " expected to be != to\n.", expected_dom.to_s, actual_dom.to_s) + assert_block(full_message) { expected_dom != actual_dom } end end diff --git a/actionpack/lib/action_controller/assertions/response_assertions.rb b/actionpack/lib/action_controller/assertions/response_assertions.rb index de7efd0ac9..f45727f508 100644 --- a/actionpack/lib/action_controller/assertions/response_assertions.rb +++ b/actionpack/lib/action_controller/assertions/response_assertions.rb @@ -138,4 +138,4 @@ module ActionController end end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/assertions/selector_assertions.rb b/actionpack/lib/action_controller/assertions/selector_assertions.rb index 05ca2bff15..7e9692be3f 100644 --- a/actionpack/lib/action_controller/assertions/selector_assertions.rb +++ b/actionpack/lib/action_controller/assertions/selector_assertions.rb @@ -66,6 +66,7 @@ module ActionController raise ArgumentError, "First argument is either selector or element to select, but nil found. Perhaps you called assert_select with an element that does not exist?" elsif @selected matches = [] + @selected.each do |selected| subset = css_select(selected, HTML::Selector.new(arg.dup, args.dup)) subset.each do |match| @@ -387,6 +388,7 @@ module ActionController # any RJS statement. if arg.is_a?(Symbol) rjs_type = arg + if rjs_type == :insert arg = args.shift insertion = "insert_#{arg}".to_sym @@ -433,6 +435,7 @@ module ActionController "" end end + if matches if block_given? && !([:remove, :show, :hide, :toggle].include? rjs_type) begin @@ -563,9 +566,11 @@ module ActionController # page, or from all the RJS statements, depending on the type of response. def response_from_page_or_rjs() content_type = @response.content_type + if content_type && content_type =~ /text\/javascript/ body = @response.body.dup root = HTML::Node.new(nil) + while true next if body.sub!(RJS_PATTERN_EVERYTHING) do |match| html = unescape_rjs($3) @@ -575,6 +580,7 @@ module ActionController end break end + root else html_document.root @@ -592,7 +598,6 @@ module ActionController unescaped.gsub!(RJS_PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')} unescaped end - end end -end +end \ No newline at end of file diff --git a/actionpack/lib/action_controller/assertions/tag_assertions.rb b/actionpack/lib/action_controller/assertions/tag_assertions.rb index df8e812b3c..d911d81174 100644 --- a/actionpack/lib/action_controller/assertions/tag_assertions.rb +++ b/actionpack/lib/action_controller/assertions/tag_assertions.rb @@ -114,4 +114,4 @@ module ActionController end end end -end +end \ No newline at end of file -- cgit v1.2.3