Module: Memoria::RSpec::Configurator

Defined in:
lib/memoria/rspec/configurator.rb

Overview

Configures the integration with RSpec.

Class Method Summary collapse

Class Method Details

.configure_rspec_hooksvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Configures RSpec’s before and after hooks to record snapshots when match_snapshot is called.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/memoria/rspec/configurator.rb', line 16

def configure_rspec_hooks
  ::RSpec.configure do |config|
    config.before(:each, snapshot: true) do |example|
      current_example = example.respond_to?(:metadata) ? example : example.example
      snapshot_name   = Memoria::RSpec::MetadataParser.find_description_for(current_example.)

      Memoria.record(snapshot_name)
    end

    config.after(:each, snapshot: true) do
      Memoria.stop_recording
    end
  end
end

.include_rspec_matchersvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Includes RSpec’s matchers such as match_snapshot.



37
38
39
40
41
42
43
# File 'lib/memoria/rspec/configurator.rb', line 37

def include_rspec_matchers
  require 'memoria/rspec/matcher'

  ::RSpec.configure do |config|
    config.include Memoria::RSpec::Metadata
  end
end