Skip to content

Commit

Permalink
Refactor image_asserter.
Browse files Browse the repository at this point in the history
  • Loading branch information
giginet committed Sep 7, 2013
1 parent e687e99 commit ae6660f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion image_asserter
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end
assertion_result = ImageAssertion.assert_image(File.expand_path(test_output),
File.expand_path(ref_images_path),
image_name,
threshold)
threshold)
exit FAILED_EXIT_STATUS unless assertion_result

exit SUCCESS_EXIT_STATUS
Expand Down
5 changes: 3 additions & 2 deletions image_assertion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ def self.process_imagemagick_result(image_file_name, stderr, threshold)

#imagemagick outputs floating point metrics value when succeeds
compare_succeed = ( stderr.match(/[0-9]*\.?[0-9]+/).length > 0 )
threshold ||= MAX_ALLOWED_DIFF_VALUE

if compare_succeed
if (threshold.nil? && stderr.to_f < MAX_ALLOWED_DIFF_VALUE) || (!threshold.nil? && stderr.to_f < threshold.to_f)
if stderr.to_f < threshold

result_status = 'passed'
result_message = "#{image_file_name} asserted successfully."
assertionResult = true
else
print_status(create_status(result_status, "expected diff is smaller than #{threshold.nil? ? MAX_ALLOWED_DIFF_VALUE : threshold} but #{stderr.to_f}."))
print_status(create_status(result_status, "expected diff is smaller than #{threshold} but #{stderr.to_f}."))
end
else

Expand Down

0 comments on commit ae6660f

Please sign in to comment.