class RSpec::Cheki::Manager

Constants

SETTINGS_NAME

Attributes

files[R]

Public Class Methods

create_snapshot(example:) click to toggle source

Create snapshot instance from example object @param [RSpec::Core::Example] example The example @return [RSpec::Cheki::Snapshot] The snapshot

# File lib/rspec/cheki/manager.rb, line 10
def create_snapshot(example:)
  instance.create_snapshot(example)
end
new() click to toggle source
# File lib/rspec/cheki/manager.rb, line 34
def initialize
  @files = {}
end
settings_name() click to toggle source

@return [String] The settings name

# File lib/rspec/cheki/manager.rb, line 15
def settings_name
  SETTINGS_NAME
end
update(update: false) click to toggle source

Save snapshots to file @param update [boolean] Save updated snapshots if true

# File lib/rspec/cheki/manager.rb, line 21
def update(update: false)
  instance.save(update: update)
end

Private Class Methods

instance() click to toggle source
# File lib/rspec/cheki/manager.rb, line 27
def instance
  RSpec.configuration.send(settings_name)
end

Public Instance Methods

create_snapshot(example) click to toggle source

Create snapshot instance from example object @param [RSpec::Core::Example] example The example @return [RSpec::Cheki::Snapshot] The snapshot

# File lib/rspec/cheki/manager.rb, line 41
def create_snapshot example
  key = example.file_path
  @files[key] = SnapFile.create(example: example) unless @files.key? key
  @files[key].create_snapshot(example.id)
end
save(update: false) click to toggle source

Save snapshots to file @param update [boolean] Save updated snapshots if true

# File lib/rspec/cheki/manager.rb, line 49
def save(update: false)
  @files.each { |_, f| f.save(update: update) }
end