Skip to content

Commit

Permalink
Minor refactoring for code clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Anderson committed Jan 4, 2009
1 parent 894cd7c commit 1b4fad8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/matchers/table_body_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def negative_failure_message

def extract_html_content html
doc = Hpricot.XML(html)
elements = doc.search("table#{"##{@table_id}" if @table_id} tr").select{|e| ! e.search('td').empty? }
elements = doc.search("table#{"##{@table_id}" if @table_id} tr").reject{|e| e.search('td').empty? }
elements.map{|n| n.search('/td').map{|n| n.inner_text.strip.gsub(/\n \t\t/, "\n")}}
end

end
end
end
end
end
4 changes: 2 additions & 2 deletions lib/matchers/table_header_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def negative_failure_message

def extract_html_content html
doc = Hpricot.XML(html)
elements = doc.search("table#{"##{@table_id}" if @table_id} tr").select{|e| ! e.search('th').empty? }
elements = doc.search("table#{"##{@table_id}" if @table_id} tr").reject{|e| e.search('th').empty? }
elements.map{|n| n.search('/th').map{|n| n.inner_text.strip.gsub(/\n \t\t/, "\n")}}
end

end
end
end
end
end
4 changes: 2 additions & 2 deletions lib/matchers/table_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def extract_html_content html
doc = Hpricot.XML(html)

rows = doc.search("table#{"##{@table_id}" if @table_id} tr")
header_elements = rows.select{|e| ! e.search('th').empty? }
header_elements = rows.reject{|e| e.search('th').empty? }
header_content = header_elements.map{|n| n.search('/th').map{|n| n.inner_text.strip.gsub(/\n \t\t/, "\n")}}

body_elements = rows.select{|e| ! e.search('td').empty? }
body_elements = rows.reject{|e| e.search('td').empty? }
body_content = body_elements.map{|n| n.search('/td').map{|n| n.inner_text.strip.gsub(/\n \t\t/, "\n")}}

header_content + body_content
Expand Down

0 comments on commit 1b4fad8

Please sign in to comment.