diff --git a/lib/rspec/snapshot/file_operator.rb b/lib/rspec/snapshot/file_operator.rb index 9cc5f60..014dadd 100644 --- a/lib/rspec/snapshot/file_operator.rb +++ b/lib/rspec/snapshot/file_operator.rb @@ -6,6 +6,8 @@ module RSpec module Snapshot # Handles File IO for snapshots class FileOperator + attr_reader :snapshot_path + # Initializes the class instance, and creates the snapshot directory for # the current test if needed. # diff --git a/lib/rspec/snapshot/matchers/match_snapshot.rb b/lib/rspec/snapshot/matchers/match_snapshot.rb index 70bd309..56e1e47 100644 --- a/lib/rspec/snapshot/matchers/match_snapshot.rb +++ b/lib/rspec/snapshot/matchers/match_snapshot.rb @@ -48,7 +48,7 @@ def matches?(actual) end def description - "to match a snapshot containing: \"#{@expected}\"" + "to match a snapshot: '#{@file_operator.snapshot_path}'" end def diffable? diff --git a/spec/rspec/snapshot/matchers/match_snapshot_spec.rb b/spec/rspec/snapshot/matchers/match_snapshot_spec.rb index 1b65681..1994296 100644 --- a/spec/rspec/snapshot/matchers/match_snapshot_spec.rb +++ b/spec/rspec/snapshot/matchers/match_snapshot_spec.rb @@ -79,17 +79,17 @@ end describe '.description' do - subject { described_class.new(nil, nil) } + subject { described_class.new(nil, file_operator) } - let(:expected) { 'snapshot value' } + let(:snapshot_path) { 'path/to/snapshot.snap' } before do - subject.instance_variable_set(:@expected, expected) + allow(file_operator).to receive(:snapshot_path).and_return(snapshot_path) end - it 'returns a description of the expected value' do + it 'returns a description which includes the path to the snapshot' do expect(subject.description).to( - eq("to match a snapshot containing: \"#{expected}\"") + eq("to match a snapshot: '#{snapshot_path}'") ) end end