Class: RSpec::Cheki::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/cheki/manager.rb

Constant Summary collapse

SETTINGS_NAME =
:"rspec_cheki_manager"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Manager

Returns a new instance of Manager.



34
35
36
# File 'lib/rspec/cheki/manager.rb', line 34

def initialize
  @files = {}
end

Instance Attribute Details

#files ⇒ Object (readonly)

Returns the value of attribute files.



32
33
34
# File 'lib/rspec/cheki/manager.rb', line 32

def files
  @files
end

Class Method Details

.create_snapshot(example:) ⇒ RSpec::Cheki::Snapshot

Create snapshot instance from example object

Parameters:

  • example (RSpec::Core::Example) —

    The example

Returns:



10
11
12
# File 'lib/rspec/cheki/manager.rb', line 10

def create_snapshot(example:)
  instance.create_snapshot(example)
end

.settings_name ⇒ String

Returns The settings name.

Returns:

  • (String) —

    The settings name



15
16
17
# File 'lib/rspec/cheki/manager.rb', line 15

def settings_name
  SETTINGS_NAME
end

.update(update: false) ⇒ Object

Save snapshots to file

Parameters:

  • update (boolean) (defaults to: false) —

    Save updated snapshots if true



21
22
23
# File 'lib/rspec/cheki/manager.rb', line 21

def update(update: false)
  instance.save(update: update)
end

Instance Method Details

#create_snapshot(example) ⇒ RSpec::Cheki::Snapshot

Create snapshot instance from example object

Parameters:

  • example (RSpec::Core::Example) —

    The example

Returns:



41
42
43
44
45
# 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) ⇒ Object

Save snapshots to file

Parameters:

  • update (boolean) (defaults to: false) —

    Save updated snapshots if true



49
50
51
# File 'lib/rspec/cheki/manager.rb', line 49

def save(update: false)
  @files.each { |_, f| f.save(update: update) }
end