Browse files

Random hits from the style nazi

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7437 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 46f217b commit 2c690edb940b55366bc479fc7e51fc620fd85d5b @dhh dhh committed Sep 9, 2007
View
8 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
View
2 actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -138,4 +138,4 @@ def parameterize(value)
end
end
end
-end
+end
View
9 actionpack/lib/action_controller/assertions/selector_assertions.rb
@@ -66,6 +66,7 @@ def css_select(*args)
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 @@ def assert_select_rjs(*args, &block)
# 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 @@ def assert_select_rjs(*args, &block)
""
end
end
+
if matches
if block_given? && !([:remove, :show, :hide, :toggle].include? rjs_type)
begin
@@ -563,9 +566,11 @@ def assert_select_email(&block)
# 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 @@ def response_from_page_or_rjs()
end
break
end
+
root
else
html_document.root
@@ -592,7 +598,6 @@ def unescape_rjs(rjs_string)
unescaped.gsub!(RJS_PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')}
unescaped
end
-
end
end
-end
+end
View
2 actionpack/lib/action_controller/assertions/tag_assertions.rb
@@ -114,4 +114,4 @@ def assert_no_tag(*opts)
end
end
end
-end
+end

0 comments on commit 2c690ed

Please sign in to comment.