Sha256: 95793976cee518793403bc87598311b63ad0a5002c62efaea8b8a98b13cfa997
Contents?: true
Size: 848 Bytes
Versions: 1
Compression:
Stored size: 848 Bytes
Contents
require 'fileutils' # Usage: expect(renderer.render).to match_binary_asset('pdf/test.pdf') RSpec::Matchers.define(:match_binary_asset) do |file_name| match do |actual_output| expected_path = File.join('spec/assets', file_name) expected_output = File.binread(expected_path) (actual_output == expected_output).tap do |result| unless result output_path = File.join('tmp/rendered_output', file_name) FileUtils.mkdir_p(File.dirname(output_path)) File.open(output_path, "wb") { |f| f.write actual_output } end end end failure_message_for_should do |actual_output| expected_output_path = File.join('spec/assets', file_name) actual_output_path = File.join('tmp/rendered_output', file_name) "expected output to match '#{expected_output_path}' (see #{actual_output_path})" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
payday-1.1.2 | spec/support/asset_matchers.rb |