Class: TestBench::Session::Substitute::Sink
- Inherits:
-
Object
- Object
- TestBench::Session::Substitute::Sink
show all
- Includes:
- Telemetry::Sink, Events
- Defined in:
- lib/test_bench/session/substitute/sink.rb
Defined Under Namespace
Classes: Record
Constant Summary
Constants included
from Events
Events::Commented, Events::ContextFinished, Events::ContextSkipped, Events::ContextStarted, Events::Detailed, Events::Failed, Events::FixtureFinished, Events::FixtureStarted, Events::TestFinished, Events::TestSkipped, Events::TestStarted
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Events
each_type
Instance Attribute Details
#path ⇒ Object
13
14
15
|
# File 'lib/test_bench/session/substitute/sink.rb', line 13
def path
@path ||= Path.new
end
|
#records ⇒ Object
8
9
10
|
# File 'lib/test_bench/session/substitute/sink.rb', line 8
def records
@records ||= []
end
|
Instance Method Details
#any_event?(event_class, *path_segments, **attributes) ⇒ Boolean
Also known as:
event?
75
76
77
78
|
# File 'lib/test_bench/session/substitute/sink.rb', line 75
def any_event?(event_class, *path_segments, **attributes)
event_sink = event_sink(*path_segments)
event_sink.any_event?(event_class, **attributes)
end
|
#event_sink(*path_segments) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/test_bench/session/substitute/sink.rb', line 86
def event_sink(*path_segments)
event_sink = Telemetry::Substitute::Sink.new
records.each do |record|
if record.match?(path_segments)
event_data = record.event_data
event_sink.receive(event_data)
end
end
event_sink
end
|
#events(event_class, *path_segments, **attributes) ⇒ Object
81
82
83
84
|
# File 'lib/test_bench/session/substitute/sink.rb', line 81
def events(event_class, *path_segments, **attributes)
event_sink = event_sink(*path_segments)
event_sink.events(event_class, **attributes)
end
|
#one_event(event_class, *path_segments, **attributes) ⇒ Object
70
71
72
73
|
# File 'lib/test_bench/session/substitute/sink.rb', line 70
def one_event(event_class, *path_segments, **attributes)
event_sink = event_sink(*path_segments)
event_sink.one_event(event_class, **attributes)
end
|
#one_event?(event_class, *path_segments, **attributes) ⇒ Boolean
65
66
67
68
|
# File 'lib/test_bench/session/substitute/sink.rb', line 65
def one_event?(event_class, *path_segments, **attributes)
event_sink = event_sink(*path_segments)
event_sink.one_event?(event_class, **attributes)
end
|
#receive(event_data) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/test_bench/session/substitute/sink.rb', line 18
def receive(event_data)
event_type = event_data.type
case event_data.type
when :TestStarted, :ContextStarted
title, * = event_data.data
if not title.nil?
path.push(title)
end
when :TestFinished, :ContextFinished
title, * = event_data.data
if not title.nil?
path.pop(title)
end
end
record = Record.new(event_data)
path.copy(record)
case event_data.type
when :TestFinished, :ContextFinished
title, * = event_data.data
if not title.nil?
record.path.push(title)
end
when :Commented, :Detailed
, * = event_data.data
record.path.push()
end
records.push(record)
record
end
|
#received?(event_data = nil) ⇒ Boolean
55
56
57
58
59
60
61
62
63
|
# File 'lib/test_bench/session/substitute/sink.rb', line 55
def received?(event_data=nil)
if not event_data.nil?
records.any? do |record|
record.event_data == event_data
end
else
records.any?
end
end
|