Skip to content

Commit

Permalink
only display error message for top level of format error
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed May 20, 2010
1 parent a761d7e commit bc93512
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def has_error(error, &block)
end
end

def has_format(original_data, original_format)
def has_format(original_data, original_format, original = true)
valid = true
data = original_data.dup
format = original_format.dup
Expand All @@ -29,20 +29,20 @@ def has_format(original_data, original_format)
for element in datum
type = value.first
if type.is_a?(Hash)
valid &&= has_format({:element => element}, {:element => type})
valid &&= has_format({:element => element}, {:element => type}, false)
else
valid &&= element.is_a?(type)
end
end
when Hash
valid &&= datum.is_a?(Hash)
valid &&= has_format(datum, value)
valid &&= has_format(datum, value, false)
else
valid &&= datum.is_a?(value)
end
end
valid &&= data.empty? && format.empty?
unless valid
if !valid && original
@formatador.display_line("[red]#{original_data.inspect} does not match #{original_format.inspect}[/]")
end
valid
Expand Down

0 comments on commit bc93512

Please sign in to comment.