Module: SnapshotTesting::RSpec

Defined in:
lib/snapshot_testing/rspec.rb

Defined Under Namespace

Classes: MatchSnapshot

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/snapshot_testing/rspec.rb', line 5

def self.included(base)
  base.let :__snapshot_recorder__ do |example|
    SnapshotTesting::Recorder.new(
      name: example.description,
      path: example.[:absolute_file_path],
      update: !ENV['UPDATE_SNAPSHOTS'].nil?
    )
  end

  base.after :each do
    __snapshot_recorder__.commit
  end
end

Instance Method Details

#match_snapshotObject



19
20
21
# File 'lib/snapshot_testing/rspec.rb', line 19

def match_snapshot
  SnapshotTesting::RSpec::MatchSnapshot.new(recorder: __snapshot_recorder__)
end