rspec-core 2.99.2 → 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +103 -191
- data/License.txt +1 -0
- data/README.md +4 -25
- data/features/Upgrade.md +2 -14
- data/features/command_line/dry_run.feature +29 -0
- data/features/command_line/example_name_option.feature +1 -1
- data/features/command_line/fail_fast.feature +26 -0
- data/features/command_line/format_option.feature +3 -3
- data/features/command_line/line_number_option.feature +16 -11
- data/features/command_line/order.feature +2 -3
- data/features/command_line/pattern_option.feature +3 -3
- data/features/command_line/randomization.feature +63 -0
- data/features/command_line/require_option.feature +2 -2
- data/features/command_line/ruby.feature +1 -1
- data/features/configuration/alias_example_to.feature +13 -22
- data/features/configuration/{backtrace_clean_patterns.feature → backtrace_exclusion_patterns.feature} +17 -14
- data/features/configuration/custom_settings.feature +11 -11
- data/features/configuration/overriding_global_ordering.feature +93 -0
- data/features/configuration/profile.feature +13 -13
- data/features/configuration/read_options_from_file.feature +7 -7
- data/features/example_groups/basic_structure.feature +1 -1
- data/features/example_groups/shared_context.feature +8 -8
- data/features/example_groups/shared_examples.feature +6 -14
- data/features/expectation_framework_integration/configure_expectation_framework.feature +27 -122
- data/features/filtering/exclusion_filters.feature +2 -5
- data/features/filtering/inclusion_filters.feature +1 -5
- data/features/formatters/json_formatter.feature +2 -2
- data/features/formatters/text_formatter.feature +4 -4
- data/features/helper_methods/arbitrary_methods.feature +2 -2
- data/features/helper_methods/let.feature +5 -5
- data/features/helper_methods/modules.feature +5 -8
- data/features/hooks/around_hooks.feature +2 -2
- data/features/hooks/before_and_after_hooks.feature +14 -14
- data/features/hooks/filtering.feature +12 -14
- data/features/metadata/described_class.feature +1 -1
- data/features/metadata/user_defined.feature +16 -29
- data/features/mock_framework_integration/use_flexmock.feature +1 -1
- data/features/mock_framework_integration/use_mocha.feature +1 -1
- data/features/mock_framework_integration/use_rr.feature +1 -1
- data/features/mock_framework_integration/use_rspec.feature +5 -5
- data/features/pending/pending_examples.feature +5 -5
- data/features/spec_files/arbitrary_file_suffix.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +3 -3
- data/features/subject/explicit_subject.feature +8 -8
- data/features/subject/implicit_receiver.feature +29 -0
- data/features/subject/implicit_subject.feature +4 -4
- data/features/support/env.rb +10 -3
- data/features/support/require_expect_syntax_in_aruba_specs.rb +16 -0
- data/lib/rspec/core.rb +11 -48
- data/lib/rspec/core/backport_random.rb +302 -0
- data/lib/rspec/core/backtrace_formatter.rb +65 -0
- data/lib/rspec/core/command_line.rb +7 -18
- data/lib/rspec/core/configuration.rb +202 -507
- data/lib/rspec/core/configuration_options.rb +17 -30
- data/lib/rspec/core/example.rb +29 -39
- data/lib/rspec/core/example_group.rb +166 -259
- data/lib/rspec/core/filter_manager.rb +30 -47
- data/lib/rspec/core/flat_map.rb +17 -0
- data/lib/rspec/core/formatters.rb +0 -138
- data/lib/rspec/core/formatters/base_formatter.rb +46 -1
- data/lib/rspec/core/formatters/base_text_formatter.rb +38 -61
- data/lib/rspec/core/formatters/deprecation_formatter.rb +21 -52
- data/lib/rspec/core/formatters/helpers.rb +0 -28
- data/lib/rspec/core/formatters/html_formatter.rb +1 -1
- data/lib/rspec/core/formatters/json_formatter.rb +38 -9
- data/lib/rspec/core/formatters/snippet_extractor.rb +14 -5
- data/lib/rspec/core/hooks.rb +55 -39
- data/lib/rspec/core/memoized_helpers.rb +17 -167
- data/lib/rspec/core/metadata.rb +16 -64
- data/lib/rspec/core/option_parser.rb +30 -39
- data/lib/rspec/core/ordering.rb +154 -0
- data/lib/rspec/core/pending.rb +12 -69
- data/lib/rspec/core/project_initializer.rb +12 -10
- data/lib/rspec/core/rake_task.rb +5 -108
- data/lib/rspec/core/reporter.rb +15 -18
- data/lib/rspec/core/runner.rb +16 -30
- data/lib/rspec/core/shared_context.rb +3 -5
- data/lib/rspec/core/shared_example_group.rb +3 -51
- data/lib/rspec/core/shared_example_group/collection.rb +1 -19
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/warnings.rb +22 -0
- data/lib/rspec/core/world.rb +12 -8
- data/spec/command_line/order_spec.rb +20 -23
- data/spec/rspec/core/backtrace_formatter_spec.rb +216 -0
- data/spec/rspec/core/command_line_spec.rb +32 -48
- data/spec/rspec/core/configuration_options_spec.rb +19 -50
- data/spec/rspec/core/configuration_spec.rb +142 -713
- data/spec/rspec/core/drb_command_line_spec.rb +2 -0
- data/spec/rspec/core/dsl_spec.rb +0 -1
- data/spec/rspec/core/example_group_spec.rb +192 -223
- data/spec/rspec/core/example_spec.rb +40 -16
- data/spec/rspec/core/filter_manager_spec.rb +2 -2
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -41
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +5 -123
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +2 -87
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +2 -3
- data/spec/rspec/core/formatters/{text_mate_formatted.html → html_formatted-1.8.7-jruby.html} +44 -25
- data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +477 -0
- data/spec/rspec/core/formatters/{html_formatted.html → html_formatted-1.8.7.html} +42 -25
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +425 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +416 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +477 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +419 -0
- data/spec/rspec/core/formatters/html_formatted-2.0.0.html +425 -0
- data/spec/rspec/core/formatters/html_formatter_spec.rb +21 -46
- data/spec/rspec/core/formatters/json_formatter_spec.rb +97 -8
- data/spec/rspec/core/hooks_filtering_spec.rb +5 -5
- data/spec/rspec/core/hooks_spec.rb +61 -47
- data/spec/rspec/core/memoized_helpers_spec.rb +20 -322
- data/spec/rspec/core/metadata_spec.rb +1 -24
- data/spec/rspec/core/option_parser_spec.rb +20 -62
- data/spec/rspec/core/ordering_spec.rb +102 -0
- data/spec/rspec/core/pending_example_spec.rb +0 -40
- data/spec/rspec/core/project_initializer_spec.rb +1 -25
- data/spec/rspec/core/rake_task_spec.rb +5 -72
- data/spec/rspec/core/random_spec.rb +47 -0
- data/spec/rspec/core/reporter_spec.rb +23 -48
- data/spec/rspec/core/runner_spec.rb +31 -39
- data/spec/rspec/core/shared_context_spec.rb +3 -15
- data/spec/rspec/core/shared_example_group/collection_spec.rb +4 -17
- data/spec/rspec/core/shared_example_group_spec.rb +12 -45
- data/spec/rspec/core/{deprecation_spec.rb → warnings_spec.rb} +3 -1
- data/spec/rspec/core_spec.rb +4 -21
- data/spec/spec_helper.rb +41 -5
- data/spec/support/helper_methods.rb +0 -29
- data/spec/support/sandboxed_mock_space.rb +0 -16
- data/spec/support/shared_example_groups.rb +7 -36
- data/spec/support/stderr_splitter.rb +36 -0
- metadata +163 -157
- metadata.gz.sig +1 -0
- data/exe/autospec +0 -13
- data/features/Autotest.md +0 -38
- data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
- data/features/subject/attribute_of_subject.feature +0 -124
- data/features/subject/one_liner_syntax.feature +0 -71
- data/lib/autotest/discover.rb +0 -10
- data/lib/autotest/rspec2.rb +0 -77
- data/lib/rspec/core/backtrace_cleaner.rb +0 -46
- data/lib/rspec/core/backward_compatibility.rb +0 -55
- data/lib/rspec/core/caller_filter.rb +0 -60
- data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
- data/lib/rspec/core/deprecation.rb +0 -26
- data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
- data/lib/rspec/core/extensions/kernel.rb +0 -9
- data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
- data/lib/rspec/core/extensions/ordered.rb +0 -27
- data/lib/rspec/core/formatters/console_codes.rb +0 -42
- data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
- data/lib/rspec/core/metadata_hash_builder.rb +0 -97
- data/lib/rspec/core/minitest_assertions_adapter.rb +0 -28
- data/lib/rspec/core/test_unit_assertions_adapter.rb +0 -30
- data/spec/autotest/discover_spec.rb +0 -49
- data/spec/autotest/failed_results_re_spec.rb +0 -45
- data/spec/autotest/rspec_spec.rb +0 -133
- data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
- data/spec/rspec/core/caller_filter_spec.rb +0 -58
- data/spec/rspec/core/deprecations_spec.rb +0 -59
- data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
- data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
- data/spec/rspec/core/pending_spec.rb +0 -27
- data/spec/support/silence_dsl_deprecations.rb +0 -32
@@ -5,8 +5,6 @@ module RSpec
|
|
5
5
|
# syntax embraced by shoulda matchers:
|
6
6
|
#
|
7
7
|
# describe Widget do
|
8
|
-
# it { is_expected.to validate_presence_of(:name) }
|
9
|
-
# # or
|
10
8
|
# it { should validate_presence_of(:name) }
|
11
9
|
# end
|
12
10
|
#
|
@@ -33,10 +31,8 @@ module RSpec
|
|
33
31
|
# end
|
34
32
|
# end
|
35
33
|
#
|
36
|
-
# # one-liner syntax -
|
34
|
+
# # one-liner syntax - should is invoked on subject
|
37
35
|
# describe Person do
|
38
|
-
# it { is_expected.to be_eligible_to_vote }
|
39
|
-
# # or
|
40
36
|
# it { should be_eligible_to_vote }
|
41
37
|
# end
|
42
38
|
#
|
@@ -68,11 +64,6 @@ module RSpec
|
|
68
64
|
# end
|
69
65
|
#
|
70
66
|
# @see #subject
|
71
|
-
# @see #is_expected
|
72
|
-
#
|
73
|
-
# @note This only works if you are using rspec-expectations.
|
74
|
-
# @note If you are using RSpec's newer expect-based syntax you may
|
75
|
-
# want to use `is_expected.to` instead of `should`.
|
76
67
|
def should(matcher=nil, message=nil)
|
77
68
|
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(subject, matcher, message)
|
78
69
|
end
|
@@ -87,34 +78,10 @@ module RSpec
|
|
87
78
|
# end
|
88
79
|
#
|
89
80
|
# @see #subject
|
90
|
-
# @see #is_expected
|
91
|
-
#
|
92
|
-
# @note This only works if you are using rspec-expectations.
|
93
|
-
# @note If you are using RSpec's newer expect-based syntax you may
|
94
|
-
# want to use `is_expected.to_not` instead of `should_not`.
|
95
81
|
def should_not(matcher=nil, message=nil)
|
96
82
|
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(subject, matcher, message)
|
97
83
|
end
|
98
84
|
|
99
|
-
# Wraps the `subject` in `expect` to make it the target of an expectation.
|
100
|
-
# Designed to read nicely for one-liners.
|
101
|
-
#
|
102
|
-
# @example
|
103
|
-
#
|
104
|
-
# describe [1, 2, 3] do
|
105
|
-
# it { is_expected.to be_an Array }
|
106
|
-
# it { is_expected.not_to include 4 }
|
107
|
-
# end
|
108
|
-
#
|
109
|
-
# @see #subject
|
110
|
-
# @see #should
|
111
|
-
# @see #should_not
|
112
|
-
#
|
113
|
-
# @note This only works if you are using rspec-expectations.
|
114
|
-
def is_expected
|
115
|
-
expect(subject)
|
116
|
-
end
|
117
|
-
|
118
85
|
private
|
119
86
|
|
120
87
|
# @private
|
@@ -128,85 +95,61 @@ module RSpec
|
|
128
95
|
# @private
|
129
96
|
class AllHookMemoizedHash
|
130
97
|
def self.isolate_for_all_hook(example_group_instance)
|
131
|
-
|
98
|
+
hash = self
|
132
99
|
|
133
100
|
example_group_instance.instance_eval do
|
134
|
-
@__memoized =
|
101
|
+
@__memoized = hash
|
135
102
|
|
136
103
|
begin
|
137
104
|
yield
|
138
105
|
ensure
|
139
|
-
@__memoized.preserve_accessed_lets
|
140
106
|
@__memoized = nil
|
141
107
|
end
|
142
108
|
end
|
143
109
|
end
|
144
110
|
|
145
|
-
def
|
146
|
-
@example_group_instance = example_group_instance
|
147
|
-
@hash = {}
|
148
|
-
end
|
149
|
-
|
150
|
-
def fetch(key, &block)
|
111
|
+
def self.fetch(key, &block)
|
151
112
|
description = if key == :subject
|
152
113
|
"subject"
|
153
114
|
else
|
154
115
|
"let declaration `#{key}`"
|
155
116
|
end
|
156
117
|
|
157
|
-
|
158
|
-
|
118
|
+
raise <<-EOS
|
119
|
+
#{description} accessed in #{article} #{hook_expression} hook at:
|
159
120
|
#{CallerFilter.first_non_rspec_line}
|
160
121
|
|
161
122
|
`let` and `subject` declarations are not intended to be called
|
162
123
|
in #{article} #{hook_expression} hook, as they exist to define state that
|
163
124
|
is reset between each example, while #{hook_expression} exists to
|
164
125
|
#{hook_intention}.
|
165
|
-
|
166
|
-
This is deprecated behavior that will not be supported in RSpec 3.
|
167
126
|
EOS
|
168
|
-
@hash.fetch(key, &block)
|
169
|
-
end
|
170
|
-
|
171
|
-
def []=(key, value)
|
172
|
-
@hash[key] = value
|
173
|
-
end
|
174
|
-
|
175
|
-
def preserve_accessed_lets
|
176
|
-
hash = @hash
|
177
|
-
|
178
|
-
@example_group_instance.class.class_eval do
|
179
|
-
hash.each do |key, value|
|
180
|
-
undef_method(key) if method_defined?(key)
|
181
|
-
define_method(key) { value }
|
182
|
-
end
|
183
|
-
end
|
184
127
|
end
|
185
128
|
|
186
129
|
class Before < self
|
187
|
-
def hook_expression
|
130
|
+
def self.hook_expression
|
188
131
|
"`before(:all)`"
|
189
132
|
end
|
190
133
|
|
191
|
-
def article
|
134
|
+
def self.article
|
192
135
|
"a"
|
193
136
|
end
|
194
137
|
|
195
|
-
def hook_intention
|
138
|
+
def self.hook_intention
|
196
139
|
"define state that is shared across examples in an example group"
|
197
140
|
end
|
198
141
|
end
|
199
142
|
|
200
143
|
class After < self
|
201
|
-
def hook_expression
|
144
|
+
def self.hook_expression
|
202
145
|
"`after(:all)`"
|
203
146
|
end
|
204
147
|
|
205
|
-
def article
|
148
|
+
def self.article
|
206
149
|
"an"
|
207
150
|
end
|
208
151
|
|
209
|
-
def hook_intention
|
152
|
+
def self.hook_intention
|
210
153
|
"cleanup state that is shared across examples in an example group"
|
211
154
|
end
|
212
155
|
end
|
@@ -322,9 +265,8 @@ EOS
|
|
322
265
|
before { __send__(name) }
|
323
266
|
end
|
324
267
|
|
325
|
-
# Declares a `subject` for an example group which can then be
|
326
|
-
#
|
327
|
-
# in a concise, one-line example.
|
268
|
+
# Declares a `subject` for an example group which can then be the
|
269
|
+
# implicit receiver (through delegation) of calls to `should`.
|
328
270
|
#
|
329
271
|
# Given a `name`, defines a method with that name which returns the
|
330
272
|
# `subject`. This lets you declare the subject once and access it
|
@@ -339,13 +281,13 @@ EOS
|
|
339
281
|
#
|
340
282
|
# describe CheckingAccount, "with $50" do
|
341
283
|
# subject { CheckingAccount.new(Money.new(50, :USD)) }
|
342
|
-
# it {
|
343
|
-
# it {
|
284
|
+
# it { should have_a_balance_of(Money.new(50, :USD)) }
|
285
|
+
# it { should_not be_overdrawn }
|
344
286
|
# end
|
345
287
|
#
|
346
288
|
# describe CheckingAccount, "with a non-zero starting balance" do
|
347
289
|
# subject(:account) { CheckingAccount.new(Money.new(50, :USD)) }
|
348
|
-
# it {
|
290
|
+
# it { should_not be_overdrawn }
|
349
291
|
# it "has a balance equal to the starting balance" do
|
350
292
|
# account.balance.should eq(Money.new(50, :USD))
|
351
293
|
# end
|
@@ -422,98 +364,6 @@ EOS
|
|
422
364
|
subject(name, &block)
|
423
365
|
before { subject }
|
424
366
|
end
|
425
|
-
|
426
|
-
# Creates a nested example group named by the submitted `attribute`,
|
427
|
-
# and then generates an example using the submitted block.
|
428
|
-
#
|
429
|
-
# @example
|
430
|
-
#
|
431
|
-
# # This ...
|
432
|
-
# describe Array do
|
433
|
-
# its(:size) { should eq(0) }
|
434
|
-
# end
|
435
|
-
#
|
436
|
-
# # ... generates the same runtime structure as this:
|
437
|
-
# describe Array do
|
438
|
-
# describe "size" do
|
439
|
-
# it "should eq(0)" do
|
440
|
-
# subject.size.should eq(0)
|
441
|
-
# end
|
442
|
-
# end
|
443
|
-
# end
|
444
|
-
#
|
445
|
-
# The attribute can be a `Symbol` or a `String`. Given a `String`
|
446
|
-
# with dots, the result is as though you concatenated that `String`
|
447
|
-
# onto the subject in an expression.
|
448
|
-
#
|
449
|
-
# @example
|
450
|
-
#
|
451
|
-
# describe Person do
|
452
|
-
# subject do
|
453
|
-
# Person.new.tap do |person|
|
454
|
-
# person.phone_numbers << "555-1212"
|
455
|
-
# end
|
456
|
-
# end
|
457
|
-
#
|
458
|
-
# its("phone_numbers.first") { should eq("555-1212") }
|
459
|
-
# end
|
460
|
-
#
|
461
|
-
# When the subject is a `Hash`, you can refer to the Hash keys by
|
462
|
-
# specifying a `Symbol` or `String` in an array.
|
463
|
-
#
|
464
|
-
# @example
|
465
|
-
#
|
466
|
-
# describe "a configuration Hash" do
|
467
|
-
# subject do
|
468
|
-
# { :max_users => 3,
|
469
|
-
# 'admin' => :all_permissions }
|
470
|
-
# end
|
471
|
-
#
|
472
|
-
# its([:max_users]) { should eq(3) }
|
473
|
-
# its(['admin']) { should eq(:all_permissions) }
|
474
|
-
#
|
475
|
-
# # You can still access to its regular methods this way:
|
476
|
-
# its(:keys) { should include(:max_users) }
|
477
|
-
# its(:count) { should eq(2) }
|
478
|
-
# end
|
479
|
-
#
|
480
|
-
# Note that this method does not modify `subject` in any way, so if you
|
481
|
-
# refer to `subject` in `let` or `before` blocks, you're still
|
482
|
-
# referring to the outer subject.
|
483
|
-
#
|
484
|
-
# @example
|
485
|
-
#
|
486
|
-
# describe Person do
|
487
|
-
# subject { Person.new }
|
488
|
-
# before { subject.age = 25 }
|
489
|
-
# its(:age) { should eq(25) }
|
490
|
-
# end
|
491
|
-
def its(attribute, &block)
|
492
|
-
RSpec.deprecate("Use of rspec-core's `its` method", :replacement => 'the rspec-its gem')
|
493
|
-
|
494
|
-
describe(attribute.to_s) do
|
495
|
-
if Array === attribute
|
496
|
-
let(:__its_subject) { subject[*attribute] }
|
497
|
-
else
|
498
|
-
let(:__its_subject) do
|
499
|
-
attribute_chain = attribute.to_s.split('.')
|
500
|
-
attribute_chain.inject(subject) do |inner_subject, attr|
|
501
|
-
inner_subject.send(attr)
|
502
|
-
end
|
503
|
-
end
|
504
|
-
end
|
505
|
-
|
506
|
-
def should(matcher=nil, message=nil)
|
507
|
-
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(__its_subject, matcher, message)
|
508
|
-
end
|
509
|
-
|
510
|
-
def should_not(matcher=nil, message=nil)
|
511
|
-
RSpec::Expectations::NegativeExpectationHandler.handle_matcher(__its_subject, matcher, message)
|
512
|
-
end
|
513
|
-
|
514
|
-
example(&block)
|
515
|
-
end
|
516
|
-
end
|
517
367
|
end
|
518
368
|
|
519
369
|
# @api private
|
data/lib/rspec/core/metadata.rb
CHANGED
@@ -25,9 +25,6 @@ module RSpec
|
|
25
25
|
# @see Configuration#filter_run_including
|
26
26
|
# @see Configuration#filter_run_excluding
|
27
27
|
class Metadata < Hash
|
28
|
-
class << self
|
29
|
-
attr_accessor :line_number_filter_deprecation_issued
|
30
|
-
end
|
31
28
|
|
32
29
|
def self.relative_path(line)
|
33
30
|
line = line.sub(File.expand_path("."), ".")
|
@@ -39,6 +36,20 @@ module RSpec
|
|
39
36
|
end
|
40
37
|
|
41
38
|
# @private
|
39
|
+
# Used internally to build a hash from an args array.
|
40
|
+
# Symbols are converted into hash keys with a value of `true`.
|
41
|
+
# This is done to support simple tagging using a symbol, rather
|
42
|
+
# than needing to do `:symbol => true`.
|
43
|
+
def self.build_hash_from(args)
|
44
|
+
hash = args.last.is_a?(Hash) ? args.pop : {}
|
45
|
+
|
46
|
+
while args.last.is_a?(Symbol)
|
47
|
+
hash[args.pop] = true
|
48
|
+
end
|
49
|
+
|
50
|
+
hash
|
51
|
+
end
|
52
|
+
|
42
53
|
module MetadataHash
|
43
54
|
|
44
55
|
# @private
|
@@ -130,30 +141,6 @@ module RSpec
|
|
130
141
|
include MetadataHash
|
131
142
|
|
132
143
|
def described_class
|
133
|
-
warn_about_first_description_arg_behavioral_change_in_rspec_3
|
134
|
-
|
135
|
-
value_for_rspec_2 = described_class_for_rspec_2
|
136
|
-
value_for_rspec_3 = described_class_for_rspec_3
|
137
|
-
|
138
|
-
if value_for_rspec_2 != value_for_rspec_3
|
139
|
-
RSpec.warn_deprecation(<<-EOS.gsub(/^\s+\|/, ''))
|
140
|
-
|The semantics of `described_class` in a nested `describe <SomeClass>`
|
141
|
-
|example group are changing in RSpec 3. In RSpec 2.x, `described_class`
|
142
|
-
|would return the outermost described class (#{value_for_rspec_2.inspect}).
|
143
|
-
|In RSpec 3, it will return the innermost described class (#{value_for_rspec_3.inspect}).
|
144
|
-
|In general, we recommend not describing multiple classes or objects in a
|
145
|
-
|nested manner as it creates confusion.
|
146
|
-
|
|
147
|
-
|To make your code compatible with RSpec 3, change from `described_class` to a reference
|
148
|
-
|to `#{value_for_rspec_3.inspect}`, or change the arg of the inner `describe` to a string.
|
149
|
-
|(Called from #{CallerFilter.first_non_rspec_line})
|
150
|
-
EOS
|
151
|
-
end
|
152
|
-
|
153
|
-
value_for_rspec_2
|
154
|
-
end
|
155
|
-
|
156
|
-
def described_class_for_rspec_2
|
157
144
|
container_stack.each do |g|
|
158
145
|
[:described_class, :describes].each do |key|
|
159
146
|
if g.has_key?(key)
|
@@ -171,33 +158,8 @@ module RSpec
|
|
171
158
|
nil
|
172
159
|
end
|
173
160
|
|
174
|
-
def described_class_for_rspec_3
|
175
|
-
container_stack.each do |g|
|
176
|
-
[:described_class, :describes].each do |key|
|
177
|
-
if g.has_key?(key)
|
178
|
-
value = g[key]
|
179
|
-
return value unless value.nil?
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
candidate = g[:description_args].first
|
184
|
-
return candidate unless NilClass === candidate || String === candidate || Symbol === candidate
|
185
|
-
end
|
186
|
-
|
187
|
-
nil
|
188
|
-
end
|
189
|
-
|
190
|
-
def warn_about_first_description_arg_behavioral_change_in_rspec_3
|
191
|
-
return unless behavior_change = self[:description_arg_behavior_changing_in_rspec_3]
|
192
|
-
RSpec.warn_deprecation(behavior_change.warning)
|
193
|
-
end
|
194
|
-
|
195
|
-
def first_description_arg
|
196
|
-
self[:description_args].first
|
197
|
-
end
|
198
|
-
|
199
161
|
def full_description
|
200
|
-
build_description_from(*container_stack.reverse
|
162
|
+
build_description_from(*FlatMap.flat_map(container_stack.reverse) {|a| a[:description_args]})
|
201
163
|
end
|
202
164
|
|
203
165
|
def container_stack
|
@@ -230,7 +192,6 @@ module RSpec
|
|
230
192
|
|
231
193
|
self[:example_group].store(:description_args, args)
|
232
194
|
self[:example_group].store(:caller, user_metadata.delete(:caller) || caller)
|
233
|
-
self[:example_group][:description_arg_behavior_changing_in_rspec_3] = user_metadata.delete(:description_arg_behavior_changing_in_rspec_3)
|
234
195
|
|
235
196
|
update(user_metadata)
|
236
197
|
end
|
@@ -253,16 +214,7 @@ module RSpec
|
|
253
214
|
# @private
|
254
215
|
def filter_applies?(key, value, metadata=self)
|
255
216
|
return metadata.filter_applies_to_any_value?(key, value) if Array === metadata[key] && !(Proc === value)
|
256
|
-
|
257
|
-
if key == :line_numbers
|
258
|
-
unless Metadata.line_number_filter_deprecation_issued
|
259
|
-
RSpec.deprecate("Filtering by `:line_numbers`",
|
260
|
-
:replacement => "filtering by `:locations`")
|
261
|
-
end
|
262
|
-
|
263
|
-
return metadata.line_number_filter_applies?(value)
|
264
|
-
end
|
265
|
-
|
217
|
+
return metadata.line_number_filter_applies?(value) if key == :line_numbers
|
266
218
|
return metadata.location_filter_applies?(value) if key == :locations
|
267
219
|
return metadata.filters_apply?(key, value) if Hash === value
|
268
220
|
|
@@ -14,7 +14,6 @@ module RSpec::Core
|
|
14
14
|
def parse!(args)
|
15
15
|
return {} if args.empty?
|
16
16
|
|
17
|
-
pre_parse(args)
|
18
17
|
convert_deprecated_args(args)
|
19
18
|
|
20
19
|
options = args.delete('--tty') ? {:tty => true} : {}
|
@@ -31,10 +30,9 @@ module RSpec::Core
|
|
31
30
|
args.map! { |arg|
|
32
31
|
case arg
|
33
32
|
when "--formatter"
|
34
|
-
RSpec.deprecate("
|
33
|
+
RSpec.deprecate("the --formatter option", :replacement => "-f or --format")
|
35
34
|
"--format"
|
36
35
|
when "--default_path"
|
37
|
-
RSpec.deprecate("The `--default_path` option", :replacement => "--default-path", :call_site => nil)
|
38
36
|
"--default-path"
|
39
37
|
when "--line_number"
|
40
38
|
"--line-number"
|
@@ -65,35 +63,34 @@ module RSpec::Core
|
|
65
63
|
end
|
66
64
|
|
67
65
|
parser.on('--order TYPE[:SEED]', 'Run examples by the specified order type.',
|
68
|
-
' [defined]
|
69
|
-
' [
|
70
|
-
' [rand] randomize the order of files, groups and examples',
|
66
|
+
' [defined] examples and groups are run in the order they are defined',
|
67
|
+
' [rand] randomize the order of groups and examples',
|
71
68
|
' [random] alias for rand',
|
72
69
|
' [random:SEED] e.g. --order random:123') do |o|
|
73
|
-
options[:order] =
|
74
|
-
RSpec.deprecate("RSpec's `--order default` CLI option", :replacement => "`--order defined`", :call_site => nil)
|
75
|
-
'defined'
|
76
|
-
else
|
77
|
-
o
|
78
|
-
end
|
70
|
+
options[:order] = o
|
79
71
|
end
|
80
72
|
|
81
73
|
parser.on('--seed SEED', Integer, 'Equivalent of --order rand:SEED.') do |seed|
|
82
74
|
options[:order] = "rand:#{seed}"
|
83
75
|
end
|
84
76
|
|
85
|
-
parser.on('-d', '--debugger', 'Enable debugging.') do |o|
|
86
|
-
options[:debug] = :cli
|
87
|
-
end
|
88
|
-
|
89
77
|
parser.on('--fail-fast', 'Abort the run on first failure.') do |o|
|
90
78
|
options[:fail_fast] = true
|
91
79
|
end
|
92
80
|
|
81
|
+
parser.on('--no-fail-fast', 'Do not abort the run on first failure.') do |o|
|
82
|
+
options[:fail_fast] = false
|
83
|
+
end
|
84
|
+
|
93
85
|
parser.on('--failure-exit-code CODE', Integer, 'Override the exit code used when there are failing specs.') do |code|
|
94
86
|
options[:failure_exit_code] = code
|
95
87
|
end
|
96
88
|
|
89
|
+
parser.on('--dry-run', 'Print the formatter output of your suite without',
|
90
|
+
' running any examples or hooks') do |o|
|
91
|
+
options[:dry_run] = true
|
92
|
+
end
|
93
|
+
|
97
94
|
parser.on('-X', '--[no-]drb', 'Run examples via DRb.') do |o|
|
98
95
|
options[:drb] = o
|
99
96
|
end
|
@@ -103,12 +100,13 @@ module RSpec::Core
|
|
103
100
|
end
|
104
101
|
|
105
102
|
parser.on('--init', 'Initialize your project with RSpec.') do |cmd|
|
103
|
+
require 'rspec/core/project_initializer'
|
106
104
|
ProjectInitializer.new(cmd).run
|
107
105
|
exit
|
108
106
|
end
|
109
107
|
|
110
108
|
parser.on('--configure', 'Deprecated. Use --init instead.') do |cmd|
|
111
|
-
|
109
|
+
RSpec.warning "--configure is deprecated with no effect. Use --init instead.", :call_site => nil
|
112
110
|
exit
|
113
111
|
end
|
114
112
|
|
@@ -118,7 +116,6 @@ module RSpec::Core
|
|
118
116
|
' [p]rogress (default - dots)',
|
119
117
|
' [d]ocumentation (group and example names)',
|
120
118
|
' [h]tml',
|
121
|
-
' [t]extmate',
|
122
119
|
' [j]son',
|
123
120
|
' custom formatter class name') do |o|
|
124
121
|
options[:formatters] ||= []
|
@@ -134,11 +131,6 @@ module RSpec::Core
|
|
134
131
|
options[:formatters].last << o
|
135
132
|
end
|
136
133
|
|
137
|
-
parser.on('--deprecation-out FILE', 'Write deprecation warnings to a file instead of $stdout.') do |file|
|
138
|
-
# Handled in `pre_parse` so we can set the deprecation stream as early as
|
139
|
-
# possible in case any other options cause deprecations to be issued.
|
140
|
-
end
|
141
|
-
|
142
134
|
parser.on('-b', '--backtrace', 'Enable full backtrace.') do |o|
|
143
135
|
options[:full_backtrace] = true
|
144
136
|
end
|
@@ -156,9 +148,10 @@ module RSpec::Core
|
|
156
148
|
begin
|
157
149
|
Integer(argument)
|
158
150
|
rescue ArgumentError
|
159
|
-
|
151
|
+
RSpec.warning "Non integer specified as profile count, seperate " +
|
160
152
|
"your path from options with -- e.g. " +
|
161
|
-
"`rspec --profile -- #{argument}`"
|
153
|
+
"`rspec --profile -- #{argument}`",
|
154
|
+
:call_site => nil
|
162
155
|
true
|
163
156
|
end
|
164
157
|
end
|
@@ -191,10 +184,6 @@ FILTERING
|
|
191
184
|
|
192
185
|
parser.on('-l', '--line-number LINE', 'Specify line number of an example or group (may be',
|
193
186
|
' used more than once).') do |o|
|
194
|
-
Metadata.line_number_filter_deprecation_issued = true
|
195
|
-
RSpec.deprecate("The `--line-number`/`-l` CLI option",
|
196
|
-
:replacement => "the `path/to/file.rb:num` form",
|
197
|
-
:call_site => nil)
|
198
187
|
(options[:line_numbers] ||= []) << o
|
199
188
|
end
|
200
189
|
|
@@ -205,11 +194,21 @@ FILTERING
|
|
205
194
|
' - TAG is always converted to a symbol') do |tag|
|
206
195
|
filter_type = tag =~ /^~/ ? :exclusion_filter : :inclusion_filter
|
207
196
|
|
208
|
-
name,value = tag.gsub(/^(~@|~|@)/, '').split(':')
|
197
|
+
name,value = tag.gsub(/^(~@|~|@)/, '').split(':',2)
|
209
198
|
name = name.to_sym
|
210
199
|
|
211
200
|
options[filter_type] ||= {}
|
212
|
-
options[filter_type][name] =
|
201
|
+
options[filter_type][name] = case value
|
202
|
+
when nil then true # The default value for tags is true
|
203
|
+
when 'true' then true
|
204
|
+
when 'false' then false
|
205
|
+
when 'nil' then nil
|
206
|
+
when /^:/ then value[1..-1].to_sym
|
207
|
+
when /^\d+$/ then Integer(value)
|
208
|
+
when /^\d+.\d+$/ then Float(value)
|
209
|
+
else
|
210
|
+
value
|
211
|
+
end
|
213
212
|
end
|
214
213
|
|
215
214
|
parser.on('--default-path PATH', 'Set the default path where RSpec looks for examples (can',
|
@@ -231,13 +230,5 @@ FILTERING
|
|
231
230
|
|
232
231
|
end
|
233
232
|
end
|
234
|
-
|
235
|
-
def pre_parse(args)
|
236
|
-
args.each_cons(2) do |arg, value|
|
237
|
-
if arg == "--deprecation-out"
|
238
|
-
RSpec.configuration.deprecation_stream = value
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
233
|
end
|
243
234
|
end
|