Class: Simmer::Judge

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

Overview

Runs all assertions and reports back the results.

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database) ⇒ Judge

Returns a new instance of Judge.

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
# File 'lib/simmer/judge.rb', line 18

def initialize(database)
  raise ArgumentError, 'database is required' unless database

  @database = database

  freeze
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



16
17
18
# File 'lib/simmer/judge.rb', line 16

def database
  @database
end

Instance Method Details

#assert(specification, output) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/simmer/judge.rb', line 26

def assert(specification, output)
  assertions = specification.assert.assertions

  bad_assertions = assertions.map { |assertion| assertion.assert(database, output) }.compact

  Result.new(bad_assertions)
end