Module: Kaisoku::Snapshot::RSpec

Defined in:
lib/kaisoku/snapshot/rspec.rb

Class Method Summary collapse

Class Method Details

.installObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kaisoku/snapshot/rspec.rb', line 6

def self.install
  return unless defined?(::RSpec::Matchers)

  ::RSpec::Matchers.define :match_inline_snapshot do |expected|
    match do |actual|
      location = caller_locations.find { |frame| frame.path.end_with?('_spec.rb') }
      Inline.matches?(actual, expected, location: location)
    end

    failure_message do |actual|
      "expected #{actual.inspect} to match inline snapshot #{expected.inspect}"
    end
  end
end