Class: Hecks::Behaviors::TestCaseBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/hecks/behaviors/dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(description) ⇒ TestCaseBuilder

Returns a new instance of TestCaseBuilder.



15
16
17
18
19
20
21
22
23
# File 'lib/hecks/behaviors/dsl.rb', line 15

def initialize(description)
  @description   = description
  @tests_command = nil
  @on_aggregate  = nil
  @kind          = :command
  @setups        = []
  @input         = {}
  @expect        = {}
end

Instance Method Details

#buildObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/hecks/behaviors/dsl.rb', line 38

def build
  unless @tests_command
    raise Malformed, "test #{@description.inspect} never calls `tests` — " \
                     "say which command or query this example exercises"
  end

  TestCase.new(description: @description, tests_command: @tests_command,
               on_aggregate: @on_aggregate, kind: @kind,
               setups: @setups, input: @input, expect: @expect)
end

#expect(**kwargs) ⇒ Object



36
# File 'lib/hecks/behaviors/dsl.rb', line 36

def expect(**kwargs) = @expect.merge!(kwargs)

#input(**kwargs) ⇒ Object



35
# File 'lib/hecks/behaviors/dsl.rb', line 35

def input(**kwargs)  = @input.merge!(kwargs)

#setup(command, **kwargs) ⇒ Object



31
32
33
# File 'lib/hecks/behaviors/dsl.rb', line 31

def setup(command, **kwargs)
  @setups << TestSetup.new(command: command, args: kwargs)
end

#tests(command, on: nil, kind: :command) ⇒ Object



25
26
27
28
29
# File 'lib/hecks/behaviors/dsl.rb', line 25

def tests(command, on: nil, kind: :command)
  @tests_command = command
  @on_aggregate  = on
  @kind          = kind
end