Sha256: cf14c84b04031c9254ecf61091d3608780753cdfa595488d1ff5c65964df21aa
Contents?: true
Size: 841 Bytes
Versions: 1
Compression:
Stored size: 841 Bytes
Contents
require 'looks_good' RSpec::Matchers.define :look_like do |expected, within: LooksGood::Configuration.default_within| result = nil match do |actual| if expected.is_a?(Symbol) called_by_file = self.caller.find{|str| str.include?("_spec.rb")} path_to = called_by_file.split("_spec.rb").first.split("spec/").last expected = File.join(path_to, "#{expected}.png") end result = LooksGood.check(expected, actual, within: within) result[:result] end failure_message do |actual| actual_amount = result[:percent_difference] * 100 expected_amount = result[:comparison].within * 100 error_message = "expected '#{self.actual.path}' to match previous snapshot #{expected} by #{expected_amount.round(3)}%, but was off by #{actual_amount.round(3)}%\n" error_message += result[:message] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
looks_good-1.1.1 | lib/looks_good/matchers/look_like_matcher.rb |