torkify 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -1
- data/.travis.yml +6 -0
- data/README.md +8 -2
- data/VERSION +1 -1
- data/lib/torkify/conductor.rb +25 -14
- data/lib/torkify/{events/event.rb → event/basic_event.rb} +4 -4
- data/lib/torkify/event/dispatcher.rb +91 -0
- data/lib/torkify/event/echo_event.rb +23 -0
- data/lib/torkify/{events/event_message.rb → event/message.rb} +2 -2
- data/lib/torkify/event/parser.rb +70 -0
- data/lib/torkify/{events → event}/pass_or_fail_event.rb +15 -3
- data/lib/torkify/event/ran_all_test_files_event.rb +30 -0
- data/lib/torkify/{events → event}/status_change_event.rb +3 -3
- data/lib/torkify/{events → event}/test_event.rb +4 -3
- data/lib/torkify/listener.rb +17 -8
- data/lib/torkify/log/line_matcher.rb +33 -0
- data/lib/torkify/log/log_reader.rb +32 -0
- data/lib/torkify/log/parser.rb +96 -0
- data/lib/torkify/log/test_error.rb +7 -0
- data/lib/torkify/reader.rb +7 -5
- data/lib/torkify/version.rb +1 -1
- data/lib/torkify.rb +2 -3
- data/spec/conductor_spec.rb +3 -4
- data/spec/event/basic_event_spec.rb +30 -0
- data/spec/event/dispatcher_spec.rb +190 -0
- data/spec/event/echo_event_spec.rb +22 -0
- data/spec/event/parser_spec.rb +288 -0
- data/spec/{pass_or_fail_event_spec.rb → event/pass_or_fail_event_spec.rb} +2 -2
- data/spec/event/ran_all_test_files_event_spec.rb +42 -0
- data/spec/{status_change_event_spec.rb → event/status_change_event_spec.rb} +3 -3
- data/spec/{test_event_spec.rb → event/test_event_spec.rb} +2 -2
- data/spec/log/integration_spec.rb +222 -0
- data/spec/log/line_matcher_spec.rb +247 -0
- data/spec/log/log_reader_spec.rb +54 -0
- data/spec/log/logs/invalid_ruby_error_1.log +1 -0
- data/spec/log/logs/rspec_failure_1.log +19 -0
- data/spec/log/logs/rspec_failure_2.log +57 -0
- data/spec/log/logs/ruby_error_1.log +16 -0
- data/spec/log/logs/ruby_error_2.log +17 -0
- data/spec/log/logs/ruby_error_3.log +18 -0
- data/spec/log/logs/test_unit_error_1.log +22 -0
- data/spec/log/logs/test_unit_failure_1.log +22 -0
- data/spec/log/test_error_spec.rb +36 -0
- data/torkify.gemspec +1 -1
- metadata +63 -40
- data/lib/torkify/event_parser.rb +0 -36
- data/lib/torkify/observer_set.rb +0 -62
- data/spec/event_parser_spec.rb +0 -154
- data/spec/event_spec.rb +0 -18
- data/spec/observer_set_spec.rb +0 -100
data/lib/torkify.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "torkify/version"
|
2
|
+
require 'log4r'
|
2
3
|
|
3
4
|
# Listen to tork events and execute ruby code when they happen.
|
4
5
|
#
|
@@ -15,6 +16,7 @@ require "torkify/version"
|
|
15
16
|
# # or listener.start_loop
|
16
17
|
# # or listener.start_with_tork
|
17
18
|
module Torkify
|
19
|
+
include Log4r
|
18
20
|
|
19
21
|
# Create a listener object and load all required files.
|
20
22
|
def self.listener(*args)
|
@@ -26,9 +28,6 @@ module Torkify
|
|
26
28
|
#
|
27
29
|
# Uses Log4r.
|
28
30
|
def self.logger
|
29
|
-
require 'log4r'
|
30
|
-
include Log4r
|
31
|
-
|
32
31
|
log = Logger['torkify']
|
33
32
|
unless log
|
34
33
|
log = Logger.new 'torkify'
|
data/spec/conductor_spec.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'torkify/conductor'
|
3
|
-
require 'torkify/observer_set'
|
4
3
|
|
5
4
|
module Torkify
|
6
5
|
describe Conductor do
|
7
6
|
before do
|
8
7
|
@reader = double
|
9
|
-
@observers =
|
8
|
+
@observers = Set.new
|
10
9
|
@conductor = Conductor.new @observers
|
11
10
|
end
|
12
11
|
|
@@ -38,7 +37,7 @@ module Torkify
|
|
38
37
|
end
|
39
38
|
|
40
39
|
it "should call startup and shutdown on each observer and each_line on reader" do
|
41
|
-
@reader.should_receive(:
|
40
|
+
@reader.should_receive(:gets).and_return nil
|
42
41
|
@conductor.start @reader
|
43
42
|
end
|
44
43
|
end
|
@@ -46,7 +45,7 @@ module Torkify
|
|
46
45
|
context "when start is called with dummy input" do
|
47
46
|
before do
|
48
47
|
line = '["test","spec/status_change_event_spec.rb",[],"spec/status_change_event_spec.rb.log",0]'
|
49
|
-
@reader.should_receive(:
|
48
|
+
@reader.should_receive(:gets).and_return(line, nil)
|
50
49
|
@conductor.observers += [double, double]
|
51
50
|
end
|
52
51
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'torkify/event/basic_event'
|
3
|
+
|
4
|
+
module Torkify::Event
|
5
|
+
describe BasicEvent do
|
6
|
+
context "when type is absorb" do
|
7
|
+
before do
|
8
|
+
@event = BasicEvent.new('absorb')
|
9
|
+
end
|
10
|
+
|
11
|
+
subject { @event }
|
12
|
+
|
13
|
+
its(:type) { should == 'absorb' }
|
14
|
+
its(:to_s) { should == 'absorb' }
|
15
|
+
its(:message) { should == :on_absorb }
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when type is stop" do
|
19
|
+
before do
|
20
|
+
@event = BasicEvent.new('stop')
|
21
|
+
end
|
22
|
+
|
23
|
+
subject { @event }
|
24
|
+
|
25
|
+
its(:type) { should == 'stop' }
|
26
|
+
its(:to_s) { should == 'stop' }
|
27
|
+
its(:message) { should == :on_stop }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'torkify/event/dispatcher'
|
3
|
+
require 'torkify/event/basic_event'
|
4
|
+
require 'torkify/event/pass_or_fail_event'
|
5
|
+
|
6
|
+
module Torkify::Event
|
7
|
+
|
8
|
+
class ExampleObserver
|
9
|
+
def on_stop(event, a1, a2, a3, a4, a5)
|
10
|
+
receive :on_stop, event, a1, a2, a3, a4, a5
|
11
|
+
end
|
12
|
+
|
13
|
+
def on_fail(event, another)
|
14
|
+
receive :on_fail, event, another
|
15
|
+
end
|
16
|
+
|
17
|
+
def on_test(event)
|
18
|
+
receive :on_test, event
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(name, *args)
|
22
|
+
receive name, *args
|
23
|
+
end
|
24
|
+
|
25
|
+
def on_pass
|
26
|
+
receive :on_pass
|
27
|
+
end
|
28
|
+
|
29
|
+
def receive(message, *args)
|
30
|
+
@received = [message, *args]
|
31
|
+
end
|
32
|
+
|
33
|
+
attr_reader :received
|
34
|
+
end
|
35
|
+
|
36
|
+
describe Dispatcher do
|
37
|
+
shared_examples "an observer notification" do
|
38
|
+
it "should send the expected message and event to the observer" do
|
39
|
+
observers.each { |o| o.should_receive(expected_message).with(event) }
|
40
|
+
subject.dispatch event
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
shared_examples "an observer with a called method" do
|
45
|
+
before { dispatcher.dispatch(event) }
|
46
|
+
subject { observers.first }
|
47
|
+
|
48
|
+
its(:received) { should == expected_call }
|
49
|
+
end
|
50
|
+
|
51
|
+
context "with a single observer" do
|
52
|
+
let(:observers) { [mock] }
|
53
|
+
subject { Dispatcher.new observers }
|
54
|
+
|
55
|
+
context "dispatching an example event" do
|
56
|
+
let(:event) { BasicEvent.new :example }
|
57
|
+
let(:expected_message) { :on_example }
|
58
|
+
|
59
|
+
it_behaves_like "an observer notification"
|
60
|
+
end
|
61
|
+
|
62
|
+
context "dispatching a test event" do
|
63
|
+
let(:event) { BasicEvent.new :test }
|
64
|
+
let(:expected_message) { :on_test }
|
65
|
+
|
66
|
+
it_behaves_like "an observer notification"
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
context "with a concrete observer" do
|
72
|
+
let(:observers) { [ ExampleObserver.new ] }
|
73
|
+
let(:dispatcher) { Dispatcher.new observers }
|
74
|
+
|
75
|
+
context "dispatching to a method that receives no arguments" do
|
76
|
+
let(:event) { BasicEvent.new :pass }
|
77
|
+
let(:expected_call) { [:on_pass] }
|
78
|
+
|
79
|
+
it_behaves_like "an observer with a called method"
|
80
|
+
end
|
81
|
+
|
82
|
+
context "dispatching to a method that receives one argument" do
|
83
|
+
let(:event) { BasicEvent.new :test }
|
84
|
+
let(:expected_call) { [:on_test, event] }
|
85
|
+
|
86
|
+
it_behaves_like "an observer with a called method"
|
87
|
+
end
|
88
|
+
|
89
|
+
context "dispatching to a method that receives two arguments" do
|
90
|
+
let(:event) { BasicEvent.new :fail }
|
91
|
+
let(:expected_call) { [:on_fail, event, nil] }
|
92
|
+
|
93
|
+
it_behaves_like "an observer with a called method"
|
94
|
+
end
|
95
|
+
|
96
|
+
context "dispatching to a method that receives many arguments" do
|
97
|
+
let(:event) { BasicEvent.new :stop }
|
98
|
+
let(:expected_call) { [:on_stop, event, nil, nil, nil, nil, nil] }
|
99
|
+
|
100
|
+
it_behaves_like "an observer with a called method"
|
101
|
+
end
|
102
|
+
|
103
|
+
context "dispatching to use method missing" do
|
104
|
+
let(:event) { BasicEvent.new :unknown }
|
105
|
+
let(:expected_call) { [:on_unknown, event] }
|
106
|
+
|
107
|
+
it_behaves_like "an observer with a called method"
|
108
|
+
end
|
109
|
+
|
110
|
+
context "dispatching a run all test files event" do
|
111
|
+
let(:event) { BasicEvent.new :run_all_test_files }
|
112
|
+
let(:expected_call) { [:on_run_all_test_files, event] }
|
113
|
+
|
114
|
+
before { dispatcher.dispatch event }
|
115
|
+
|
116
|
+
it_behaves_like "an observer with a called method"
|
117
|
+
|
118
|
+
context "after sending the idle event" do
|
119
|
+
before { dispatcher.dispatch BasicEvent.new :idle }
|
120
|
+
|
121
|
+
subject { observers.first.received }
|
122
|
+
|
123
|
+
its(:first) { should == :on_ran_all_test_files }
|
124
|
+
|
125
|
+
context "the event" do
|
126
|
+
subject { observers.first.received[1] }
|
127
|
+
it { should be_a RanAllTestFilesEvent }
|
128
|
+
its(:passed) { should == [] }
|
129
|
+
its(:failed) { should == [] }
|
130
|
+
its(:time) { should > 0.0 }
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "after sending several pass and fail events" do
|
135
|
+
let(:pass_events) { Array.new(3) { PassOrFailEvent.new(:pass) } }
|
136
|
+
let(:fail_events) { Array.new(3) { PassOrFailEvent.new(:fail) } }
|
137
|
+
|
138
|
+
before do
|
139
|
+
pass_events.each { |e| dispatcher.dispatch e }
|
140
|
+
fail_events.each { |e| dispatcher.dispatch e }
|
141
|
+
dispatcher.dispatch BasicEvent.new :idle
|
142
|
+
end
|
143
|
+
|
144
|
+
subject { observers.first.received }
|
145
|
+
|
146
|
+
its(:first) { should == :on_ran_all_test_files }
|
147
|
+
|
148
|
+
context "the event" do
|
149
|
+
subject { observers.first.received[1] }
|
150
|
+
it { should be_a RanAllTestFilesEvent }
|
151
|
+
its(:passed) { should == pass_events }
|
152
|
+
its(:failed) { should == fail_events }
|
153
|
+
its(:time) { should > 0.0 }
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "with an observer that has no methods" do
|
160
|
+
let(:observers) { [Object.new] }
|
161
|
+
|
162
|
+
let(:dispatcher) { Dispatcher.new observers }
|
163
|
+
|
164
|
+
context "dispatching an event" do
|
165
|
+
it "should not raise an exception" do
|
166
|
+
expect { dispatcher.dispatch BasicEvent.new(:missing) }.not_to raise_error
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context "with multiple observers" do
|
172
|
+
let(:observers) { Array.new(3) { mock } }
|
173
|
+
subject { Dispatcher.new observers }
|
174
|
+
|
175
|
+
context "dispatching an absorb event" do
|
176
|
+
let(:event) { BasicEvent.new :absorb }
|
177
|
+
let(:expected_message) { :on_absorb }
|
178
|
+
|
179
|
+
it_behaves_like "an observer notification"
|
180
|
+
end
|
181
|
+
|
182
|
+
context "dispatching a fail event" do
|
183
|
+
let(:event) { BasicEvent.new :fail }
|
184
|
+
let(:expected_message) { :on_fail }
|
185
|
+
|
186
|
+
it_behaves_like "an observer notification"
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'torkify/event/echo_event'
|
3
|
+
|
4
|
+
module Torkify::Event
|
5
|
+
describe EchoEvent do
|
6
|
+
|
7
|
+
context "with a pass_now_fail event" do
|
8
|
+
before do
|
9
|
+
@type = 'echo'
|
10
|
+
@arguments = ['a']
|
11
|
+
@event = EchoEvent.new(@type, @arguments)
|
12
|
+
end
|
13
|
+
|
14
|
+
subject { @event }
|
15
|
+
|
16
|
+
its(:type) { should == @type }
|
17
|
+
its(:arguments) { should == @arguments }
|
18
|
+
its(:args) { should == @arguments }
|
19
|
+
its(:to_s) { should == @type }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,288 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'torkify/event/parser'
|
3
|
+
|
4
|
+
module Torkify::Event
|
5
|
+
shared_examples "a basic event" do |type|
|
6
|
+
it { should be_an BasicEvent }
|
7
|
+
its(:type) { should == type }
|
8
|
+
end
|
9
|
+
|
10
|
+
shared_examples "an echo event" do |args|
|
11
|
+
it { should be_an EchoEvent }
|
12
|
+
its(:type) { should == 'echo' }
|
13
|
+
its(:args) { should == args }
|
14
|
+
end
|
15
|
+
|
16
|
+
shared_examples "an echo event and sub event" do |type, echo_args = nil|
|
17
|
+
its(:length) { should == 2 }
|
18
|
+
|
19
|
+
context "the first event" do
|
20
|
+
subject { @event_list.first }
|
21
|
+
|
22
|
+
it_behaves_like "an echo event", (echo_args || [type])
|
23
|
+
end
|
24
|
+
|
25
|
+
context "the second event" do
|
26
|
+
subject { @event_list[1] }
|
27
|
+
|
28
|
+
it_behaves_like "a basic event", type
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe Parser do
|
33
|
+
before { @parser = Parser.new }
|
34
|
+
|
35
|
+
context "when calling parse on a test event line with no numbers" do
|
36
|
+
before do
|
37
|
+
line = '["test","spec/reader_spec.rb",[],"spec/reader_spec.rb.log",3]'
|
38
|
+
@event_list = @parser.parse line
|
39
|
+
end
|
40
|
+
|
41
|
+
subject { @event_list.first }
|
42
|
+
|
43
|
+
it { should be_a TestEvent }
|
44
|
+
|
45
|
+
its(:file) { should == 'spec/reader_spec.rb' }
|
46
|
+
its(:lines) { should == [] }
|
47
|
+
its(:log_file) { should == 'spec/reader_spec.rb.log' }
|
48
|
+
its(:worker) { should == 3 }
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when calling parse on a test event line with numbers" do
|
52
|
+
before do
|
53
|
+
line = '["test","spec/another_spec.rb",[20, 32, 41],"spec/another_spec.rb.log",6]'
|
54
|
+
@event_list = @parser.parse line
|
55
|
+
end
|
56
|
+
|
57
|
+
subject { @event_list.first }
|
58
|
+
|
59
|
+
it { should be_a TestEvent }
|
60
|
+
|
61
|
+
its(:file) { should == 'spec/another_spec.rb' }
|
62
|
+
its(:lines) { should == [20, 32, 41] }
|
63
|
+
its(:log_file) { should == 'spec/another_spec.rb.log' }
|
64
|
+
its(:worker) { should == 6 }
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when calling parse on a pass event line" do
|
68
|
+
before do
|
69
|
+
line = '["pass","spec/pass_spec.rb",[27],"spec/pass_spec.rb.log",1,0,"#<Process::Status: pid 27490 exit 0>"]'
|
70
|
+
@event_list = @parser.parse line
|
71
|
+
end
|
72
|
+
|
73
|
+
subject { @event_list.first }
|
74
|
+
|
75
|
+
it { should be_a PassOrFailEvent }
|
76
|
+
its(:type) { should == 'pass' }
|
77
|
+
its(:file) { should == 'spec/pass_spec.rb' }
|
78
|
+
its(:lines) { should == [27] }
|
79
|
+
its(:log_file) { should == 'spec/pass_spec.rb.log' }
|
80
|
+
its(:worker) { should == 1 }
|
81
|
+
its(:exit_code) { should == 0 }
|
82
|
+
its(:pid) { should == 27490 }
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when calling parse on a fail event line" do
|
86
|
+
before do
|
87
|
+
|
88
|
+
line = '["fail","spec/fail_spec.rb",[],"spec/fail_spec.rb.log",1,256,"#<Process::Status: pid 23318 exit 1>"]'
|
89
|
+
@event_list = @parser.parse line
|
90
|
+
end
|
91
|
+
|
92
|
+
subject { @event_list.first }
|
93
|
+
|
94
|
+
it { should be_a PassOrFailEvent }
|
95
|
+
its(:type) { should == 'fail' }
|
96
|
+
its(:file) { should == 'spec/fail_spec.rb' }
|
97
|
+
its(:lines) { should == [] }
|
98
|
+
its(:log_file) { should == 'spec/fail_spec.rb.log' }
|
99
|
+
its(:worker) { should == 1 }
|
100
|
+
its(:exit_code) { should == 256 }
|
101
|
+
its(:pid) { should == 23318 }
|
102
|
+
end
|
103
|
+
|
104
|
+
context "when calling parse on an absorb event line" do
|
105
|
+
before do
|
106
|
+
line = '["absorb"]'
|
107
|
+
@event_list = @parser.parse line
|
108
|
+
end
|
109
|
+
|
110
|
+
subject { @event_list.first }
|
111
|
+
|
112
|
+
it_behaves_like "a basic event", 'absorb'
|
113
|
+
end
|
114
|
+
|
115
|
+
context "when calling parse on an unknown event type" do
|
116
|
+
before do
|
117
|
+
line = '["random"]'
|
118
|
+
@event_list = @parser.parse line
|
119
|
+
end
|
120
|
+
|
121
|
+
subject { @event_list.first }
|
122
|
+
|
123
|
+
it_behaves_like "a basic event", 'random'
|
124
|
+
end
|
125
|
+
|
126
|
+
context "when calling parse on a pass now fail event line" do
|
127
|
+
before do
|
128
|
+
line = '["pass_now_fail","spec/status_change_spec.rb",["fail","spec/status_change_spec.rb",[68],"spec/status_change_spec.rb.log",2,256,"#<Process::Status: pid 23819 exit 1>"]]'
|
129
|
+
@event_list = @parser.parse line
|
130
|
+
end
|
131
|
+
|
132
|
+
subject { @event_list.first }
|
133
|
+
|
134
|
+
it { should be_a StatusChangeEvent }
|
135
|
+
its(:type) { should == 'pass_now_fail' }
|
136
|
+
its(:file) { should == 'spec/status_change_spec.rb' }
|
137
|
+
its(:event) { should be_a PassOrFailEvent }
|
138
|
+
|
139
|
+
context "and getting the inner event" do
|
140
|
+
subject { @event_list.first.event }
|
141
|
+
|
142
|
+
its(:type) { should == 'fail' }
|
143
|
+
its(:file) { should == 'spec/status_change_spec.rb' }
|
144
|
+
its(:log_file) { should == 'spec/status_change_spec.rb.log' }
|
145
|
+
its(:lines) { should == [68] }
|
146
|
+
its(:worker) { should == 2 }
|
147
|
+
its(:exit_code) { should == 256 }
|
148
|
+
its(:pid) { should == 23819 }
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context "when calling parse on a fail now pass event line" do
|
153
|
+
before do
|
154
|
+
line = '["fail_now_pass","spec/status_change_spec.rb",["pass","spec/status_change_spec.rb",[],"spec/status_change_spec.rb.log",1,0,"#<Process::Status: pid 677 exit 0>"]]'
|
155
|
+
@event_list = @parser.parse line
|
156
|
+
end
|
157
|
+
|
158
|
+
subject { @event_list.first }
|
159
|
+
|
160
|
+
it { should be_a StatusChangeEvent }
|
161
|
+
its(:type) { should == 'fail_now_pass' }
|
162
|
+
its(:file) { should == 'spec/status_change_spec.rb' }
|
163
|
+
its(:event) { should be_a PassOrFailEvent }
|
164
|
+
|
165
|
+
context "and getting the inner event" do
|
166
|
+
subject { @event_list.first.event }
|
167
|
+
|
168
|
+
its(:type) { should == 'pass' }
|
169
|
+
its(:file) { should == 'spec/status_change_spec.rb' }
|
170
|
+
its(:log_file) { should == 'spec/status_change_spec.rb.log' }
|
171
|
+
its(:lines) { should == [] }
|
172
|
+
its(:worker) { should == 1 }
|
173
|
+
its(:exit_code) { should == 0 }
|
174
|
+
its(:pid) { should == 677 }
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context "when calling parse on an idle line for an idle event" do
|
179
|
+
before do
|
180
|
+
line = '["idle"]'
|
181
|
+
@event_list = @parser.parse line
|
182
|
+
end
|
183
|
+
|
184
|
+
subject { @event_list }
|
185
|
+
|
186
|
+
its(:length) { should == 1 }
|
187
|
+
|
188
|
+
context "the first event" do
|
189
|
+
subject { @event_list.first }
|
190
|
+
|
191
|
+
it_behaves_like "a basic event", 'idle'
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context "when calling parse on an echo line for the idle event" do
|
196
|
+
before do
|
197
|
+
line = '["echo", ["idle"]]'
|
198
|
+
@event_list = @parser.parse line
|
199
|
+
end
|
200
|
+
|
201
|
+
subject { @event_list }
|
202
|
+
|
203
|
+
its(:length) { should == 1 }
|
204
|
+
|
205
|
+
context "the first event" do
|
206
|
+
subject { @event_list.first }
|
207
|
+
|
208
|
+
it_behaves_like "an echo event", ['idle']
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
context "when calling parse on an echo line for the run_test_files command" do
|
213
|
+
context "with no arguments" do
|
214
|
+
before do
|
215
|
+
line = '["echo", ["run_test_files", []]]'
|
216
|
+
@event_list = @parser.parse line
|
217
|
+
end
|
218
|
+
|
219
|
+
subject { @event_list }
|
220
|
+
|
221
|
+
its(:length) { should == 1 }
|
222
|
+
|
223
|
+
context "the first event" do
|
224
|
+
subject { @event_list.first }
|
225
|
+
|
226
|
+
it_behaves_like "an echo event", ['run_test_files', []]
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
context "with files as arguments" do
|
231
|
+
before do
|
232
|
+
line = '["echo", ["run_test_files", ["path/to/file1.rb", "path/to/file2.rb"]]]'
|
233
|
+
@event_list = @parser.parse line
|
234
|
+
end
|
235
|
+
|
236
|
+
subject { @event_list }
|
237
|
+
|
238
|
+
it_behaves_like "an echo event and sub event",
|
239
|
+
'run_test_files',
|
240
|
+
["run_test_files", ["path/to/file1.rb", "path/to/file2.rb"]]
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
context "when calling parse on an echo line for the run_test_file command" do
|
245
|
+
before do
|
246
|
+
line = '["echo", ["run_test_file", "path/to/file.rb"]]'
|
247
|
+
@event_list = @parser.parse line
|
248
|
+
end
|
249
|
+
|
250
|
+
subject { @event_list }
|
251
|
+
|
252
|
+
it_behaves_like "an echo event and sub event", 'run_test_file', ['run_test_file', 'path/to/file.rb']
|
253
|
+
end
|
254
|
+
|
255
|
+
context "when calling parse on an echo line for the run_test_file command" do
|
256
|
+
before do
|
257
|
+
line = '["echo", ["stop_running_test_files"]]'
|
258
|
+
@event_list = @parser.parse line
|
259
|
+
end
|
260
|
+
|
261
|
+
subject { @event_list }
|
262
|
+
|
263
|
+
it_behaves_like "an echo event and sub event", 'stop_running_test_files'
|
264
|
+
end
|
265
|
+
|
266
|
+
context "when calling parse on an echo line for the rerun_passed_test_files command" do
|
267
|
+
before do
|
268
|
+
line = '["echo", ["rerun_passed_test_files"]]'
|
269
|
+
@event_list = @parser.parse line
|
270
|
+
end
|
271
|
+
|
272
|
+
subject { @event_list }
|
273
|
+
|
274
|
+
it_behaves_like "an echo event and sub event", 'rerun_passed_test_files'
|
275
|
+
end
|
276
|
+
|
277
|
+
context "when calling parse on an echo line for a rerun_failed_test_files command" do
|
278
|
+
before do
|
279
|
+
line = '["echo",["rerun_failed_test_files"]]'
|
280
|
+
@event_list = @parser.parse line
|
281
|
+
end
|
282
|
+
|
283
|
+
subject { @event_list }
|
284
|
+
|
285
|
+
it_behaves_like "an echo event and sub event", 'rerun_failed_test_files'
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'torkify/event/ran_all_test_files_event'
|
3
|
+
|
4
|
+
module Torkify::Event
|
5
|
+
describe RanAllTestFilesEvent do
|
6
|
+
context "with no sub events" do
|
7
|
+
subject { RanAllTestFilesEvent.new :all_tests_run }
|
8
|
+
|
9
|
+
its(:type) { should == :all_tests_run }
|
10
|
+
its(:message) { should == :on_all_tests_run }
|
11
|
+
its(:passed) { should == [] }
|
12
|
+
its(:failed) { should == [] }
|
13
|
+
its(:time) { should > 0.0 }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "with passed and failed events" do
|
17
|
+
let(:passed) { [mock, mock] }
|
18
|
+
let(:failed) { [mock, mock] }
|
19
|
+
subject { RanAllTestFilesEvent.new :all_tests_run, passed, failed }
|
20
|
+
|
21
|
+
its(:type) { should == :all_tests_run }
|
22
|
+
its(:message) { should == :on_all_tests_run }
|
23
|
+
its(:passed) { should == passed }
|
24
|
+
its(:failed) { should == failed }
|
25
|
+
its(:time) { should > 0.0 }
|
26
|
+
end
|
27
|
+
|
28
|
+
context "after sleeping" do
|
29
|
+
let(:event) { RanAllTestFilesEvent.new :all_tests_run }
|
30
|
+
|
31
|
+
before do
|
32
|
+
event
|
33
|
+
sleep 0.3
|
34
|
+
end
|
35
|
+
|
36
|
+
subject { event }
|
37
|
+
|
38
|
+
its(:time) { should > 0.3 }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'torkify/
|
3
|
-
require 'torkify/
|
2
|
+
require 'torkify/event/status_change_event'
|
3
|
+
require 'torkify/event/pass_or_fail_event'
|
4
4
|
|
5
|
-
module Torkify
|
5
|
+
module Torkify::Event
|
6
6
|
describe StatusChangeEvent do
|
7
7
|
|
8
8
|
context "with a pass_now_fail event" do
|