Class: Thoreau::LegacyExpectedOutcomes

Inherits:
Object
  • Object
show all
Defined in:
lib/thoreau/service/legacy_expected_outcomes.rb

Constant Summary collapse

VERSION =

A simple store of expected outcomes of test cases.

They are stored in a “pstore” database, with the test descriptor and inputs being the key. If you change the input of the test, it should generate a new saved result.

Set ENV to, well, reset all the snapshots.

1

Instance Method Summary collapse

Constructor Details

#initialize(suite_name) ⇒ LegacyExpectedOutcomes

Returns a new instance of LegacyExpectedOutcomes.



19
20
21
# File 'lib/thoreau/service/legacy_expected_outcomes.rb', line 19

def initialize(suite_name)
  @suite_name = suite_name
end

Instance Method Details

#has_saved_for?(test_case) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/thoreau/service/legacy_expected_outcomes.rb', line 31

def has_saved_for? test_case
  logger.debug("has_saved_for? for #{key_for(test_case)}")
  !!(load_for test_case)
end

#key_for(test_case) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/thoreau/service/legacy_expected_outcomes.rb', line 23

def key_for(test_case)
  o = {
    desc:  test_case.family_desc,
    input: test_case.input
  }
  o.to_json
end

#load_for(test_case) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/thoreau/service/legacy_expected_outcomes.rb', line 36

def load_for test_case
  logger.debug("load_for for #{key_for(test_case)}")
  wiki = PStore.new(Thoreau.configuration.legacy_outcome_path)
  wiki.transaction do
    wiki[key_for(test_case)]
  end
end

#save!(test_case) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/thoreau/service/legacy_expected_outcomes.rb', line 44

def save! test_case
  logger.debug("save! for #{key_for(test_case)}")
  wiki = PStore.new(Thoreau.configuration.legacy_outcome_path)
  wiki.transaction do
    wiki[key_for(test_case)] = test_case.actual
  end
end