guard-phpunit2 0.2.6 → 0.2.7
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/PHPUnit/Extensions/Progress/ResultPrinter.php +1 -1
- data/lib/guard/phpunit2/logreader.rb +114 -0
- data/lib/guard/phpunit2/realtime_runner.rb +54 -0
- data/lib/guard/phpunit2/runner.rb +26 -9
- data/lib/guard/phpunit2/version.rb +1 -1
- data/lib/guard/phpunit2.rb +10 -3
- data/spec/fixtures/failureSampleTest.php +11 -0
- data/spec/fixtures/mixedSampleTest.php +23 -0
- data/spec/fixtures/passingSampleTest.php +11 -0
- data/spec/fixtures/results/failing-json.txt +53 -0
- data/spec/fixtures/results/mixed-json.txt +110 -0
- data/spec/fixtures/results/multiple-test-cases-json.txt +319 -0
- data/spec/fixtures/results/passing-json.txt +35 -0
- data/spec/fixtures/results/skipped_and_incomplete-json.txt +77 -0
- data/spec/fixtures/skippedSampleTest.php +15 -0
- data/spec/guard/phpunit2/logreader_spec.rb +62 -0
- data/spec/guard/phpunit2/realtime_runner_spec.rb +167 -0
- data/spec/guard/phpunit2_spec.rb +29 -1
- data.tar.gz.sig +0 -0
- metadata +37 -14
- metadata.gz.sig +0 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Guard::PHPUnit2::LogReader do
|
4
|
+
|
5
|
+
describe '.parse_output' do
|
6
|
+
context 'when all tests pass' do
|
7
|
+
it 'returns a hash containing the results' do
|
8
|
+
output = load_phpunit_output('passing-json')
|
9
|
+
subject.parse_output(output).should == {
|
10
|
+
:tests => 2, :failures => 0,
|
11
|
+
:errors => 0, :pending => 0,
|
12
|
+
:duration => [0, 'seconds']
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when all tests fail' do
|
18
|
+
it 'returns a hash containing the tests result' do
|
19
|
+
output = load_phpunit_output('failing-json')
|
20
|
+
subject.parse_output(output).should == {
|
21
|
+
:tests => 2, :failures => 2,
|
22
|
+
:errors => 0, :pending => 0,
|
23
|
+
:duration => [0, "seconds"]
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when tests are skipped or incomplete' do
|
29
|
+
it 'returns a hash containing the tests result' do
|
30
|
+
output = load_phpunit_output('skipped_and_incomplete-json')
|
31
|
+
subject.parse_output(output).should == {
|
32
|
+
:tests => 3, :failures => 0,
|
33
|
+
:errors => 0, :pending => 3,
|
34
|
+
:duration => [0, "seconds"]
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when tests have mixed statuses' do
|
40
|
+
it 'returns a hash containing the tests result' do
|
41
|
+
output = load_phpunit_output('mixed-json')
|
42
|
+
subject.parse_output(output).should == {
|
43
|
+
:tests => 5, :failures => 1,
|
44
|
+
:errors => 1, :pending => 2,
|
45
|
+
:duration => [0, "seconds"]
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'multiple test classes' do
|
51
|
+
it 'retuns the correct total sum of tests ran' do
|
52
|
+
output = load_phpunit_output('multiple-test-cases-json')
|
53
|
+
subject.parse_output(output).should == {
|
54
|
+
:tests => 14, :failures => 4,
|
55
|
+
:errors => 1, :pending => 5,
|
56
|
+
:duration => [0, 'seconds']
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Guard::PHPUnit2::RealtimeRunner do
|
4
|
+
|
5
|
+
let(:formatter) { Guard::PHPUnit2::Formatter }
|
6
|
+
let(:logreader) { Guard::PHPUnit2::LogReader }
|
7
|
+
let(:notifier) { Guard::PHPUnit2::Notifier }
|
8
|
+
let(:ui) { Guard::UI }
|
9
|
+
|
10
|
+
describe '#run' do
|
11
|
+
before do
|
12
|
+
FileUtils.stub(:ln_s)
|
13
|
+
FileUtils.stub(:mkdir_p)
|
14
|
+
|
15
|
+
subject.stub(:execute_command)
|
16
|
+
subject.stub(:phpunit_exists?).and_return(true)
|
17
|
+
notifier.stub(:notify_results)
|
18
|
+
|
19
|
+
$?.stub(:success?).and_return(true)
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when passed an empty paths list' do
|
23
|
+
it 'returns false' do
|
24
|
+
subject.run([]).should be_false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
shared_examples_for 'paths list not empty' do
|
29
|
+
it 'checks that phpunit is installed' do
|
30
|
+
subject.should_receive(:phpunit_exists?)
|
31
|
+
subject.run( ['tests'] )
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'displays an error when phpunit is not installed' do
|
35
|
+
subject.stub(:phpunit_exists?).and_return(false)
|
36
|
+
ui.should_receive(:error).with('the provided php unit command is invalid or phpunit is not installed on your machine.', anything)
|
37
|
+
|
38
|
+
subject.run( ['tests'] )
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'notifies about running the tests' do
|
42
|
+
subject.should_receive(:notify_start).with( ['tests'], anything )
|
43
|
+
subject.run( ['tests'] )
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'runs phpunit tests' do
|
47
|
+
subject.should_receive(:execute_command).with(
|
48
|
+
%r{^phpunit .+$}
|
49
|
+
).and_return(true)
|
50
|
+
subject.run( ['tests'] )
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'runs phpunit tests with provided command' do
|
54
|
+
formatter_path = @project_path.join('lib', 'guard', 'phpunit', 'formatters', 'PHPUnit-Progress')
|
55
|
+
subject.should_receive(:execute_command).with(
|
56
|
+
%r{^/usr/local/bin/phpunit --include-path #{formatter_path} --printer PHPUnit_Extensions_Progress_ResultPrinter .+$}
|
57
|
+
).and_return(true)
|
58
|
+
subject.run( ['tests'] , {:command => '/usr/local/bin/phpunit'} )
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when PHPUnit executes the tests' do
|
62
|
+
it 'parses the tests log output' do
|
63
|
+
log = load_phpunit_output('passing-json')
|
64
|
+
subject.stub(:execute_phpunit).and_return(log)
|
65
|
+
|
66
|
+
logreader.should_receive(:parse_output).with(log)
|
67
|
+
|
68
|
+
subject.run( ['tests'] )
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'notifies about the tests output' do
|
72
|
+
log = load_phpunit_output('passing-json')
|
73
|
+
subject.stub(:execute_phpunit).and_return(log)
|
74
|
+
subject.should_receive(:notify_results).with(log, anything())
|
75
|
+
|
76
|
+
subject.run( ['tests'] )
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'notifies about the tests output even when they contain failures' do
|
80
|
+
$?.stub(:success? => false, :exitstatus => 1)
|
81
|
+
|
82
|
+
subject.stub(:execute_command)
|
83
|
+
subject.should_receive(:notify_results).with(anything(), anything())
|
84
|
+
|
85
|
+
subject.run( ['tests'] )
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'notifies about the tests output even when they contain errors' do
|
89
|
+
$?.stub(:success? => false, :exitstatus => 2)
|
90
|
+
|
91
|
+
subject.stub(:execute_command)
|
92
|
+
subject.should_receive(:notify_results).with(anything(), anything())
|
93
|
+
|
94
|
+
subject.run( ['tests'] )
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'does not notify about failures' do
|
98
|
+
subject.should_receive(:execute_command)
|
99
|
+
subject.should_not_receive(:notify_failure)
|
100
|
+
subject.run( ['tests'] )
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'when PHPUnit fails to execute' do
|
105
|
+
before do
|
106
|
+
$?.stub(:success? => false, :exitstatus => 255)
|
107
|
+
notifier.stub(:notify)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'notifies about the failure' do
|
111
|
+
subject.should_receive(:execute_command)
|
112
|
+
subject.should_receive(:notify_failure)
|
113
|
+
subject.run( ['tests'] )
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'does not notify about the tests output' do
|
117
|
+
subject.should_not_receive(:notify_results)
|
118
|
+
subject.run( ['tests'] )
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe 'options' do
|
123
|
+
describe ':cli' do
|
124
|
+
it 'runs with CLI options passed to PHPUnit' do
|
125
|
+
cli_options = '--colors --verbose'
|
126
|
+
subject.should_receive(:execute_command).with(
|
127
|
+
%r{^phpunit --include-path .* --printer .* #{cli_options} .+$}
|
128
|
+
).and_return(true)
|
129
|
+
subject.run( ['tests'], :cli => cli_options )
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe ':notification' do
|
134
|
+
it 'does not notify about tests output with notification option set to false' do
|
135
|
+
formatter.should_not_receive(:notify)
|
136
|
+
subject.run( ['tests'], :notification => false )
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context 'when passed one path' do
|
143
|
+
it_should_behave_like 'paths list not empty'
|
144
|
+
|
145
|
+
it 'should not create a test folder' do
|
146
|
+
Dir.should_not_receive(:mktmpdir)
|
147
|
+
subject.run( ['spec/fixtures/sampleTest.php'] )
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'when passed multiple paths' do
|
152
|
+
it_should_behave_like 'paths list not empty'
|
153
|
+
|
154
|
+
it 'creates a tests folder (tmpdir)' do
|
155
|
+
subject.should_receive(:create_tests_folder_for).with(instance_of(Array))
|
156
|
+
subject.stub(:execute_phpunit).and_return(load_phpunit_output('passing-json'))
|
157
|
+
subject.stub(:notify_results)
|
158
|
+
subject.run( ['spec/fixtures/sampleTest.php', 'spec/fixtures/emptyTest.php'] )
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'symlinks passed paths to the tests folder' do
|
162
|
+
subject.should_receive(:symlink_paths_to_tests_folder).with(anything(), anything())
|
163
|
+
subject.run( ['spec/fixtures/sampleTest.php', 'spec/fixtures/emptyTest.php'] )
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
data/spec/guard/phpunit2_spec.rb
CHANGED
@@ -27,6 +27,10 @@ describe Guard::PHPUnit2 do
|
|
27
27
|
it 'sets a default :notification option' do
|
28
28
|
subject.options[:notification].should be_true
|
29
29
|
end
|
30
|
+
|
31
|
+
it 'sets a default :realtime option' do
|
32
|
+
subject.options[:realtime].should be_false
|
33
|
+
end
|
30
34
|
end
|
31
35
|
|
32
36
|
context 'when other options are provided' do
|
@@ -35,7 +39,8 @@ describe Guard::PHPUnit2 do
|
|
35
39
|
:all_after_pass => false,
|
36
40
|
:keep_failed => false,
|
37
41
|
:cli => '--colors',
|
38
|
-
:tests_path => 'tests'
|
42
|
+
:tests_path => 'tests',
|
43
|
+
:realtime => true}) }
|
39
44
|
|
40
45
|
it 'sets :all_on_start with the provided option' do
|
41
46
|
subject.options[:all_on_start].should be_false
|
@@ -56,6 +61,10 @@ describe Guard::PHPUnit2 do
|
|
56
61
|
it 'sets :tests_path with the provided option' do
|
57
62
|
subject.options[:tests_path].should == 'tests'
|
58
63
|
end
|
64
|
+
|
65
|
+
it 'sets :realtime with the provided option' do
|
66
|
+
subject.options[:realtime].should be_true
|
67
|
+
end
|
59
68
|
end
|
60
69
|
|
61
70
|
it 'sets the tests path for the inspector' do
|
@@ -99,6 +108,25 @@ describe Guard::PHPUnit2 do
|
|
99
108
|
end
|
100
109
|
end
|
101
110
|
|
111
|
+
describe 'realtime handling' do
|
112
|
+
describe 'realtime endabled' do
|
113
|
+
let(:guard) { Guard::PHPUnit2.new(nil, {:realtime => true }) }
|
114
|
+
it 'should call run on the realtimerunner' do
|
115
|
+
Guard::PHPUnit2::RealtimeRunner.should_receive(:run).and_return(true)
|
116
|
+
guard.run_on_changes ['tests/firstTest.php']
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe 'realtime disabled' do
|
121
|
+
let(:guard) { Guard::PHPUnit2.new(nil, {:realtime => false }) }
|
122
|
+
|
123
|
+
it 'should call run on the Runner class' do
|
124
|
+
Guard::PHPUnit2::Runner.should_receive(:run).and_return(true)
|
125
|
+
guard.run_on_changes ['tests/firstTest.php']
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
102
130
|
describe '#run_on_changes' do
|
103
131
|
before do
|
104
132
|
inspector.stub(:clean).and_return { |paths| paths }
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-phpunit2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maher Sallam
|
@@ -12,9 +12,9 @@ bindir: bin
|
|
12
12
|
cert_chain:
|
13
13
|
- |
|
14
14
|
-----BEGIN CERTIFICATE-----
|
15
|
-
|
15
|
+
MIIDODCCAiCgAwIBAgIBAjANBgkqhkiG9w0BAQUFADBCMQ4wDAYDVQQDDAVyYW1v
|
16
16
|
bjEbMBkGCgmSJomT8ixkARkWC2NvZGVjcmFmdDYzMRMwEQYKCZImiZPyLGQBGRYD
|
17
|
-
|
17
|
+
Y29tMB4XDTE0MDQwMjEzMzEwOVoXDTE1MDQwMjEzMzEwOVowQjEOMAwGA1UEAwwF
|
18
18
|
cmFtb24xGzAZBgoJkiaJk/IsZAEZFgtjb2RlY3JhZnQ2MzETMBEGCgmSJomT8ixk
|
19
19
|
ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANMe6/bxj0lU
|
20
20
|
QJBEAPZg6YDvjo/by2I62ww7wUgd9Yh5gOFe0uxhrr4bOCRADhhC4icYow1NZ8Ju
|
@@ -22,17 +22,16 @@ cert_chain:
|
|
22
22
|
XBfffGikJEwclkpdr4mRgm4TaBzkZUF029axX6YM7G5AbBcYfbHwSss+fLsXB1t9
|
23
23
|
bU07BDLV6KSnFjn/6Gj9CrZpw3G0TCunTvB6UjcZIoBqXeWz6z9XJX+GhyaZGCjQ
|
24
24
|
R1rXqqEfSRwsG31ibcTTFrqtoyTkzmz33h5LbMZZdLoMpeEFggkY0cQBUY4sGYK/
|
25
|
-
|
26
|
-
BBYEFIcHXF/
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
7g4EOpFUXKG2E+5vow3VDEqcOhfQYvQ8UB3Of3FOp2o=
|
25
|
+
jrbnzdwgwtsCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
26
|
+
BBYEFIcHXF/pGBCu96efKVZ3eH10IgSxMA0GCSqGSIb3DQEBBQUAA4IBAQBVmXZf
|
27
|
+
1PL29cv73uxKHrIXMPIiUHwKW+8twzorMX+3BlYsQSq0OEOloHV4qHpEYtdOKTwt
|
28
|
+
FKqX3EPTy7HVQpeQjTJRo8qeqD5xMnJAFve6deF4wH5vTtjpF6BQBN7OEFSlyywK
|
29
|
+
q5TzllwektfgZuo6o6+TEZQRaTAuVioHFCyJ1SwmyNIHH5whXUlCWrurt7csbfnJ
|
30
|
+
J1k3vWJjQrItZ60kgoi2rBCPx7qAJG/lZ8UQoCMJMAAXGzarUrWvK6CKd2d1phth
|
31
|
+
tUGlQK5jGose4s/n5BjifxE3pKoirkrICQy813CvapcJDj5qAIFt3ZCEL/qiwrzY
|
32
|
+
VGMazdO/EkS6KnJc
|
34
33
|
-----END CERTIFICATE-----
|
35
|
-
date: 2014-
|
34
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
36
35
|
dependencies:
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
name: guard
|
@@ -173,20 +172,33 @@ files:
|
|
173
172
|
- lib/guard/phpunit2.rb
|
174
173
|
- lib/guard/phpunit2/formatter.rb
|
175
174
|
- lib/guard/phpunit2/inspector.rb
|
175
|
+
- lib/guard/phpunit2/logreader.rb
|
176
176
|
- lib/guard/phpunit2/notifier.rb
|
177
|
+
- lib/guard/phpunit2/realtime_runner.rb
|
177
178
|
- lib/guard/phpunit2/runner.rb
|
178
179
|
- lib/guard/phpunit2/templates/Guardfile
|
179
180
|
- lib/guard/phpunit2/version.rb
|
180
181
|
- spec/fixtures/emptyTest.php
|
182
|
+
- spec/fixtures/failureSampleTest.php
|
183
|
+
- spec/fixtures/mixedSampleTest.php
|
184
|
+
- spec/fixtures/passingSampleTest.php
|
181
185
|
- spec/fixtures/results/errors.txt
|
186
|
+
- spec/fixtures/results/failing-json.txt
|
182
187
|
- spec/fixtures/results/failing.txt
|
188
|
+
- spec/fixtures/results/mixed-json.txt
|
183
189
|
- spec/fixtures/results/mixed.txt
|
190
|
+
- spec/fixtures/results/multiple-test-cases-json.txt
|
191
|
+
- spec/fixtures/results/passing-json.txt
|
184
192
|
- spec/fixtures/results/passing.txt
|
193
|
+
- spec/fixtures/results/skipped_and_incomplete-json.txt
|
185
194
|
- spec/fixtures/results/skipped_and_incomplete.txt
|
186
195
|
- spec/fixtures/sampleTest.php
|
196
|
+
- spec/fixtures/skippedSampleTest.php
|
187
197
|
- spec/guard/phpunit2/formatter_spec.rb
|
188
198
|
- spec/guard/phpunit2/inspector_spec.rb
|
199
|
+
- spec/guard/phpunit2/logreader_spec.rb
|
189
200
|
- spec/guard/phpunit2/notifier_spec.rb
|
201
|
+
- spec/guard/phpunit2/realtime_runner_spec.rb
|
190
202
|
- spec/guard/phpunit2/runner_spec.rb
|
191
203
|
- spec/guard/phpunit2_spec.rb
|
192
204
|
- spec/spec_helper.rb
|
@@ -210,21 +222,32 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
222
|
version: 1.3.6
|
211
223
|
requirements: []
|
212
224
|
rubyforge_project: guard-phpunit2
|
213
|
-
rubygems_version: 2.2.
|
225
|
+
rubygems_version: 2.2.2
|
214
226
|
signing_key:
|
215
227
|
specification_version: 4
|
216
228
|
summary: Guard gem for PHPUnit
|
217
229
|
test_files:
|
218
230
|
- spec/fixtures/emptyTest.php
|
231
|
+
- spec/fixtures/failureSampleTest.php
|
232
|
+
- spec/fixtures/mixedSampleTest.php
|
233
|
+
- spec/fixtures/passingSampleTest.php
|
219
234
|
- spec/fixtures/results/errors.txt
|
235
|
+
- spec/fixtures/results/failing-json.txt
|
220
236
|
- spec/fixtures/results/failing.txt
|
237
|
+
- spec/fixtures/results/mixed-json.txt
|
221
238
|
- spec/fixtures/results/mixed.txt
|
239
|
+
- spec/fixtures/results/multiple-test-cases-json.txt
|
240
|
+
- spec/fixtures/results/passing-json.txt
|
222
241
|
- spec/fixtures/results/passing.txt
|
242
|
+
- spec/fixtures/results/skipped_and_incomplete-json.txt
|
223
243
|
- spec/fixtures/results/skipped_and_incomplete.txt
|
224
244
|
- spec/fixtures/sampleTest.php
|
245
|
+
- spec/fixtures/skippedSampleTest.php
|
225
246
|
- spec/guard/phpunit2/formatter_spec.rb
|
226
247
|
- spec/guard/phpunit2/inspector_spec.rb
|
248
|
+
- spec/guard/phpunit2/logreader_spec.rb
|
227
249
|
- spec/guard/phpunit2/notifier_spec.rb
|
250
|
+
- spec/guard/phpunit2/realtime_runner_spec.rb
|
228
251
|
- spec/guard/phpunit2/runner_spec.rb
|
229
252
|
- spec/guard/phpunit2_spec.rb
|
230
253
|
- spec/spec_helper.rb
|
metadata.gz.sig
CHANGED
Binary file
|