Sha256: aa354ca90a2673acac9f54b7348f95430dd7d36c643d1344e5bec83e49d26518
Contents?: true
Size: 801 Bytes
Versions: 42
Compression:
Stored size: 801 Bytes
Contents
require 'approvals/rspec' require 'pact/support' Approvals.configure do |c| c.approvals_path = 'spec/fixtures/approvals/' end def print_diff(exception) parts = exception.message.split('"') received_file = parts[1] approved_file = parts[3] if File.exist?(received_file) && File.exist?(approved_file) && received_file.end_with?(".json") && approved_file.end_with?(".json") received_hash = JSON.parse(File.read(received_file)) approved_hash = JSON.parse(File.read(approved_file)) diff = Pact::Matchers.diff(approved_hash, received_hash) puts Pact::Matchers::UnixDiffFormatter.call(diff) end end RSpec.configure do | config | config.after(:each) do | example | if example.exception.is_a?(Approvals::ApprovalError) print_diff(example.exception) end end end
Version data entries
42 entries across 42 versions & 1 rubygems