Sha256: 1c4ea1ed31c45d7c20e448ade04de918cef7dae9ea19c10cc1e24dd1aa4110d6
Contents?: true
Size: 832 Bytes
Versions: 1
Compression:
Stored size: 832 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.binwrite(output_path, actual_output) end end end failure_message 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 |
---|---|
webtranslateit-payday-1.4.0 | spec/support/asset_matchers.rb |