Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/rspec/snapshot/file_operator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/snapshot/matchers/match_snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
10 changes: 5 additions & 5 deletions spec/rspec/snapshot/matchers/match_snapshot_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading