rspec-core 2.5.1 → 2.6.0
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.
- data/.travis.yml +7 -0
- data/Gemfile +12 -14
- data/README.md +4 -1
- data/Rakefile +29 -12
- data/cucumber.yml +1 -1
- data/features/.nav +15 -9
- data/features/Autotest.md +31 -7
- data/features/Changelog.md +46 -3
- data/features/Upgrade.md +35 -2
- data/features/command_line/README.md +22 -0
- data/features/command_line/configure.feature +2 -2
- data/features/command_line/example_name_option.feature +10 -10
- data/features/command_line/exit_status.feature +4 -4
- data/features/command_line/format_option.feature +4 -4
- data/features/command_line/line_number_appended_to_path.feature +11 -11
- data/features/command_line/line_number_option.feature +2 -2
- data/features/command_line/rake_task.feature +3 -3
- data/features/command_line/tag.feature +30 -14
- data/features/configuration/alias_example_to.feature +48 -0
- data/features/configuration/custom_settings.feature +3 -3
- data/features/configuration/fail_fast.feature +3 -3
- data/features/configuration/read_options_from_file.feature +4 -4
- data/features/example_groups/basic_structure.feature +11 -15
- data/features/example_groups/shared_context.feature +74 -0
- data/features/example_groups/shared_example_group.feature +21 -17
- data/features/expectation_framework_integration/configure_expectation_framework.feature +15 -4
- data/features/filtering/exclusion_filters.feature +28 -4
- data/features/filtering/{implicit_filters.feature → if_and_unless.feature} +9 -7
- data/features/filtering/inclusion_filters.feature +26 -3
- data/features/filtering/run_all_when_everything_filtered.feature +2 -2
- data/features/formatters/custom_formatter.feature +1 -1
- data/features/formatters/text_formatter.feature +43 -0
- data/features/helper_methods/arbitrary_methods.feature +2 -2
- data/features/helper_methods/let.feature +2 -2
- data/features/helper_methods/modules.feature +149 -0
- data/features/hooks/around_hooks.feature +18 -11
- data/features/hooks/before_and_after_hooks.feature +15 -19
- data/features/hooks/filtering.feature +160 -124
- data/features/metadata/current_example.feature +17 -0
- data/features/metadata/described_class.feature +2 -2
- data/features/metadata/user_defined.feature +111 -0
- data/features/mock_framework_integration/use_any_framework.feature +1 -1
- data/features/mock_framework_integration/use_flexmock.feature +83 -10
- data/features/mock_framework_integration/use_mocha.feature +84 -10
- data/features/mock_framework_integration/use_rr.feature +85 -10
- data/features/mock_framework_integration/use_rspec.feature +84 -10
- data/features/pending/pending_examples.feature +8 -8
- data/features/spec_files/arbitrary_file_suffix.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +11 -1
- data/features/subject/attribute_of_subject.feature +24 -4
- data/features/subject/explicit_subject.feature +5 -5
- data/features/subject/implicit_receiver.feature +2 -2
- data/features/subject/implicit_subject.feature +2 -2
- data/features/support/env.rb +6 -1
- data/lib/rspec/core/backward_compatibility.rb +12 -2
- data/lib/rspec/core/command_line.rb +2 -5
- data/lib/rspec/core/configuration.rb +70 -38
- data/lib/rspec/core/configuration_options.rb +6 -23
- data/lib/rspec/core/drb_command_line.rb +5 -11
- data/lib/rspec/core/example.rb +29 -21
- data/lib/rspec/core/example_group.rb +40 -8
- data/lib/rspec/core/extensions/object.rb +0 -1
- data/lib/rspec/core/formatters/base_formatter.rb +6 -0
- data/lib/rspec/core/formatters/base_text_formatter.rb +1 -1
- data/lib/rspec/core/formatters/helpers.rb +0 -4
- data/lib/rspec/core/hooks.rb +14 -4
- data/lib/rspec/core/metadata.rb +1 -1
- data/lib/rspec/core/metadata_hash_builder.rb +93 -0
- data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
- data/lib/rspec/core/mocking/with_mocha.rb +2 -0
- data/lib/rspec/core/mocking/with_rr.rb +2 -0
- data/lib/rspec/core/mocking/with_rspec.rb +3 -1
- data/lib/rspec/core/option_parser.rb +9 -2
- data/lib/rspec/core/pending.rb +10 -3
- data/lib/rspec/core/reporter.rb +2 -2
- data/lib/rspec/core/runner.rb +38 -13
- data/lib/rspec/core/shared_example_group.rb +18 -4
- data/lib/rspec/core/subject.rb +4 -6
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +70 -18
- data/lib/rspec/core.rb +29 -0
- data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
- data/rspec-core.gemspec +3 -5
- data/spec/autotest/failed_results_re_spec.rb +2 -2
- data/spec/rspec/core/command_line_spec.rb +36 -2
- data/spec/rspec/core/configuration_spec.rb +150 -70
- data/spec/rspec/core/deprecations_spec.rb +21 -0
- data/spec/rspec/core/drb_command_line_spec.rb +21 -56
- data/spec/rspec/core/example_group_spec.rb +213 -56
- data/spec/rspec/core/example_spec.rb +110 -0
- data/spec/rspec/core/formatters/base_formatter_spec.rb +23 -2
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +9 -0
- data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +8 -10
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.1.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +5 -5
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -1
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +8 -10
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +5 -5
- data/spec/rspec/core/hooks_spec.rb +86 -0
- data/spec/rspec/core/metadata_spec.rb +7 -7
- data/spec/rspec/core/option_parser_spec.rb +26 -15
- data/spec/rspec/core/pending_example_spec.rb +12 -51
- data/spec/rspec/core/reporter_spec.rb +19 -3
- data/spec/rspec/core/resources/formatter_specs.rb +7 -1
- data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
- data/spec/rspec/core/runner_spec.rb +42 -10
- data/spec/rspec/core/shared_example_group_spec.rb +57 -21
- data/spec/rspec/core/subject_spec.rb +32 -11
- data/spec/rspec/core/world_spec.rb +147 -15
- data/spec/rspec/core_spec.rb +28 -0
- data/spec/spec_helper.rb +22 -2
- data/spec/support/matchers.rb +44 -13
- data/spec/support/shared_example_groups.rb +41 -0
- data/spec/support/spec_files.rb +44 -0
- data/spec.txt +1126 -0
- metadata +35 -16
- data/spec/ruby_forker.rb +0 -13
|
@@ -5,7 +5,7 @@ module RSpec::Core
|
|
|
5
5
|
|
|
6
6
|
describe Configuration do
|
|
7
7
|
|
|
8
|
-
let(:config) {
|
|
8
|
+
let(:config) { Configuration.new }
|
|
9
9
|
|
|
10
10
|
describe "#load_spec_files" do
|
|
11
11
|
|
|
@@ -30,6 +30,17 @@ module RSpec::Core
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
describe "#treat_symbols_as_metadata_keys_with_true_values?" do
|
|
34
|
+
it 'defaults to false' do
|
|
35
|
+
config.treat_symbols_as_metadata_keys_with_true_values?.should be_false
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'can be set to true' do
|
|
39
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
40
|
+
config.treat_symbols_as_metadata_keys_with_true_values?.should be_true
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
33
44
|
describe "#mock_framework" do
|
|
34
45
|
it "defaults to :rspec" do
|
|
35
46
|
config.should_receive(:require).with('rspec/core/mocking/with_rspec')
|
|
@@ -100,16 +111,46 @@ module RSpec::Core
|
|
|
100
111
|
end
|
|
101
112
|
end
|
|
102
113
|
|
|
103
|
-
|
|
114
|
+
describe "#expecting_with_rspec?" do
|
|
115
|
+
before(:each) do
|
|
116
|
+
# prevent minitest assertions from being required and included,
|
|
117
|
+
# as that causes problems in some of our specs.
|
|
118
|
+
config.stub(:require)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "returns false by default" do
|
|
122
|
+
config.should_not be_expecting_with_rspec
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "returns true when `expect_with :rspec` has been configured" do
|
|
126
|
+
config.expect_with :rspec
|
|
127
|
+
config.should be_expecting_with_rspec
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it "returns true when `expect_with :rspec, :stdlib` has been configured" do
|
|
131
|
+
config.expect_with :rspec, :stdlib
|
|
132
|
+
config.should be_expecting_with_rspec
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "returns true when `expect_with :stdlib, :rspec` has been configured" do
|
|
136
|
+
config.expect_with :stdlib, :rspec
|
|
137
|
+
config.should be_expecting_with_rspec
|
|
138
|
+
end
|
|
104
139
|
|
|
140
|
+
it "returns false when `expect_with :stdlib` has been configured" do
|
|
141
|
+
config.expect_with :stdlib
|
|
142
|
+
config.should_not be_expecting_with_rspec
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
describe "#files_to_run" do
|
|
105
147
|
it "loads files not following pattern if named explicitly" do
|
|
106
148
|
file = "./spec/rspec/core/resources/a_bar.rb"
|
|
107
149
|
config.files_or_directories_to_run = file
|
|
108
150
|
config.files_to_run.should == [file]
|
|
109
151
|
end
|
|
110
152
|
|
|
111
|
-
|
|
112
|
-
|
|
153
|
+
context "with default pattern" do
|
|
113
154
|
it "loads files named _spec.rb" do
|
|
114
155
|
dir = "./spec/rspec/core/resources"
|
|
115
156
|
config.files_or_directories_to_run = dir
|
|
@@ -121,80 +162,70 @@ module RSpec::Core
|
|
|
121
162
|
config.files_or_directories_to_run = file
|
|
122
163
|
config.files_to_run.should == [file]
|
|
123
164
|
end
|
|
124
|
-
|
|
125
165
|
end
|
|
166
|
+
end
|
|
126
167
|
|
|
127
|
-
|
|
168
|
+
%w[pattern= filename_pattern=].each do |setter|
|
|
169
|
+
describe "##{setter}" do
|
|
170
|
+
context "with single pattern" do
|
|
171
|
+
before { config.send(setter, "**/*_foo.rb") }
|
|
172
|
+
it "loads files following pattern" do
|
|
173
|
+
file = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb")
|
|
174
|
+
config.files_or_directories_to_run = file
|
|
175
|
+
config.files_to_run.should include(file)
|
|
176
|
+
end
|
|
128
177
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
178
|
+
it "loads files in directories following pattern" do
|
|
179
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
|
180
|
+
config.files_or_directories_to_run = dir
|
|
181
|
+
config.files_to_run.should include("#{dir}/a_foo.rb")
|
|
182
|
+
end
|
|
132
183
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
184
|
+
it "does not load files in directories not following pattern" do
|
|
185
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
|
186
|
+
config.files_or_directories_to_run = dir
|
|
187
|
+
config.files_to_run.should_not include("#{dir}/a_bar.rb")
|
|
188
|
+
end
|
|
137
189
|
end
|
|
138
190
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
191
|
+
context "with multiple patterns" do
|
|
192
|
+
it "supports comma separated values" do
|
|
193
|
+
config.send(setter, "**/*_foo.rb,**/*_bar.rb")
|
|
194
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
|
195
|
+
config.files_or_directories_to_run = dir
|
|
196
|
+
config.files_to_run.should include("#{dir}/a_foo.rb")
|
|
197
|
+
config.files_to_run.should include("#{dir}/a_bar.rb")
|
|
198
|
+
end
|
|
144
199
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
200
|
+
it "supports comma separated values with spaces" do
|
|
201
|
+
config.send(setter, "**/*_foo.rb, **/*_bar.rb")
|
|
202
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
|
203
|
+
config.files_or_directories_to_run = dir
|
|
204
|
+
config.files_to_run.should include("#{dir}/a_foo.rb")
|
|
205
|
+
config.files_to_run.should include("#{dir}/a_bar.rb")
|
|
206
|
+
end
|
|
149
207
|
end
|
|
150
|
-
|
|
151
208
|
end
|
|
209
|
+
end
|
|
152
210
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
it "supports comma separated values" do
|
|
160
|
-
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
|
161
|
-
config.files_or_directories_to_run = dir
|
|
162
|
-
config.files_to_run.should include("#{dir}/a_foo.rb")
|
|
163
|
-
config.files_to_run.should include("#{dir}/a_bar.rb")
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
it "supports comma separated values with spaces" do
|
|
167
|
-
dir = File.expand_path(File.dirname(__FILE__) + "/resources")
|
|
168
|
-
config.files_or_directories_to_run = dir
|
|
169
|
-
config.files_to_run.should include("#{dir}/a_foo.rb")
|
|
170
|
-
config.files_to_run.should include("#{dir}/a_bar.rb")
|
|
171
|
-
end
|
|
172
|
-
|
|
211
|
+
describe "path with line number" do
|
|
212
|
+
it "assigns the line number as the filter" do
|
|
213
|
+
config.files_or_directories_to_run = "path/to/a_spec.rb:37"
|
|
214
|
+
config.filter.should == {:line_number => 37}
|
|
173
215
|
end
|
|
216
|
+
end
|
|
174
217
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
end
|
|
181
|
-
|
|
218
|
+
context "with full_description" do
|
|
219
|
+
it "overrides :focused" do
|
|
220
|
+
config.filter_run :focused => true
|
|
221
|
+
config.full_description = "foo"
|
|
222
|
+
config.filter.should_not have_key(:focused)
|
|
182
223
|
end
|
|
183
224
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
config.full_description = "foo"
|
|
188
|
-
config.filter.should_not have_key(:focused)
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
it "assigns the example name as the filter on description" do
|
|
192
|
-
config.full_description = "foo"
|
|
193
|
-
config.filter.should == {:full_description => /foo/}
|
|
194
|
-
end
|
|
195
|
-
|
|
225
|
+
it "assigns the example name as the filter on description" do
|
|
226
|
+
config.full_description = "foo"
|
|
227
|
+
config.filter.should == {:full_description => /foo/}
|
|
196
228
|
end
|
|
197
|
-
|
|
198
229
|
end
|
|
199
230
|
|
|
200
231
|
describe "#include" do
|
|
@@ -205,6 +236,13 @@ module RSpec::Core
|
|
|
205
236
|
end
|
|
206
237
|
end
|
|
207
238
|
|
|
239
|
+
it_behaves_like "metadata hash builder" do
|
|
240
|
+
def metadata_hash(*args)
|
|
241
|
+
config.include(InstanceLevelMethods, *args)
|
|
242
|
+
config.include_or_extend_modules.last.last
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
208
246
|
context "with no filter" do
|
|
209
247
|
it "includes the given module into each example group" do
|
|
210
248
|
RSpec.configure do |c|
|
|
@@ -238,6 +276,13 @@ module RSpec::Core
|
|
|
238
276
|
end
|
|
239
277
|
end
|
|
240
278
|
|
|
279
|
+
it_behaves_like "metadata hash builder" do
|
|
280
|
+
def metadata_hash(*args)
|
|
281
|
+
config.extend(ThatThingISentYou, *args)
|
|
282
|
+
config.include_or_extend_modules.last.last
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
241
286
|
it "extends the given module into each matching example group" do
|
|
242
287
|
RSpec.configure do |c|
|
|
243
288
|
c.extend(ThatThingISentYou, :magic_key => :extend)
|
|
@@ -249,7 +294,7 @@ module RSpec::Core
|
|
|
249
294
|
|
|
250
295
|
end
|
|
251
296
|
|
|
252
|
-
describe "run_all_when_everything_filtered?" do
|
|
297
|
+
describe "#run_all_when_everything_filtered?" do
|
|
253
298
|
|
|
254
299
|
it "defaults to false" do
|
|
255
300
|
config.run_all_when_everything_filtered?.should be_false
|
|
@@ -350,14 +395,14 @@ module RSpec::Core
|
|
|
350
395
|
end
|
|
351
396
|
end
|
|
352
397
|
|
|
353
|
-
describe 'formatter=' do
|
|
398
|
+
describe '#formatter=' do
|
|
354
399
|
it "delegates to add_formatter (better API for user-facing configuration)" do
|
|
355
400
|
config.should_receive(:add_formatter).with('these','options')
|
|
356
401
|
config.add_formatter('these','options')
|
|
357
402
|
end
|
|
358
403
|
end
|
|
359
404
|
|
|
360
|
-
describe "add_formatter" do
|
|
405
|
+
describe "#add_formatter" do
|
|
361
406
|
|
|
362
407
|
it "adds to the list of formatters" do
|
|
363
408
|
config.add_formatter :documentation
|
|
@@ -421,6 +466,13 @@ module RSpec::Core
|
|
|
421
466
|
end
|
|
422
467
|
|
|
423
468
|
describe "#filter_run" do
|
|
469
|
+
it_behaves_like "metadata hash builder" do
|
|
470
|
+
def metadata_hash(*args)
|
|
471
|
+
config.filter_run *args
|
|
472
|
+
config.filter
|
|
473
|
+
end
|
|
474
|
+
end
|
|
475
|
+
|
|
424
476
|
it "sets the filter" do
|
|
425
477
|
config.filter_run :focus => true
|
|
426
478
|
config.filter[:focus].should == true
|
|
@@ -454,6 +506,13 @@ module RSpec::Core
|
|
|
454
506
|
end
|
|
455
507
|
|
|
456
508
|
describe "#filter_run_excluding" do
|
|
509
|
+
it_behaves_like "metadata hash builder" do
|
|
510
|
+
def metadata_hash(*args)
|
|
511
|
+
config.filter_run_excluding *args
|
|
512
|
+
config.exclusion_filter
|
|
513
|
+
end
|
|
514
|
+
end
|
|
515
|
+
|
|
457
516
|
it "sets the filter" do
|
|
458
517
|
config.filter_run_excluding :slow => true
|
|
459
518
|
config.exclusion_filter[:slow].should == true
|
|
@@ -502,7 +561,7 @@ module RSpec::Core
|
|
|
502
561
|
end
|
|
503
562
|
end
|
|
504
563
|
|
|
505
|
-
describe "line_number=" do
|
|
564
|
+
describe "#line_number=" do
|
|
506
565
|
before { config.stub(:warn) }
|
|
507
566
|
|
|
508
567
|
it "sets the line number" do
|
|
@@ -524,9 +583,18 @@ module RSpec::Core
|
|
|
524
583
|
end
|
|
525
584
|
|
|
526
585
|
describe "#full_backtrace=" do
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
586
|
+
context "given true" do
|
|
587
|
+
it "clears the backtrace clean patterns" do
|
|
588
|
+
config.full_backtrace = true
|
|
589
|
+
config.backtrace_clean_patterns.should == []
|
|
590
|
+
end
|
|
591
|
+
end
|
|
592
|
+
|
|
593
|
+
context "given false" do
|
|
594
|
+
it "restores backtrace clean patterns" do
|
|
595
|
+
config.full_backtrace = false
|
|
596
|
+
config.backtrace_clean_patterns.should == RSpec::Core::Configuration::DEFAULT_BACKTRACE_PATTERNS
|
|
597
|
+
end
|
|
530
598
|
end
|
|
531
599
|
|
|
532
600
|
it "doesn't impact other instances of config" do
|
|
@@ -712,5 +780,17 @@ module RSpec::Core
|
|
|
712
780
|
group.included_modules.should include(mod2)
|
|
713
781
|
end
|
|
714
782
|
end
|
|
783
|
+
|
|
784
|
+
describe "#alias_example_to" do
|
|
785
|
+
it_behaves_like "metadata hash builder" do
|
|
786
|
+
def metadata_hash(*args)
|
|
787
|
+
config.alias_example_to :my_example, *args
|
|
788
|
+
group = ExampleGroup.describe("group")
|
|
789
|
+
example = group.my_example("description")
|
|
790
|
+
example.metadata
|
|
791
|
+
end
|
|
792
|
+
end
|
|
793
|
+
end
|
|
794
|
+
|
|
715
795
|
end
|
|
716
796
|
end
|
|
@@ -11,6 +11,16 @@ describe "deprecations" do
|
|
|
11
11
|
RSpec.stub(:warn_deprecation)
|
|
12
12
|
Spec.should == RSpec
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
it "doesn't include backward compatibility in const_missing backtrace" do
|
|
16
|
+
RSpec.stub(:warn_deprecation)
|
|
17
|
+
exception = nil
|
|
18
|
+
begin
|
|
19
|
+
ConstantThatDoesNotExist
|
|
20
|
+
rescue Exception => exception
|
|
21
|
+
end
|
|
22
|
+
exception.backtrace.find { |l| l =~ /lib\/rspec\/core\/backward_compatibility/ }.should be_nil
|
|
23
|
+
end
|
|
14
24
|
end
|
|
15
25
|
|
|
16
26
|
describe RSpec::Core::ExampleGroup do
|
|
@@ -41,5 +51,16 @@ describe "deprecations" do
|
|
|
41
51
|
RSpec.should_receive(:deprecate)
|
|
42
52
|
Spec::Rake::SpecTask
|
|
43
53
|
end
|
|
54
|
+
|
|
55
|
+
it "doesn't include backward compatibility in const_missing backtrace" do
|
|
56
|
+
RSpec.stub(:warn_deprecation)
|
|
57
|
+
exception = nil
|
|
58
|
+
begin
|
|
59
|
+
Spec::Rake::ConstantThatDoesNotExist
|
|
60
|
+
rescue Exception => exception
|
|
61
|
+
end
|
|
62
|
+
exception.backtrace.find { |l| l =~ /lib\/rspec\/core\/backward_compatibility/ }.should be_nil
|
|
63
|
+
end
|
|
44
64
|
end
|
|
65
|
+
|
|
45
66
|
end
|
|
@@ -5,31 +5,25 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
|
5
5
|
let(:out) { StringIO.new }
|
|
6
6
|
let(:err) { StringIO.new }
|
|
7
7
|
|
|
8
|
+
include_context "spec files"
|
|
9
|
+
|
|
10
|
+
def command_line(args)
|
|
11
|
+
RSpec::Core::DRbCommandLine.new(config_options(args))
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
def config_options(argv=[])
|
|
9
15
|
options = RSpec::Core::ConfigurationOptions.new(argv)
|
|
10
16
|
options.parse_options
|
|
11
17
|
options
|
|
12
18
|
end
|
|
13
19
|
|
|
14
|
-
def drb_command_line(args)
|
|
15
|
-
RSpec::Core::DRbCommandLine.new(config_options(args))
|
|
16
|
-
end
|
|
17
|
-
|
|
18
20
|
def run_with(args)
|
|
19
|
-
|
|
21
|
+
command_line(args).run(err, out)
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
context "without server running" do
|
|
23
|
-
it "
|
|
24
|
-
run_with []
|
|
25
|
-
|
|
26
|
-
err.rewind
|
|
27
|
-
err.read.should =~ /No DRb server is running/
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "returns false" do
|
|
31
|
-
result = run_with []
|
|
32
|
-
result.should be_false
|
|
25
|
+
it "raises an error" do
|
|
26
|
+
lambda { run_with [] }.should raise_error(DRb::DRbConnError)
|
|
33
27
|
end
|
|
34
28
|
end
|
|
35
29
|
|
|
@@ -47,14 +41,14 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
|
47
41
|
context "without RSPEC_DRB environment variable set" do
|
|
48
42
|
it "defaults to 8989" do
|
|
49
43
|
with_RSPEC_DRB_set_to(nil) do
|
|
50
|
-
|
|
44
|
+
command_line([]).drb_port.should == 8989
|
|
51
45
|
end
|
|
52
46
|
end
|
|
53
47
|
|
|
54
48
|
it "sets the DRb port" do
|
|
55
49
|
with_RSPEC_DRB_set_to(nil) do
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
command_line(["--drb-port", "1234"]).drb_port.should == 1234
|
|
51
|
+
command_line(["--drb-port", "5678"]).drb_port.should == 5678
|
|
58
52
|
end
|
|
59
53
|
end
|
|
60
54
|
end
|
|
@@ -64,7 +58,7 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
|
64
58
|
context "without config variable set" do
|
|
65
59
|
it "uses RSPEC_DRB value" do
|
|
66
60
|
with_RSPEC_DRB_set_to('9000') do
|
|
67
|
-
|
|
61
|
+
command_line([]).drb_port.should == "9000"
|
|
68
62
|
end
|
|
69
63
|
end
|
|
70
64
|
end
|
|
@@ -72,7 +66,7 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
|
72
66
|
context "and config variable set" do
|
|
73
67
|
it "uses configured value" do
|
|
74
68
|
with_RSPEC_DRB_set_to('9000') do
|
|
75
|
-
|
|
69
|
+
command_line(%w[--drb-port 5678]).drb_port.should == 5678
|
|
76
70
|
end
|
|
77
71
|
end
|
|
78
72
|
end
|
|
@@ -88,59 +82,30 @@ describe "::DRbCommandLine", :ruby => "!jruby" do
|
|
|
88
82
|
end
|
|
89
83
|
end
|
|
90
84
|
|
|
91
|
-
def dummy_spec_filename
|
|
92
|
-
@dummy_spec_filename ||= File.expand_path(File.dirname(__FILE__)) + "/_dummy_spec#{@drb_example_file_counter}.rb"
|
|
93
|
-
end
|
|
94
|
-
|
|
95
85
|
before(:all) do
|
|
96
86
|
@drb_port = 8990
|
|
97
87
|
@drb_example_file_counter = 0
|
|
98
88
|
DRb::start_service("druby://127.0.0.1:#{@drb_port}", ::FakeDrbSpecServer)
|
|
99
89
|
end
|
|
100
90
|
|
|
101
|
-
before(:each) do
|
|
102
|
-
@drb_example_file_counter += 1
|
|
103
|
-
create_dummy_spec_file
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
after(:each) do
|
|
107
|
-
File.delete(dummy_spec_filename)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
91
|
after(:all) do
|
|
111
92
|
DRb::stop_service
|
|
112
93
|
end
|
|
113
94
|
|
|
114
|
-
|
|
115
|
-
File.open(dummy_spec_filename, 'w') do |f|
|
|
116
|
-
f.write %q{
|
|
117
|
-
describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do
|
|
118
|
-
it "should be output with green bar" do
|
|
119
|
-
true.should be_true
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
it "should be output with red bar" do
|
|
123
|
-
raise("I want to see a red bar!")
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
}
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it "returns true" do
|
|
95
|
+
it "returns 0 if spec passes" do
|
|
131
96
|
err, out = StringIO.new, StringIO.new
|
|
132
|
-
result =
|
|
133
|
-
result.should
|
|
97
|
+
result = command_line(["--drb-port", @drb_port.to_s, passing_spec_filename]).run(err, out)
|
|
98
|
+
result.should be(0)
|
|
134
99
|
end
|
|
135
100
|
|
|
136
|
-
it "
|
|
101
|
+
it "returns 1 if spec passes" do
|
|
137
102
|
err, out = StringIO.new, StringIO.new
|
|
138
|
-
result =
|
|
139
|
-
result.should
|
|
103
|
+
result = command_line(["--drb-port", @drb_port.to_s, failing_spec_filename]).run(err, out)
|
|
104
|
+
result.should be(1)
|
|
140
105
|
end
|
|
141
106
|
|
|
142
107
|
def run_spec_via_druby
|
|
143
|
-
run_with([
|
|
108
|
+
run_with([failing_spec_filename, "--colour", "--drb-port", @drb_port.to_s])
|
|
144
109
|
out.rewind
|
|
145
110
|
out.read
|
|
146
111
|
end
|