Class: Metacosm::TestHarness::GivenWhenThen

Inherits:
Struct
  • Object
show all
Includes:
RSpec::Matchers
Defined in:
lib/metacosm/support/test_harness.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#given_eventsObject

Returns the value of attribute given_events

Returns:

  • (Object)

    the current value of given_events



3
4
5
# File 'lib/metacosm/support/test_harness.rb', line 3

def given_events
  @given_events
end

#then_event_classObject

Returns the value of attribute then_event_class

Returns:

  • (Object)

    the current value of then_event_class



3
4
5
# File 'lib/metacosm/support/test_harness.rb', line 3

def then_event_class
  @then_event_class
end

#when_commandObject

Returns the value of attribute when_command

Returns:

  • (Object)

    the current value of when_command



3
4
5
# File 'lib/metacosm/support/test_harness.rb', line 3

def when_command
  @when_command
end

Instance Method Details

#expect_events(evts) ⇒ Object



14
15
16
17
18
# File 'lib/metacosm/support/test_harness.rb', line 14

def expect_events(evts)
  @then_events = evts
  verify!
  self
end

#expect_query(query, to_find:) ⇒ Object



20
21
22
23
24
25
# File 'lib/metacosm/support/test_harness.rb', line 20

def expect_query(query, to_find:)
  @query = query
  @expected_query_results = to_find
  verify!
  self
end

#verify!Object (protected)



29
30
31
32
33
34
35
36
37
38
# File 'lib/metacosm/support/test_harness.rb', line 29

def verify!
  clean_slate!
  receive_events!
  fire_commands!

  validate_events!
  validate_query!

  self
end

#when(*commands) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/metacosm/support/test_harness.rb', line 6

def when(*commands)
  @when_commands ||= []
  commands.each do |command|
    @when_commands.push command
  end
  self
end