mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Random hits from the style nazi
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7437 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
46f217b298
commit
2c690edb94
4 changed files with 14 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -138,4 +138,4 @@ module ActionController
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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
|
|
@ -114,4 +114,4 @@ module ActionController
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue