vinted-parallel_tests 0.13.3 → 1.7.0.1
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
- data/Readme.md +86 -47
- data/bin/parallel_cucumber +5 -1
- data/bin/parallel_rspec +5 -1
- data/bin/parallel_spinach +9 -0
- data/bin/parallel_test +5 -1
- data/lib/parallel_tests.rb +15 -2
- data/lib/parallel_tests/cli.rb +115 -35
- data/lib/parallel_tests/cucumber/failures_logger.rb +9 -7
- data/lib/parallel_tests/cucumber/runner.rb +16 -77
- data/lib/parallel_tests/cucumber/scenario_line_logger.rb +52 -0
- data/lib/parallel_tests/cucumber/scenarios.rb +34 -0
- data/lib/parallel_tests/{cucumber → gherkin}/io.rb +1 -1
- data/lib/parallel_tests/{cucumber/gherkin_listener.rb → gherkin/listener.rb} +11 -6
- data/lib/parallel_tests/gherkin/runner.rb +116 -0
- data/lib/parallel_tests/{cucumber → gherkin}/runtime_logger.rb +2 -2
- data/lib/parallel_tests/grouper.rb +34 -17
- data/lib/parallel_tests/rspec/failures_logger.rb +22 -14
- data/lib/parallel_tests/rspec/logger_base.rb +5 -1
- data/lib/parallel_tests/rspec/runner.rb +5 -4
- data/lib/parallel_tests/rspec/runtime_logger.rb +10 -5
- data/lib/parallel_tests/rspec/summary_logger.rb +11 -11
- data/lib/parallel_tests/spinach/runner.rb +19 -0
- data/lib/parallel_tests/tasks.rb +41 -18
- data/lib/parallel_tests/test/runner.rb +80 -28
- data/lib/parallel_tests/test/runtime_logger.rb +86 -55
- data/lib/parallel_tests/version.rb +1 -1
- metadata +18 -35
- data/.gitignore +0 -2
- data/.rspec +0 -2
- data/.travis.yml +0 -6
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -48
- data/Rakefile +0 -6
- data/ReadmeRails2.md +0 -48
- data/parallel_tests.gemspec +0 -14
- data/spec/integration_spec.rb +0 -285
- data/spec/parallel_tests/cli_spec.rb +0 -71
- data/spec/parallel_tests/cucumber/failure_logger_spec.rb +0 -43
- data/spec/parallel_tests/cucumber/gherkin_listener_spec.rb +0 -97
- data/spec/parallel_tests/cucumber/runner_spec.rb +0 -179
- data/spec/parallel_tests/grouper_spec.rb +0 -52
- data/spec/parallel_tests/rspec/failures_logger_spec.rb +0 -82
- data/spec/parallel_tests/rspec/runner_spec.rb +0 -187
- data/spec/parallel_tests/rspec/runtime_logger_spec.rb +0 -126
- data/spec/parallel_tests/rspec/summary_logger_spec.rb +0 -37
- data/spec/parallel_tests/tasks_spec.rb +0 -151
- data/spec/parallel_tests/test/runner_spec.rb +0 -413
- data/spec/parallel_tests/test/runtime_logger_spec.rb +0 -90
- data/spec/parallel_tests_spec.rb +0 -137
- data/spec/spec_helper.rb +0 -157
@@ -1,179 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "parallel_tests/cucumber/runner"
|
3
|
-
|
4
|
-
describe ParallelTests::Cucumber do
|
5
|
-
test_tests_in_groups(ParallelTests::Cucumber::Runner, 'features', ".feature")
|
6
|
-
|
7
|
-
describe :run_tests do
|
8
|
-
before do
|
9
|
-
ParallelTests.stub!(:bundler_enabled?).and_return false
|
10
|
-
File.stub!(:file?).with('.bundle/environment.rb').and_return false
|
11
|
-
File.stub!(:file?).with('script/cucumber').and_return true
|
12
|
-
end
|
13
|
-
|
14
|
-
def call(*args)
|
15
|
-
ParallelTests::Cucumber::Runner.run_tests(*args)
|
16
|
-
end
|
17
|
-
|
18
|
-
def should_run_with(regex)
|
19
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).with{|a,b,c,d| a =~ regex}
|
20
|
-
end
|
21
|
-
|
22
|
-
it "allows to override runner executable via PARALLEL_TESTS_EXECUTABLE" do
|
23
|
-
ENV['PARALLEL_TESTS_EXECUTABLE'] = 'script/custom_rspec'
|
24
|
-
should_run_with /script\/custom_rspec/
|
25
|
-
call(['xxx'],1,22,{})
|
26
|
-
ENV.delete('PARALLEL_TESTS_EXECUTABLE')
|
27
|
-
end
|
28
|
-
|
29
|
-
it "runs bundle exec cucumber when on bundler 0.9" do
|
30
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
31
|
-
should_run_with %r{bundle exec cucumber}
|
32
|
-
call(['xxx'],1,22,{})
|
33
|
-
end
|
34
|
-
|
35
|
-
it "runs script/cucumber when script/cucumber is found" do
|
36
|
-
should_run_with %r{script/cucumber}
|
37
|
-
call(['xxx'],1,22,{})
|
38
|
-
end
|
39
|
-
|
40
|
-
it "runs cucumber by default" do
|
41
|
-
File.stub!(:file?).with('script/cucumber').and_return false
|
42
|
-
should_run_with %r{^cucumber}
|
43
|
-
call(['xxx'],1,22,{})
|
44
|
-
end
|
45
|
-
|
46
|
-
it "uses bin/cucumber when present" do
|
47
|
-
File.stub(:exists?).with("bin/cucumber").and_return true
|
48
|
-
should_run_with %r{bin/cucumber}
|
49
|
-
call(['xxx'],1,22,{})
|
50
|
-
end
|
51
|
-
|
52
|
-
it "uses options passed in" do
|
53
|
-
should_run_with %r{script/cucumber .* -p default}
|
54
|
-
call(['xxx'],1,22,:test_options => '-p default')
|
55
|
-
end
|
56
|
-
|
57
|
-
it "sanitizes dangerous file names" do
|
58
|
-
should_run_with %r{xx\\ x}
|
59
|
-
call(['xx x'],1,22,{})
|
60
|
-
end
|
61
|
-
|
62
|
-
context "with parallel profile in config/cucumber.yml" do
|
63
|
-
before do
|
64
|
-
file_contents = 'parallel: -f progress'
|
65
|
-
Dir.stub(:glob).and_return ['config/cucumber.yml']
|
66
|
-
File.stub(:read).with('config/cucumber.yml').and_return file_contents
|
67
|
-
end
|
68
|
-
|
69
|
-
it "uses parallel profile" do
|
70
|
-
should_run_with %r{script/cucumber .* foo bar --profile parallel xxx}
|
71
|
-
call(['xxx'],1,22, :test_options => 'foo bar')
|
72
|
-
end
|
73
|
-
|
74
|
-
it "uses given profile via --profile" do
|
75
|
-
should_run_with %r{script/cucumber .* --profile foo xxx$}
|
76
|
-
call(['xxx'],1,22, :test_options => '--profile foo')
|
77
|
-
end
|
78
|
-
|
79
|
-
it "uses given profile via -p" do
|
80
|
-
should_run_with %r{script/cucumber .* -p foo xxx$}
|
81
|
-
call(['xxx'],1,22, :test_options => '-p foo')
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
it "does not use parallel profile if config/cucumber.yml does not contain it" do
|
86
|
-
file_contents = 'blob: -f progress'
|
87
|
-
should_run_with %r{script/cucumber .* foo bar}
|
88
|
-
Dir.should_receive(:glob).and_return ['config/cucumber.yml']
|
89
|
-
File.should_receive(:read).with('config/cucumber.yml').and_return file_contents
|
90
|
-
call(['xxx'],1,22,:test_options => 'foo bar')
|
91
|
-
end
|
92
|
-
|
93
|
-
it "does not use the parallel profile if config/cucumber.yml does not exist" do
|
94
|
-
should_run_with %r{script/cucumber} # TODO this test looks useless...
|
95
|
-
Dir.should_receive(:glob).and_return []
|
96
|
-
call(['xxx'],1,22,{})
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe :line_is_result? do
|
101
|
-
it "should match lines with only one scenario" do
|
102
|
-
line = "1 scenario (1 failed)"
|
103
|
-
ParallelTests::Cucumber::Runner.line_is_result?(line).should be_true
|
104
|
-
end
|
105
|
-
|
106
|
-
it "should match lines with multiple scenarios" do
|
107
|
-
line = "2 scenarios (1 failed, 1 passed)"
|
108
|
-
ParallelTests::Cucumber::Runner.line_is_result?(line).should be_true
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should match lines with only one step" do
|
112
|
-
line = "1 step (1 failed)"
|
113
|
-
ParallelTests::Cucumber::Runner.line_is_result?(line).should be_true
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should match lines with multiple steps" do
|
117
|
-
line = "5 steps (1 failed, 4 passed)"
|
118
|
-
ParallelTests::Cucumber::Runner.line_is_result?(line).should be_true
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should not match other lines" do
|
122
|
-
line = ' And I should have "2" emails # features/step_definitions/user_steps.rb:25'
|
123
|
-
ParallelTests::Cucumber::Runner.line_is_result?(line).should be_false
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe :find_results do
|
128
|
-
it "finds multiple results in test output" do
|
129
|
-
output = <<EOF
|
130
|
-
And I should not see "/en/" # features/step_definitions/webrat_steps.rb:87
|
131
|
-
|
132
|
-
7 scenarios (3 failed, 4 passed)
|
133
|
-
33 steps (3 failed, 2 skipped, 28 passed)
|
134
|
-
/apps/rs/features/signup.feature:2
|
135
|
-
Given I am on "/" # features/step_definitions/common_steps.rb:12
|
136
|
-
When I click "register" # features/step_definitions/common_steps.rb:6
|
137
|
-
And I should have "2" emails # features/step_definitions/user_steps.rb:25
|
138
|
-
|
139
|
-
4 scenarios (4 passed)
|
140
|
-
40 steps (40 passed)
|
141
|
-
|
142
|
-
And I should not see "foo" # features/step_definitions/webrat_steps.rb:87
|
143
|
-
|
144
|
-
1 scenario (1 passed)
|
145
|
-
1 step (1 passed)
|
146
|
-
|
147
|
-
EOF
|
148
|
-
ParallelTests::Cucumber::Runner.find_results(output).should == ["7 scenarios (3 failed, 4 passed)", "33 steps (3 failed, 2 skipped, 28 passed)", "4 scenarios (4 passed)", "40 steps (40 passed)", "1 scenario (1 passed)", "1 step (1 passed)"]
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe :summarize_results do
|
153
|
-
def call(*args)
|
154
|
-
ParallelTests::Cucumber::Runner.summarize_results(*args)
|
155
|
-
end
|
156
|
-
|
157
|
-
it "sums up results for scenarios and steps separately from each other" do
|
158
|
-
results = ["7 scenarios (3 failed, 4 passed)", "33 steps (3 failed, 2 skipped, 28 passed)", "4 scenarios (4 passed)",
|
159
|
-
"40 steps (40 passed)", "1 scenario (1 passed)", "1 step (1 passed)"]
|
160
|
-
call(results).should == "12 scenarios (3 failed, 9 passed)\n74 steps (3 failed, 2 skipped, 69 passed)"
|
161
|
-
end
|
162
|
-
|
163
|
-
it "adds same results with plurals" do
|
164
|
-
results = ["1 scenario (1 passed)", "2 steps (2 passed)",
|
165
|
-
"2 scenarios (2 passed)", "7 steps (7 passed)"]
|
166
|
-
call(results).should == "3 scenarios (3 passed)\n9 steps (9 passed)"
|
167
|
-
end
|
168
|
-
|
169
|
-
it "adds non-similar results" do
|
170
|
-
results = ["1 scenario (1 passed)", "1 step (1 passed)",
|
171
|
-
"2 scenarios (1 failed, 1 pending)", "2 steps (1 failed, 1 pending)"]
|
172
|
-
call(results).should == "3 scenarios (1 failed, 1 pending, 1 passed)\n3 steps (1 failed, 1 pending, 1 passed)"
|
173
|
-
end
|
174
|
-
|
175
|
-
it "does not pluralize 1" do
|
176
|
-
call(["1 scenario (1 passed)", "1 step (1 passed)"]).should == "1 scenario (1 passed)\n1 step (1 passed)"
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'parallel_tests/grouper'
|
3
|
-
require 'tmpdir'
|
4
|
-
|
5
|
-
describe ParallelTests::Grouper do
|
6
|
-
describe :by_steps do
|
7
|
-
def write(file, content)
|
8
|
-
File.open(file,'w'){|f| f.write content }
|
9
|
-
end
|
10
|
-
|
11
|
-
it "sorts features by steps" do
|
12
|
-
tmpdir = nil
|
13
|
-
result = Dir.mktmpdir do |dir|
|
14
|
-
tmpdir = dir
|
15
|
-
write("#{dir}/a.feature", "Feature: xxx\n Scenario: xxx\n Given something")
|
16
|
-
write("#{dir}/b.feature", "Feature: xxx\n Scenario: xxx\n Given something\n Scenario: yyy\n Given something")
|
17
|
-
write("#{dir}/c.feature", "Feature: xxx\n Scenario: xxx\n Given something")
|
18
|
-
ParallelTests::Grouper.by_steps(["#{dir}/a.feature", "#{dir}/b.feature", "#{dir}/c.feature"], 2, {})
|
19
|
-
end
|
20
|
-
|
21
|
-
# testing inside mktmpdir is always green
|
22
|
-
result.should =~ [
|
23
|
-
["#{tmpdir}/a.feature", "#{tmpdir}/c.feature"],
|
24
|
-
["#{tmpdir}/b.feature"]
|
25
|
-
]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe :in_even_groups_by_size do
|
30
|
-
let(:files_with_size){ {"1" => 1, "2" => 2, "3" => 3, "4" => 4, "5" => 5} }
|
31
|
-
|
32
|
-
def call(num_groups)
|
33
|
-
ParallelTests::Grouper.in_even_groups_by_size(files_with_size, num_groups)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "groups 1 by 1 for same groups as size" do
|
37
|
-
call(5).should == [["5"], ["4"], ["3"], ["2"], ["1"]]
|
38
|
-
end
|
39
|
-
|
40
|
-
it "groups into even groups" do
|
41
|
-
call(2).should == [["1", "2", "5"], ["3", "4"]]
|
42
|
-
end
|
43
|
-
|
44
|
-
it "groups into a single group" do
|
45
|
-
call(1).should == [["1", "2", "3", "4", "5"]]
|
46
|
-
end
|
47
|
-
|
48
|
-
it "adds empty groups if there are more groups than feature files" do
|
49
|
-
call(6).should == [["5"], ["4"], ["3"], ["2"], ["1"], []]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ParallelTests::RSpec::FailuresLogger do
|
4
|
-
def silence_warnings
|
5
|
-
old_verbose, $VERBOSE = $VERBOSE, nil
|
6
|
-
yield
|
7
|
-
ensure
|
8
|
-
$VERBOSE = old_verbose
|
9
|
-
end
|
10
|
-
|
11
|
-
before do
|
12
|
-
@output = OutputLogger.new([])
|
13
|
-
@example1 = mock( 'example', :location => "#{Dir.pwd}/spec/path/to/example:123", :full_description => 'should do stuff', :description => 'd' )
|
14
|
-
@example2 = mock( 'example', :location => "#{Dir.pwd}/spec/path/to/example2:456", :full_description => 'should do other stuff', :description => 'd')
|
15
|
-
@exception1 = mock( :to_s => 'exception', :backtrace => [ '/path/to/error/line:33' ] )
|
16
|
-
@failure1 = mock( 'example', :location => "#{Dir.pwd}/example:123", :header => 'header', :exception => @exception1 )
|
17
|
-
@logger = ParallelTests::RSpec::FailuresLogger.new(@output)
|
18
|
-
end
|
19
|
-
|
20
|
-
after do
|
21
|
-
silence_warnings{ ParallelTests::RSpec::LoggerBase::RSPEC_1 = false }
|
22
|
-
end
|
23
|
-
|
24
|
-
def clean_output
|
25
|
-
@output.output.join("\n").gsub(/\e\[\d+m/,'')
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should produce a list of command lines for failing examples" do
|
29
|
-
@logger.example_failed @example1
|
30
|
-
@logger.example_failed @example2
|
31
|
-
|
32
|
-
@logger.dump_failures
|
33
|
-
@logger.dump_summary(1,2,3,4)
|
34
|
-
|
35
|
-
clean_output.should =~ /^rspec .*? should do stuff/
|
36
|
-
clean_output.should =~ /^rspec .*? should do other stuff/
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should invoke spec for rspec 1" do
|
40
|
-
silence_warnings{ ParallelTests::RSpec::LoggerBase::RSPEC_1 = true }
|
41
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
42
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec-core").and_return "Could not find gem 'rspec-core'."
|
43
|
-
@logger.example_failed @example1
|
44
|
-
|
45
|
-
@logger.dump_failures
|
46
|
-
@logger.dump_summary(1,2,3,4)
|
47
|
-
|
48
|
-
clean_output.should =~ /^bundle exec spec/
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should invoke rspec for rspec 2" do
|
52
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
53
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec").and_return "/foo/bar/rspec-core-2.0.2"
|
54
|
-
@logger.example_failed @example1
|
55
|
-
|
56
|
-
@logger.dump_failures
|
57
|
-
@logger.dump_summary(1,2,3,4)
|
58
|
-
|
59
|
-
clean_output.should =~ /^rspec/
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should return relative paths" do
|
63
|
-
@logger.example_failed @example1
|
64
|
-
@logger.example_failed @example2
|
65
|
-
|
66
|
-
@logger.dump_failures
|
67
|
-
@logger.dump_summary(1,2,3,4)
|
68
|
-
|
69
|
-
clean_output.should =~ %r(\./spec/path/to/example:123)
|
70
|
-
clean_output.should =~ %r(\./spec/path/to/example2:456)
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
# should not longer be a problem since its using native rspec methods
|
75
|
-
xit "should not log examples without location" do
|
76
|
-
example = mock('example', :location => 'bla', :full_description => 'before :all')
|
77
|
-
@logger.example_failed example
|
78
|
-
@logger.dump_failures
|
79
|
-
@logger.dump_summary(1,2,3,4)
|
80
|
-
clean_output.should == ''
|
81
|
-
end
|
82
|
-
end
|
@@ -1,187 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "parallel_tests/rspec/runner"
|
3
|
-
|
4
|
-
describe ParallelTests::RSpec::Runner do
|
5
|
-
test_tests_in_groups(ParallelTests::RSpec::Runner, 'spec', '_spec.rb')
|
6
|
-
|
7
|
-
describe :run_tests do
|
8
|
-
before do
|
9
|
-
File.stub!(:file?).with('script/spec').and_return false
|
10
|
-
File.stub!(:file?).with('spec/spec.opts').and_return false
|
11
|
-
File.stub!(:file?).with('spec/parallel_spec.opts').and_return false
|
12
|
-
File.stub!(:file?).with('.rspec_parallel').and_return false
|
13
|
-
ParallelTests.stub!(:bundler_enabled?).and_return false
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(*args)
|
17
|
-
ParallelTests::RSpec::Runner.run_tests(*args)
|
18
|
-
end
|
19
|
-
|
20
|
-
def should_run_with(regex)
|
21
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).with{|a,b,c,d| a =~ regex}
|
22
|
-
end
|
23
|
-
|
24
|
-
def should_not_run_with(regex)
|
25
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).with{|a,b,c,d| a !~ regex}
|
26
|
-
end
|
27
|
-
|
28
|
-
it "runs command using nice when specifed" do
|
29
|
-
ParallelTests::Test::Runner.should_receive(:execute_command_and_capture_output).with{|a,b,c| b =~ %r{^nice rspec}}
|
30
|
-
call('xxx', 1, 22, :nice => true)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "runs with color when called from cmdline" do
|
34
|
-
should_run_with %r{ --tty}
|
35
|
-
$stdout.should_receive(:tty?).and_return true
|
36
|
-
call('xxx', 1, 22, {})
|
37
|
-
end
|
38
|
-
|
39
|
-
it "runs without color when not called from cmdline" do
|
40
|
-
should_not_run_with %r{ --tty}
|
41
|
-
$stdout.should_receive(:tty?).and_return false
|
42
|
-
call('xxx', 1, 22, {})
|
43
|
-
end
|
44
|
-
|
45
|
-
it "runs with color for rspec 1 when called for the cmdline" do
|
46
|
-
File.should_receive(:file?).with('script/spec').and_return true
|
47
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).with { |a, b, c, d| d[:env] == {"RSPEC_COLOR" => "1"} }
|
48
|
-
$stdout.should_receive(:tty?).and_return true
|
49
|
-
call('xxx', 1, 22, {})
|
50
|
-
end
|
51
|
-
|
52
|
-
it "runs without color for rspec 1 when not called for the cmdline" do
|
53
|
-
File.should_receive(:file?).with('script/spec').and_return true
|
54
|
-
ParallelTests::Test::Runner.should_receive(:execute_command).with { |a, b, c, d| d[:env] == {} }
|
55
|
-
$stdout.should_receive(:tty?).and_return false
|
56
|
-
call('xxx', 1, 22, {})
|
57
|
-
end
|
58
|
-
|
59
|
-
it "run bundle exec spec when on bundler rspec 1" do
|
60
|
-
File.stub!(:file?).with('script/spec').and_return false
|
61
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
62
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec-core").and_return "Could not find gem 'rspec-core' in bundler."
|
63
|
-
should_run_with %r{bundle exec spec}
|
64
|
-
call('xxx', 1, 22, {})
|
65
|
-
end
|
66
|
-
|
67
|
-
it "run bundle exec rspec when on bundler rspec 2" do
|
68
|
-
File.stub!(:file?).with('script/spec').and_return false
|
69
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
70
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec-core").and_return "/foo/bar/rspec-core-2.0.2"
|
71
|
-
should_run_with %r{bundle exec rspec}
|
72
|
-
call('xxx', 1, 22, {})
|
73
|
-
end
|
74
|
-
|
75
|
-
it "runs script/spec when script/spec can be found" do
|
76
|
-
File.should_receive(:file?).with('script/spec').and_return true
|
77
|
-
should_run_with %r{script/spec}
|
78
|
-
call('xxx' ,1, 22, {})
|
79
|
-
end
|
80
|
-
|
81
|
-
it "runs spec when script/spec cannot be found" do
|
82
|
-
File.stub!(:file?).with('script/spec').and_return false
|
83
|
-
should_not_run_with %r{ script/spec}
|
84
|
-
call('xxx', 1, 22, {})
|
85
|
-
end
|
86
|
-
|
87
|
-
it "uses bin/rspec when present" do
|
88
|
-
File.stub(:exists?).with('bin/rspec').and_return true
|
89
|
-
should_run_with %r{bin/rspec}
|
90
|
-
call('xxx', 1, 22, {})
|
91
|
-
end
|
92
|
-
|
93
|
-
it "uses no -O when no opts where found" do
|
94
|
-
File.stub!(:file?).with('spec/spec.opts').and_return false
|
95
|
-
should_not_run_with %r{spec/spec.opts}
|
96
|
-
call('xxx', 1, 22, {})
|
97
|
-
end
|
98
|
-
|
99
|
-
it "uses -O spec/spec.opts when found (with script/spec)" do
|
100
|
-
File.stub!(:file?).with('script/spec').and_return true
|
101
|
-
File.stub!(:file?).with('spec/spec.opts').and_return true
|
102
|
-
should_run_with %r{script/spec\s+-O spec/spec.opts}
|
103
|
-
call('xxx', 1, 22, {})
|
104
|
-
end
|
105
|
-
|
106
|
-
it "uses -O spec/parallel_spec.opts when found (with script/spec)" do
|
107
|
-
File.stub!(:file?).with('script/spec').and_return true
|
108
|
-
File.should_receive(:file?).with('spec/parallel_spec.opts').and_return true
|
109
|
-
should_run_with %r{script/spec\s+-O spec/parallel_spec.opts}
|
110
|
-
call('xxx', 1, 22, {})
|
111
|
-
end
|
112
|
-
|
113
|
-
it "uses -O .rspec_parallel when found (with script/spec)" do
|
114
|
-
File.stub!(:file?).with('script/spec').and_return true
|
115
|
-
File.should_receive(:file?).with('.rspec_parallel').and_return true
|
116
|
-
should_run_with %r{script/spec\s+-O .rspec_parallel}
|
117
|
-
call('xxx', 1, 22, {})
|
118
|
-
end
|
119
|
-
|
120
|
-
it "uses -O spec/parallel_spec.opts with rspec1" do
|
121
|
-
File.should_receive(:file?).with('spec/parallel_spec.opts').and_return true
|
122
|
-
|
123
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
124
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec-core").and_return "Could not find gem 'rspec-core'."
|
125
|
-
|
126
|
-
should_run_with %r{spec\s+-O spec/parallel_spec.opts}
|
127
|
-
call('xxx', 1, 22, {})
|
128
|
-
end
|
129
|
-
|
130
|
-
it "uses -O spec/parallel_spec.opts with rspec2" do
|
131
|
-
pending if RUBY_PLATFORM == "java" # FIXME not sure why, but fails on travis
|
132
|
-
File.should_receive(:file?).with('spec/parallel_spec.opts').and_return true
|
133
|
-
|
134
|
-
ParallelTests.stub!(:bundler_enabled?).and_return true
|
135
|
-
ParallelTests::RSpec::Runner.stub!(:run).with("bundle show rspec-core").and_return "/foo/bar/rspec-core-2.4.2"
|
136
|
-
|
137
|
-
should_run_with %r{rspec\s+--color --tty -O spec/parallel_spec.opts}
|
138
|
-
call('xxx', 1, 22, {})
|
139
|
-
end
|
140
|
-
|
141
|
-
it "uses options passed in" do
|
142
|
-
should_run_with %r{rspec -f n}
|
143
|
-
call('xxx', 1, 22, :test_options => '-f n')
|
144
|
-
end
|
145
|
-
|
146
|
-
it "returns the output" do
|
147
|
-
ParallelTests::RSpec::Runner.should_receive(:execute_command).and_return :x => 1
|
148
|
-
call('xxx', 1, 22, {}).should == {:x => 1}
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe :find_results do
|
153
|
-
def call(*args)
|
154
|
-
ParallelTests::RSpec::Runner.find_results(*args)
|
155
|
-
end
|
156
|
-
|
157
|
-
it "finds multiple results in spec output" do
|
158
|
-
output = "
|
159
|
-
....F...
|
160
|
-
..
|
161
|
-
failute fsddsfsd
|
162
|
-
...
|
163
|
-
ff.**..
|
164
|
-
0 examples, 0 failures, 0 pending
|
165
|
-
ff.**..
|
166
|
-
1 example, 1 failure, 1 pending
|
167
|
-
"
|
168
|
-
|
169
|
-
call(output).should == ['0 examples, 0 failures, 0 pending','1 example, 1 failure, 1 pending']
|
170
|
-
end
|
171
|
-
|
172
|
-
it "is robust against scrambeled output" do
|
173
|
-
output = "
|
174
|
-
....F...
|
175
|
-
..
|
176
|
-
failute fsddsfsd
|
177
|
-
...
|
178
|
-
ff.**..
|
179
|
-
0 exFampl*es, 0 failures, 0 pend.ing
|
180
|
-
ff.**..
|
181
|
-
1 exampF.les, 1 failures, 1 pend.ing
|
182
|
-
"
|
183
|
-
|
184
|
-
call(output).should == ['0 examples, 0 failures, 0 pending','1 examples, 1 failures, 1 pending']
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|