rspec-core 2.8.0.rc1 → 2.8.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/License.txt +24 -0
- data/README.md +197 -37
- data/features/command_line/format_option.feature +3 -3
- data/features/command_line/init.feature +18 -0
- data/features/example_groups/shared_examples.feature +1 -1
- data/features/hooks/around_hooks.feature +4 -4
- data/features/pending/pending_examples.feature +5 -5
- data/features/support/env.rb +8 -1
- data/lib/autotest/rspec2.rb +2 -6
- data/lib/rspec/core.rb +48 -158
- data/lib/rspec/core/backward_compatibility.rb +2 -0
- data/lib/rspec/core/command_line.rb +4 -0
- data/lib/rspec/core/configuration.rb +201 -106
- data/lib/rspec/core/configuration_options.rb +2 -1
- data/lib/rspec/core/deprecation.rb +2 -3
- data/lib/rspec/core/drb_options.rb +69 -58
- data/lib/rspec/core/dsl.rb +12 -0
- data/lib/rspec/core/example.rb +53 -18
- data/lib/rspec/core/example_group.rb +144 -54
- data/lib/rspec/core/extensions.rb +4 -4
- data/lib/rspec/core/extensions/instance_eval_with_args.rb +5 -0
- data/lib/rspec/core/extensions/kernel.rb +1 -1
- data/lib/rspec/core/extensions/module_eval_with_args.rb +4 -0
- data/lib/rspec/core/extensions/ordered.rb +7 -2
- data/lib/rspec/core/filter_manager.rb +69 -36
- data/lib/rspec/core/formatters/base_text_formatter.rb +1 -1
- data/lib/rspec/core/formatters/html_formatter.rb +10 -4
- data/lib/rspec/core/hooks.rb +93 -34
- data/lib/rspec/core/let.rb +62 -61
- data/lib/rspec/core/metadata.rb +103 -80
- data/lib/rspec/core/metadata_hash_builder.rb +4 -0
- data/lib/rspec/core/option_parser.rb +42 -44
- data/lib/rspec/core/pending.rb +25 -3
- data/lib/rspec/core/project_initializer.rb +62 -0
- data/lib/rspec/core/rake_task.rb +7 -13
- data/lib/rspec/core/runner.rb +2 -2
- data/lib/rspec/core/shared_context.rb +1 -1
- data/lib/rspec/core/shared_example_group.rb +11 -5
- data/lib/rspec/core/subject.rb +3 -3
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/monkey.rb +1 -1
- data/lib/rspec/monkey/spork/test_framework/rspec.rb +2 -0
- data/spec/command_line/order_spec.rb +19 -13
- data/spec/rspec/core/command_line_spec.rb +1 -5
- data/spec/rspec/core/configuration_options_spec.rb +22 -27
- data/spec/rspec/core/configuration_spec.rb +32 -14
- data/spec/rspec/core/drb_command_line_spec.rb +20 -37
- data/spec/rspec/core/drb_options_spec.rb +51 -3
- data/spec/rspec/core/example_group_spec.rb +101 -84
- data/spec/rspec/core/example_spec.rb +14 -0
- data/spec/rspec/core/filter_manager_spec.rb +114 -33
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +17 -69
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +14 -4
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +14 -4
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +14 -4
- data/spec/rspec/core/formatters/html_formatter_spec.rb +1 -1
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +20 -72
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +24 -14
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -19
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +29 -19
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +1 -2
- data/spec/rspec/core/metadata_spec.rb +77 -45
- data/spec/rspec/core/option_parser_spec.rb +5 -0
- data/spec/rspec/core/pending_example_spec.rb +44 -12
- data/spec/rspec/core/project_initializer_spec.rb +130 -0
- data/spec/rspec/core/rake_task_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/support/matchers.rb +2 -12
- metadata +18 -16
- data/features/command_line/configure.feature +0 -22
- data/lib/rspec/core/command_line_configuration.rb +0 -62
- data/lib/rspec/core/errors.rb +0 -13
- data/spec/rspec/core/command_line_configuration_spec.rb +0 -26
data/lib/rspec/core/version.rb
CHANGED
data/lib/rspec/monkey.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
require_rspec 'monkey/spork/test_framework/rspec.rb'
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# TODO (2011-05-08) - remove this as soon as spork 0.9.0 is released
|
2
2
|
if defined?(Spork::TestFramework::RSpec)
|
3
|
+
# @private
|
3
4
|
class Spork::TestFramework::RSpec < Spork::TestFramework
|
5
|
+
# @private
|
4
6
|
def run_tests(argv, err, out)
|
5
7
|
::RSpec::Core::CommandLine.new(argv).run(err, out)
|
6
8
|
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'command line', :ui do
|
4
|
+
let(:stderr) { StringIO.new }
|
5
|
+
let(:stdout) { StringIO.new }
|
6
|
+
|
4
7
|
before :all do
|
5
8
|
write_file 'spec/order_spec.rb', """
|
6
9
|
describe 'group 1' do
|
@@ -54,9 +57,11 @@ describe 'command line', :ui do
|
|
54
57
|
|
55
58
|
describe '--order rand' do
|
56
59
|
it 'runs the examples and groups in a different order each time' do
|
57
|
-
|
60
|
+
run_command 'tmp/aruba/spec/order_spec.rb --order rand -f doc'
|
61
|
+
RSpec.configuration.seed = srand && srand # reset seed in same process
|
62
|
+
run_command 'tmp/aruba/spec/order_spec.rb --order rand -f doc'
|
58
63
|
|
59
|
-
|
64
|
+
stdout.string.should match(/Randomized with seed \d+/)
|
60
65
|
|
61
66
|
top_level_groups {|first_run, second_run| first_run.should_not eq(second_run)}
|
62
67
|
nested_groups {|first_run, second_run| first_run.should_not eq(second_run)}
|
@@ -67,9 +72,9 @@ describe 'command line', :ui do
|
|
67
72
|
|
68
73
|
describe '--order rand:SEED' do
|
69
74
|
it 'runs the examples and groups in the same order each time' do
|
70
|
-
2.times { run_command '
|
75
|
+
2.times { run_command 'tmp/aruba/spec/order_spec.rb --order rand:123 -f doc' }
|
71
76
|
|
72
|
-
|
77
|
+
stdout.string.should match(/Randomized with seed 123/)
|
73
78
|
|
74
79
|
top_level_groups {|first_run, second_run| first_run.should eq(second_run)}
|
75
80
|
nested_groups {|first_run, second_run| first_run.should eq(second_run)}
|
@@ -80,9 +85,9 @@ describe 'command line', :ui do
|
|
80
85
|
|
81
86
|
describe '--seed SEED' do
|
82
87
|
it "forces '--order rand' and runs the examples and groups in the same order each time" do
|
83
|
-
2.times { run_command '
|
88
|
+
2.times { run_command 'tmp/aruba/spec/order_spec.rb --seed 123 -f doc' }
|
84
89
|
|
85
|
-
|
90
|
+
stdout.string.should match(/Randomized with seed \d+/)
|
86
91
|
|
87
92
|
top_level_groups {|first_run, second_run| first_run.should eq(second_run)}
|
88
93
|
nested_groups {|first_run, second_run| first_run.should eq(second_run)}
|
@@ -95,16 +100,18 @@ describe 'command line', :ui do
|
|
95
100
|
it "overrides --order rand with --order default" do
|
96
101
|
write_file '.rspec', '--order rand'
|
97
102
|
|
98
|
-
run_command '
|
103
|
+
run_command 'tmp/aruba/spec/order_spec.rb --order default -f doc'
|
99
104
|
|
100
|
-
|
105
|
+
stdout.string.should_not match(/Randomized/)
|
101
106
|
|
102
|
-
|
107
|
+
stdout.string.should match(
|
108
|
+
/group 1.*group 1 example 1.*group 1 example 2.*group 1-1.*group 1-2.*group 2.*/m
|
109
|
+
)
|
103
110
|
end
|
104
111
|
end
|
105
112
|
|
106
113
|
def examples(group)
|
107
|
-
yield split_in_half(
|
114
|
+
yield split_in_half(stdout.string.scan(/^\s+#{group} example.*$/))
|
108
115
|
end
|
109
116
|
|
110
117
|
def top_level_groups
|
@@ -116,7 +123,7 @@ describe 'command line', :ui do
|
|
116
123
|
end
|
117
124
|
|
118
125
|
def example_groups_at_level(level)
|
119
|
-
split_in_half(
|
126
|
+
split_in_half(stdout.string.scan(/^\s{#{level*2}}group.*$/))
|
120
127
|
end
|
121
128
|
|
122
129
|
def split_in_half(array)
|
@@ -125,7 +132,6 @@ describe 'command line', :ui do
|
|
125
132
|
end
|
126
133
|
|
127
134
|
def run_command(cmd)
|
128
|
-
|
129
|
-
run_simple cmd, false
|
135
|
+
RSpec::Core::Runner.run(cmd.split, stderr, stdout)
|
130
136
|
end
|
131
137
|
end
|
@@ -22,19 +22,16 @@ module RSpec::Core
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns 0 if spec passes" do
|
25
|
-
err, out = StringIO.new, StringIO.new
|
26
25
|
result = command_line([passing_spec_filename]).run(err, out)
|
27
26
|
result.should be(0)
|
28
27
|
end
|
29
28
|
|
30
29
|
it "returns 1 if spec fails" do
|
31
|
-
err, out = StringIO.new, StringIO.new
|
32
30
|
result = command_line([failing_spec_filename]).run(err, out)
|
33
31
|
result.should be(1)
|
34
32
|
end
|
35
33
|
|
36
34
|
it "returns 2 if spec fails and --failure-exit-code is 2" do
|
37
|
-
err, out = StringIO.new, StringIO.new
|
38
35
|
result = command_line([failing_spec_filename, "--failure-exit-code", "2"]).run(err, out)
|
39
36
|
result.should be(2)
|
40
37
|
end
|
@@ -95,8 +92,7 @@ module RSpec::Core
|
|
95
92
|
# this is necessary to ensure that color works correctly on windows
|
96
93
|
config.should_receive(:error_stream=).ordered
|
97
94
|
config.should_receive(:output_stream=).ordered
|
98
|
-
config.should_receive(:force).
|
99
|
-
config.should_receive(:force).with(:color => true).ordered
|
95
|
+
config.should_receive(:force).any_number_of_times.ordered
|
100
96
|
command_line.run(err, out) rescue nil
|
101
97
|
end
|
102
98
|
|
@@ -48,6 +48,13 @@ describe RSpec::Core::ConfigurationOptions do
|
|
48
48
|
opts.configure(config)
|
49
49
|
end
|
50
50
|
|
51
|
+
it "assigns inclusion_filter" do
|
52
|
+
opts = config_options_object(*%w[--tag awesome])
|
53
|
+
config = RSpec::Core::Configuration.new
|
54
|
+
opts.configure(config)
|
55
|
+
config.inclusion_filter.should have_key(:awesome)
|
56
|
+
end
|
57
|
+
|
51
58
|
it "merges the :exclusion_filter option with the default exclusion_filter" do
|
52
59
|
opts = config_options_object(*%w[--tag ~slow])
|
53
60
|
config = RSpec::Core::Configuration.new
|
@@ -62,16 +69,14 @@ describe RSpec::Core::ConfigurationOptions do
|
|
62
69
|
opts.configure(config)
|
63
70
|
end
|
64
71
|
|
65
|
-
it "assigns filter" do
|
66
|
-
pending
|
67
|
-
end
|
68
|
-
|
69
72
|
[
|
70
73
|
["--failure-exit-code", "3", :failure_exit_code, 3 ],
|
71
74
|
["--pattern", "foo/bar", :pattern, "foo/bar"],
|
72
75
|
["--failure-exit-code", "37", :failure_exit_code, 37],
|
73
76
|
["--default_path", "behavior", :default_path, "behavior"],
|
74
77
|
["--drb", nil, :drb, true],
|
78
|
+
["--order", "rand", :order, "rand"],
|
79
|
+
["--seed", "37", :order, "rand:37"],
|
75
80
|
["--drb-port", "37", :drb_port, 37],
|
76
81
|
["--backtrace", nil, :full_backtrace, true],
|
77
82
|
["--profile", nil, :profile_examples, true],
|
@@ -88,20 +93,6 @@ describe RSpec::Core::ConfigurationOptions do
|
|
88
93
|
end
|
89
94
|
end
|
90
95
|
|
91
|
-
it "sets order directly" do
|
92
|
-
opts = config_options_object("--order", "rand")
|
93
|
-
config = RSpec::Core::Configuration.new
|
94
|
-
opts.configure(config)
|
95
|
-
config.order.should eq("rand")
|
96
|
-
end
|
97
|
-
|
98
|
-
it "sets seed directly" do
|
99
|
-
opts = config_options_object("--seed", "37")
|
100
|
-
config = RSpec::Core::Configuration.new
|
101
|
-
opts.configure(config)
|
102
|
-
config.seed.should eq(37)
|
103
|
-
end
|
104
|
-
|
105
96
|
it "sets debug directly" do
|
106
97
|
opts = config_options_object("--debug")
|
107
98
|
config = RSpec::Core::Configuration.new
|
@@ -152,9 +143,9 @@ describe RSpec::Core::ConfigurationOptions do
|
|
152
143
|
|
153
144
|
describe "--format, -f" do
|
154
145
|
it "sets :formatter" do
|
155
|
-
|
156
|
-
|
157
|
-
|
146
|
+
[['--format', 'd'], ['-f', 'd'], '-fd'].each do |args|
|
147
|
+
parse_options(*args).should include(:formatters => [['d']])
|
148
|
+
end
|
158
149
|
end
|
159
150
|
|
160
151
|
example "can accept a class name" do
|
@@ -283,7 +274,9 @@ describe RSpec::Core::ConfigurationOptions do
|
|
283
274
|
|
284
275
|
describe "files_or_directories_to_run" do
|
285
276
|
it "parses files from '-c file.rb dir/file.rb'" do
|
286
|
-
parse_options("-c", "file.rb", "dir/file.rb").should include(
|
277
|
+
parse_options("-c", "file.rb", "dir/file.rb").should include(
|
278
|
+
:files_or_directories_to_run => ["file.rb", "dir/file.rb"]
|
279
|
+
)
|
287
280
|
end
|
288
281
|
|
289
282
|
it "parses dir from 'dir'" do
|
@@ -291,17 +284,15 @@ describe RSpec::Core::ConfigurationOptions do
|
|
291
284
|
end
|
292
285
|
|
293
286
|
it "parses dir and files from 'spec/file1_spec.rb, spec/file2_spec.rb'" do
|
294
|
-
parse_options("dir", "spec/file1_spec.rb", "spec/file2_spec.rb").should include(
|
287
|
+
parse_options("dir", "spec/file1_spec.rb", "spec/file2_spec.rb").should include(
|
288
|
+
:files_or_directories_to_run => ["dir", "spec/file1_spec.rb", "spec/file2_spec.rb"]
|
289
|
+
)
|
295
290
|
end
|
296
291
|
|
297
292
|
it "provides no files or directories if spec directory does not exist" do
|
298
293
|
FileTest.stub(:directory?).with("spec").and_return false
|
299
294
|
parse_options().should include(:files_or_directories_to_run => [])
|
300
295
|
end
|
301
|
-
|
302
|
-
it "parses dir and files from 'spec/file1_spec.rb, spec/file2_spec.rb'" do
|
303
|
-
parse_options("dir", "spec/file1_spec.rb", "spec/file2_spec.rb").should include(:files_or_directories_to_run => ["dir", "spec/file1_spec.rb", "spec/file2_spec.rb"])
|
304
|
-
end
|
305
296
|
end
|
306
297
|
|
307
298
|
describe "default_path" do
|
@@ -315,6 +306,10 @@ describe RSpec::Core::ConfigurationOptions do
|
|
315
306
|
end
|
316
307
|
|
317
308
|
describe "sources: ~/.rspec, ./.rspec, custom, CLI, and SPEC_OPTS" do
|
309
|
+
before(:each) do
|
310
|
+
FileUtils.mkpath(File.expand_path("~"))
|
311
|
+
end
|
312
|
+
|
318
313
|
it "merges global, local, SPEC_OPTS, and CLI" do
|
319
314
|
File.open("./.rspec", "w") {|f| f << "--line 37"}
|
320
315
|
File.open("~/.rspec", "w") {|f| f << "--color"}
|
@@ -649,13 +649,6 @@ module RSpec::Core
|
|
649
649
|
config.inclusion_filter[:foo].should be(true)
|
650
650
|
config.inclusion_filter[:bar].should be(false)
|
651
651
|
end
|
652
|
-
|
653
|
-
it "gets overrided by forced options" do
|
654
|
-
config.force_exclude :foo => true
|
655
|
-
config.filter_run_including :foo => true
|
656
|
-
config.inclusion_filter.should eq({})
|
657
|
-
end
|
658
|
-
|
659
652
|
end
|
660
653
|
|
661
654
|
describe "#filter_run_excluding" do
|
@@ -684,13 +677,6 @@ module RSpec::Core
|
|
684
677
|
config.exclusion_filter[:foo].should be(true)
|
685
678
|
config.exclusion_filter[:bar].should be(false)
|
686
679
|
end
|
687
|
-
|
688
|
-
it "gets overrided by forced options" do
|
689
|
-
config.exclusion_filter.clear
|
690
|
-
config.force_include :foo => true
|
691
|
-
config.filter_run_excluding :foo => true
|
692
|
-
config.exclusion_filter.should eq({})
|
693
|
-
end
|
694
680
|
end
|
695
681
|
|
696
682
|
describe "#inclusion_filter" do
|
@@ -1035,6 +1021,38 @@ module RSpec::Core
|
|
1035
1021
|
end
|
1036
1022
|
end
|
1037
1023
|
|
1024
|
+
describe "#force" do
|
1025
|
+
it "forces order" do
|
1026
|
+
config.force :order => "default"
|
1027
|
+
config.order = "rand"
|
1028
|
+
config.order.should eq("default")
|
1029
|
+
end
|
1030
|
+
|
1031
|
+
it "forces order and seed with :order => 'rand:37'" do
|
1032
|
+
config.force :order => "rand:37"
|
1033
|
+
config.order = "default"
|
1034
|
+
config.order.should eq("rand")
|
1035
|
+
config.seed.should eq(37)
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
it "forces order and seed with :seed => '37'" do
|
1039
|
+
config.force :seed => "37"
|
1040
|
+
config.order = "default"
|
1041
|
+
config.seed.should eq(37)
|
1042
|
+
config.order.should eq("rand")
|
1043
|
+
end
|
1044
|
+
|
1045
|
+
it "forces 'false' value" do
|
1046
|
+
config.add_setting :custom_option
|
1047
|
+
config.custom_option = true
|
1048
|
+
config.custom_option?.should be_true
|
1049
|
+
config.force :custom_option => false
|
1050
|
+
config.custom_option?.should be_false
|
1051
|
+
config.custom_option = true
|
1052
|
+
config.custom_option?.should be_false
|
1053
|
+
end
|
1054
|
+
end
|
1055
|
+
|
1038
1056
|
describe '#seed' do
|
1039
1057
|
it 'returns the seed as an int' do
|
1040
1058
|
config.seed = '123'
|
@@ -7,23 +7,19 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
7
7
|
|
8
8
|
include_context "spec files"
|
9
9
|
|
10
|
-
def command_line(args)
|
11
|
-
RSpec::Core::DRbCommandLine.new(config_options(args))
|
10
|
+
def command_line(*args)
|
11
|
+
RSpec::Core::DRbCommandLine.new(config_options(*args))
|
12
12
|
end
|
13
13
|
|
14
|
-
def config_options(
|
15
|
-
options = RSpec::Core::ConfigurationOptions.new(
|
14
|
+
def config_options(*args)
|
15
|
+
options = RSpec::Core::ConfigurationOptions.new(args)
|
16
16
|
options.parse_options
|
17
17
|
options
|
18
18
|
end
|
19
19
|
|
20
|
-
def run_with(args)
|
21
|
-
command_line(args).run(err, out)
|
22
|
-
end
|
23
|
-
|
24
20
|
context "without server running" do
|
25
21
|
it "raises an error" do
|
26
|
-
lambda {
|
22
|
+
lambda { command_line.run(err, out) }.should raise_error(DRb::DRbConnError)
|
27
23
|
end
|
28
24
|
end
|
29
25
|
|
@@ -41,24 +37,23 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
41
37
|
context "without RSPEC_DRB environment variable set" do
|
42
38
|
it "defaults to 8989" do
|
43
39
|
with_RSPEC_DRB_set_to(nil) do
|
44
|
-
command_line
|
40
|
+
command_line.drb_port.should eq(8989)
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
44
|
it "sets the DRb port" do
|
49
45
|
with_RSPEC_DRB_set_to(nil) do
|
50
|
-
command_line(
|
51
|
-
command_line(
|
46
|
+
command_line("--drb-port", "1234").drb_port.should eq(1234)
|
47
|
+
command_line("--drb-port", "5678").drb_port.should eq(5678)
|
52
48
|
end
|
53
49
|
end
|
54
50
|
end
|
55
51
|
|
56
52
|
context "with RSPEC_DRB environment variable set" do
|
57
|
-
|
58
53
|
context "without config variable set" do
|
59
54
|
it "uses RSPEC_DRB value" do
|
60
55
|
with_RSPEC_DRB_set_to('9000') do
|
61
|
-
command_line
|
56
|
+
command_line.drb_port.should eq("9000")
|
62
57
|
end
|
63
58
|
end
|
64
59
|
end
|
@@ -66,7 +61,7 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
66
61
|
context "and config variable set" do
|
67
62
|
it "uses configured value" do
|
68
63
|
with_RSPEC_DRB_set_to('9000') do
|
69
|
-
command_line(
|
64
|
+
command_line(*%w[--drb-port 5678]).drb_port.should eq(5678)
|
70
65
|
end
|
71
66
|
end
|
72
67
|
end
|
@@ -74,7 +69,7 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
74
69
|
end
|
75
70
|
|
76
71
|
context "with server running" do
|
77
|
-
class
|
72
|
+
class SimpleDRbSpecServer
|
78
73
|
def self.run(argv, err, out)
|
79
74
|
options = RSpec::Core::ConfigurationOptions.new(argv)
|
80
75
|
options.parse_options
|
@@ -83,9 +78,9 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
83
78
|
end
|
84
79
|
|
85
80
|
before(:all) do
|
86
|
-
@drb_port = 8990
|
81
|
+
@drb_port = '8990'
|
87
82
|
@drb_example_file_counter = 0
|
88
|
-
DRb::start_service("druby://127.0.0.1:#{@drb_port}",
|
83
|
+
DRb::start_service("druby://127.0.0.1:#{@drb_port}", SimpleDRbSpecServer)
|
89
84
|
end
|
90
85
|
|
91
86
|
after(:all) do
|
@@ -93,32 +88,20 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
93
88
|
end
|
94
89
|
|
95
90
|
it "returns 0 if spec passes" do
|
96
|
-
|
97
|
-
result = command_line(["--drb-port", @drb_port.to_s, passing_spec_filename]).run(err, out)
|
91
|
+
result = command_line("--drb-port", @drb_port, passing_spec_filename).run(err, out)
|
98
92
|
result.should be(0)
|
99
93
|
end
|
100
94
|
|
101
|
-
it "returns 1 if spec
|
102
|
-
|
103
|
-
result = command_line(["--drb-port", @drb_port.to_s, failing_spec_filename]).run(err, out)
|
95
|
+
it "returns 1 if spec fails" do
|
96
|
+
result = command_line("--drb-port", @drb_port, failing_spec_filename).run(err, out)
|
104
97
|
result.should be(1)
|
105
98
|
end
|
106
99
|
|
107
|
-
|
108
|
-
|
100
|
+
it "outputs colorized text when running with --colour option" do
|
101
|
+
pending "figure out a way to tell the output to say it's tty"
|
102
|
+
command_line(failing_spec_filename, "--color", "--drb-port", @drb_port).run(err, out)
|
109
103
|
out.rewind
|
110
|
-
out.read
|
111
|
-
end
|
112
|
-
|
113
|
-
it "outputs green colorized text when running with --colour option" do
|
114
|
-
pending "figure out a way to properly sandbox this"
|
115
|
-
run_spec_via_druby.should =~ /\e\[32m/m
|
116
|
-
end
|
117
|
-
|
118
|
-
it "outputs red colorized text when running with -c option" do
|
119
|
-
pending "figure out a way to properly sandbox this"
|
120
|
-
run_spec_via_druby.should =~ /\e\[31m/m
|
104
|
+
out.read.should =~ /\e\[31m/m
|
121
105
|
end
|
122
106
|
end
|
123
|
-
|
124
107
|
end
|
@@ -3,15 +3,20 @@ require "spec_helper"
|
|
3
3
|
describe RSpec::Core::DrbOptions do
|
4
4
|
include ConfigOptionsHelper
|
5
5
|
|
6
|
-
# TODO ensure all options are output
|
7
6
|
describe "#drb_argv" do
|
8
7
|
it "preserves extra arguments" do
|
9
8
|
File.stub(:exist?) { false }
|
10
9
|
config_options_object(*%w[ a --drb b --color c ]).drb_argv.should =~ %w[ --color a b c ]
|
11
10
|
end
|
12
11
|
|
13
|
-
|
14
|
-
|
12
|
+
%w(--color --fail-fast --profile --backtrace --tty).each do |option|
|
13
|
+
it "includes #{option}" do
|
14
|
+
config_options_object("#{option}").drb_argv.should include("#{option}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "includes --failure-exit-code" do
|
19
|
+
config_options_object(*%w[--failure-exit-code 2]).drb_argv.should include("--failure-exit-code", "2")
|
15
20
|
end
|
16
21
|
|
17
22
|
it "includes --options" do
|
@@ -97,6 +102,49 @@ describe RSpec::Core::DrbOptions do
|
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
105
|
+
context "with --out" do
|
106
|
+
it "combines with formatters" do
|
107
|
+
coo = config_options_object(*%w[--format h --out report.html])
|
108
|
+
coo.drb_argv.should eq(%w[--format h --out report.html])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "with --line_number" do
|
113
|
+
it "includes --line_number" do
|
114
|
+
config_options_object(*%w[--line_number 35]).drb_argv.should eq(%w[--line_number 35])
|
115
|
+
end
|
116
|
+
|
117
|
+
it "includes multiple lines" do
|
118
|
+
config_options_object(*%w[-l 90 -l 4 -l 55]).drb_argv.should eq(
|
119
|
+
%w[--line_number 90 --line_number 4 --line_number 55]
|
120
|
+
)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context "with -I libs" do
|
125
|
+
it "includes -I" do
|
126
|
+
config_options_object(*%w[-I a_dir]).drb_argv.should eq(%w[-I a_dir])
|
127
|
+
end
|
128
|
+
|
129
|
+
it "includes multiple paths" do
|
130
|
+
config_options_object(*%w[-I dir_1 -I dir_2 -I dir_3]).drb_argv.should eq(
|
131
|
+
%w[-I dir_1 -I dir_2 -I dir_3]
|
132
|
+
)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "with --require" do
|
137
|
+
it "includes --require" do
|
138
|
+
config_options_object(*%w[--require a_path]).drb_argv.should eq(%w[--require a_path])
|
139
|
+
end
|
140
|
+
|
141
|
+
it "includes multiple paths" do
|
142
|
+
config_options_object(*%w[--require dir/ --require file.rb]).drb_argv.should eq(
|
143
|
+
%w[--require dir/ --require file.rb]
|
144
|
+
)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
100
148
|
context "--drb specified in ARGV" do
|
101
149
|
it "renders all the original arguments except --drb" do
|
102
150
|
config_options_object(*%w[ --drb --color --format s --example pattern --line_number 1 --profile --backtrace -I path/a -I path/b --require path/c --require path/d]).
|