Class: Simmer::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/simmer/runner.rb,
lib/simmer/runner/result.rb,
lib/simmer/runner/timeout_error.rb

Overview

Runs a single specification.

Defined Under Namespace

Classes: Result, TimeoutError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database:, file_system:, fixture_set:, out:, spoon_client:) ⇒ Runner

Returns a new instance of Runner.



19
20
21
22
23
24
25
26
27
28
# File 'lib/simmer/runner.rb', line 19

def initialize(database:, file_system:, fixture_set:, out:, spoon_client:)
  @database     = database
  @file_system  = file_system
  @fixture_set  = fixture_set
  @judge        = Judge.new(database)
  @out          = out
  @spoon_client = spoon_client

  freeze
end

Instance Attribute Details

#spoon_clientObject (readonly)

Returns the value of attribute spoon_client.



17
18
19
# File 'lib/simmer/runner.rb', line 17

def spoon_client
  @spoon_client
end

Instance Method Details

#completeObject



51
52
53
# File 'lib/simmer/runner.rb', line 51

def complete
  out.close
end

#run(specification, config:, id: SecureRandom.uuid) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/simmer/runner.rb', line 30

def run(specification, config:, id: SecureRandom.uuid)
  out.announce_start(id, specification)

  config.run_single_test_with_callbacks do
    clean_and_seed(specification)

    spoon_client_result = execute_spoon(specification, config)
    judge_result        = assert(specification, spoon_client_result)

    Result.new(
      id: id,
      judge_result: judge_result,
      specification: specification,
      spoon_client_result: spoon_client_result
    ).tap { |result| out.final_verdict(result) }
  rescue Database::FixtureSet::FixtureMissingError, Simmer::Runner::TimeoutError => e
    Result.new(id: id, specification: specification, errors: e)
          .tap { |result| out.final_verdict(result) }
  end
end