rspec-core 2.99.2 → 3.0.0.beta1
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 +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
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
module RSpec
|
|
2
|
+
module Core
|
|
3
|
+
if defined?(::Random)
|
|
4
|
+
RandomNumberGenerator = ::Random
|
|
5
|
+
else
|
|
6
|
+
require 'rspec/core/backport_random'
|
|
7
|
+
RandomNumberGenerator = RSpec::Core::Backports::Random
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# @private
|
|
11
|
+
module Ordering
|
|
12
|
+
# @private
|
|
13
|
+
# The default global ordering (defined order).
|
|
14
|
+
class Identity
|
|
15
|
+
def order(items)
|
|
16
|
+
items
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @private
|
|
21
|
+
# Orders items randomly.
|
|
22
|
+
class Random
|
|
23
|
+
def initialize(configuration)
|
|
24
|
+
@configuration = configuration
|
|
25
|
+
@used = false
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def used?
|
|
29
|
+
@used
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def order(items)
|
|
33
|
+
@used = true
|
|
34
|
+
rng = RandomNumberGenerator.new(@configuration.seed)
|
|
35
|
+
shuffle items, rng
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
if RUBY_VERSION > '1.9.3'
|
|
39
|
+
def shuffle(list, rng)
|
|
40
|
+
list.shuffle(:random => rng)
|
|
41
|
+
end
|
|
42
|
+
else
|
|
43
|
+
def shuffle(list, rng)
|
|
44
|
+
shuffled = list.dup
|
|
45
|
+
shuffled.size.times do |i|
|
|
46
|
+
j = i + rng.rand(shuffled.size - i)
|
|
47
|
+
next if i == j
|
|
48
|
+
shuffled[i], shuffled[j] = shuffled[j], shuffled[i]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
shuffled
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @private
|
|
57
|
+
# Orders items based on a custom block.
|
|
58
|
+
class Custom
|
|
59
|
+
def initialize(callable)
|
|
60
|
+
@callable = callable
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def order(list)
|
|
64
|
+
@callable.call(list)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# @private
|
|
69
|
+
# Stores the different ordering strategies.
|
|
70
|
+
class Registry
|
|
71
|
+
def initialize(configuration)
|
|
72
|
+
@configuration = configuration
|
|
73
|
+
@strategies = {}
|
|
74
|
+
|
|
75
|
+
register(:random, Random.new(configuration))
|
|
76
|
+
|
|
77
|
+
identity = Identity.new
|
|
78
|
+
register(:defined, identity)
|
|
79
|
+
|
|
80
|
+
# The default global ordering is --defined.
|
|
81
|
+
register(:global, identity)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def fetch(name, &fallback)
|
|
85
|
+
@strategies.fetch(name, &fallback)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def register(sym, strategy)
|
|
89
|
+
@strategies[sym] = strategy
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def used_random_seed?
|
|
93
|
+
@strategies[:random].used?
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# @private
|
|
98
|
+
# Manages ordering configuration.
|
|
99
|
+
#
|
|
100
|
+
# @note This is not intended to be used externally. Use
|
|
101
|
+
# the APIs provided by `RSpec::Core::Configuration` instead.
|
|
102
|
+
class ConfigurationManager
|
|
103
|
+
attr_reader :seed, :ordering_registry
|
|
104
|
+
|
|
105
|
+
def initialize
|
|
106
|
+
@ordering_registry = Registry.new(self)
|
|
107
|
+
@seed = rand(0xFFFF)
|
|
108
|
+
@seed_forced = false
|
|
109
|
+
@order_forced = false
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def seed_used?
|
|
113
|
+
ordering_registry.used_random_seed?
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def seed=(seed)
|
|
117
|
+
return if @seed_forced
|
|
118
|
+
register_ordering(:global, ordering_registry.fetch(:random))
|
|
119
|
+
@seed = seed.to_i
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def order=(type)
|
|
123
|
+
order, seed = type.to_s.split(':')
|
|
124
|
+
@seed = seed = seed.to_i if seed
|
|
125
|
+
|
|
126
|
+
ordering_name = if order.include?('rand')
|
|
127
|
+
:random
|
|
128
|
+
elsif order == 'defined'
|
|
129
|
+
:defined
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
register_ordering(:global, ordering_registry.fetch(ordering_name)) if ordering_name
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def force(hash)
|
|
136
|
+
if hash.has_key?(:seed)
|
|
137
|
+
self.seed = hash[:seed]
|
|
138
|
+
@seed_forced = true
|
|
139
|
+
@order_forced = true
|
|
140
|
+
elsif hash.has_key?(:order)
|
|
141
|
+
self.order = hash[:order]
|
|
142
|
+
@order_forced = true
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def register_ordering(name, strategy = Custom.new(Proc.new { |l| yield l }))
|
|
147
|
+
return if @order_forced && name == :global
|
|
148
|
+
ordering_registry.register(name, strategy)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
data/lib/rspec/core/pending.rb
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
module RSpec
|
|
2
2
|
module Core
|
|
3
3
|
module Pending
|
|
4
|
-
class
|
|
5
|
-
attr_reader :argument
|
|
6
|
-
|
|
7
|
-
def initialize(argument)
|
|
8
|
-
super(argument.to_s)
|
|
9
|
-
@argument = argument
|
|
10
|
-
end
|
|
11
|
-
end
|
|
4
|
+
class PendingDeclaredInExample < StandardError; end
|
|
12
5
|
|
|
13
6
|
# If Test::Unit is loaed, we'll use its error as baseclass, so that Test::Unit
|
|
14
7
|
# will report unmet RSpec expectations as failures rather than errors.
|
|
@@ -78,33 +71,10 @@ module RSpec
|
|
|
78
71
|
# it "does something", :pending => "something else getting finished" do
|
|
79
72
|
# # ...
|
|
80
73
|
# end
|
|
81
|
-
def pending(*args
|
|
82
|
-
RSpec.
|
|
83
|
-
|The semantics of `RSpec::Core::Pending#pending` are changing in
|
|
84
|
-
|RSpec 3. In RSpec 2.x, it caused the example to be skipped. In
|
|
85
|
-
|RSpec 3, the rest of the example will still be run but is expected
|
|
86
|
-
|to fail, and will be marked as a failure (rather than as pending)
|
|
87
|
-
|if the example passes.
|
|
88
|
-
|
|
|
89
|
-
|Any passed block will no longer be executed. This feature is being
|
|
90
|
-
|removed since it was semantically inconsistent, and the behaviour it
|
|
91
|
-
|offered is being made available with the other ways of marking an
|
|
92
|
-
|example pending.
|
|
93
|
-
|
|
|
94
|
-
|To keep the same skip semantics, change `pending` to `skip`.
|
|
95
|
-
|Otherwise, if you want the new RSpec 3 behavior, you can safely
|
|
96
|
-
|ignore this warning and continue to upgrade to RSpec 3 without
|
|
97
|
-
|addressing it.
|
|
98
|
-
|
|
|
99
|
-
|Called from #{CallerFilter.first_non_rspec_line}.
|
|
100
|
-
|
|
|
101
|
-
EOS
|
|
102
|
-
|
|
103
|
-
pending_no_warning(*args, &block)
|
|
104
|
-
end
|
|
74
|
+
def pending(*args)
|
|
75
|
+
current_example = RSpec.current_example
|
|
105
76
|
|
|
106
|
-
|
|
107
|
-
return self.class.before(:each) { pending(*args) } unless RSpec.current_example
|
|
77
|
+
return self.class.before(:each) { pending(*args) } unless current_example
|
|
108
78
|
|
|
109
79
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
110
80
|
message = args.first || NO_REASON_GIVEN
|
|
@@ -113,55 +83,28 @@ module RSpec
|
|
|
113
83
|
return block_given? ? yield : nil
|
|
114
84
|
end
|
|
115
85
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
86
|
+
current_example.metadata[:pending] = true
|
|
87
|
+
current_example.metadata[:execution_result][:pending_message] = message
|
|
88
|
+
current_example.execution_result[:pending_fixed] = false
|
|
119
89
|
if block_given?
|
|
120
90
|
begin
|
|
121
91
|
result = begin
|
|
122
92
|
yield
|
|
123
|
-
|
|
93
|
+
current_example.example_group_instance.instance_eval { verify_mocks_for_rspec }
|
|
124
94
|
end
|
|
125
|
-
|
|
95
|
+
current_example.metadata[:pending] = false
|
|
126
96
|
rescue Exception => e
|
|
127
|
-
|
|
97
|
+
current_example.execution_result[:exception] = e
|
|
128
98
|
ensure
|
|
129
99
|
teardown_mocks_for_rspec
|
|
130
100
|
end
|
|
131
101
|
if result
|
|
132
|
-
|
|
102
|
+
current_example.execution_result[:pending_fixed] = true
|
|
133
103
|
raise PendingExampleFixedError.new
|
|
134
104
|
end
|
|
135
105
|
end
|
|
136
|
-
raise
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
# Backport from RSpec 3 to aid in upgrading.
|
|
140
|
-
#
|
|
141
|
-
# Not using alias method because we explictly want to discard any block.
|
|
142
|
-
def skip(*args)
|
|
143
|
-
pending_no_warning(*args)
|
|
106
|
+
raise PendingDeclaredInExample.new(message)
|
|
144
107
|
end
|
|
145
|
-
|
|
146
|
-
def self.const_missing(name)
|
|
147
|
-
return super unless name == :PendingDeclaredInExample
|
|
148
|
-
|
|
149
|
-
RSpec.deprecate("RSpec::Core::PendingDeclaredInExample",
|
|
150
|
-
:replacement => "RSpec::Core::Pending::SkipDeclaredInExample")
|
|
151
|
-
|
|
152
|
-
SkipDeclaredInExample
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
# Alias the error for compatibility with extension gems (e.g. formatters)
|
|
157
|
-
# that depend on the const name of the error in RSpec <= 2.8.
|
|
158
|
-
def self.const_missing(name)
|
|
159
|
-
return super unless name == :PendingExampleFixedError
|
|
160
|
-
|
|
161
|
-
RSpec.deprecate("RSpec::Core::PendingExampleFixedError",
|
|
162
|
-
:replacement => "RSpec::Core::Pending::PendingExampleFixedError")
|
|
163
|
-
|
|
164
|
-
Pending::PendingExampleFixedError
|
|
165
108
|
end
|
|
166
109
|
end
|
|
167
110
|
end
|
|
@@ -8,10 +8,6 @@ module RSpec
|
|
|
8
8
|
def run
|
|
9
9
|
create_spec_helper_file
|
|
10
10
|
create_dot_rspec_file
|
|
11
|
-
delete_if_confirmed("autotest/discover.rb", <<-MESSAGE)
|
|
12
|
-
RSpec registers its own discover.rb with Autotest, so autotest/discover.rb is
|
|
13
|
-
no longer needed.
|
|
14
|
-
MESSAGE
|
|
15
11
|
|
|
16
12
|
delete_if_confirmed("lib/tasks/rspec.rake", <<-MESSAGE)
|
|
17
13
|
If the file in lib/tasks/rspec.rake is the one generated by rspec-rails-1x,
|
|
@@ -35,9 +31,9 @@ CONTENT
|
|
|
35
31
|
|
|
36
32
|
def create_spec_helper_file
|
|
37
33
|
if File.exist?('spec/spec_helper.rb')
|
|
38
|
-
report_exists(
|
|
34
|
+
report_exists('spec/spec_helper.rb')
|
|
39
35
|
else
|
|
40
|
-
report_creating(
|
|
36
|
+
report_creating('spec/spec_helper.rb')
|
|
41
37
|
FileUtils.mkdir_p('spec')
|
|
42
38
|
File.open('spec/spec_helper.rb','w') do |f|
|
|
43
39
|
f.write <<-CONTENT
|
|
@@ -48,15 +44,21 @@ CONTENT
|
|
|
48
44
|
#
|
|
49
45
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
50
46
|
RSpec.configure do |config|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
# Limit the spec run to only specs with the focus metadata. If no specs have
|
|
48
|
+
# the filtering metadata and `run_all_when_everything_filtered = true` then
|
|
49
|
+
# all specs will run.
|
|
50
|
+
#config.filter_run :focus
|
|
51
|
+
|
|
52
|
+
# Run all specs when none match the provided filter. This works well in
|
|
53
|
+
# conjunction with `config.filter_run :focus`, as it will run the entire
|
|
54
|
+
# suite when no specs have `:filter` metadata.
|
|
55
|
+
#config.run_all_when_everything_filtered = true
|
|
54
56
|
|
|
55
57
|
# Run specs in random order to surface order dependencies. If you find an
|
|
56
58
|
# order dependency and want to debug it, you can fix the order by providing
|
|
57
59
|
# the seed, which is printed after each run.
|
|
58
60
|
# --seed 1234
|
|
59
|
-
config.order = 'random'
|
|
61
|
+
#config.order = 'random'
|
|
60
62
|
end
|
|
61
63
|
CONTENT
|
|
62
64
|
end
|
data/lib/rspec/core/rake_task.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
require 'rspec/
|
|
2
|
-
require 'rspec/core/backward_compatibility'
|
|
1
|
+
require 'rspec/support/warnings'
|
|
3
2
|
require 'rake'
|
|
4
3
|
require 'rake/tasklib'
|
|
5
4
|
require 'shellwords'
|
|
@@ -21,31 +20,6 @@ module RSpec
|
|
|
21
20
|
# 'spec/**/*_spec.rb'
|
|
22
21
|
attr_accessor :pattern
|
|
23
22
|
|
|
24
|
-
# @deprecated
|
|
25
|
-
# Has no effect. The rake task now checks ENV['BUNDLE_GEMFILE'] instead.
|
|
26
|
-
def skip_bundler=(*)
|
|
27
|
-
deprecate("RSpec::Core::RakeTask#skip_bundler=")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# @deprecated
|
|
31
|
-
# Has no effect. The rake task now checks ENV['BUNDLE_GEMFILE'] instead.
|
|
32
|
-
def gemfile=(*)
|
|
33
|
-
deprecate("RSpec::Core::RakeTask#gemfile=", :replacement => 'ENV["BUNDLE_GEMFILE"]')
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# @deprecated
|
|
37
|
-
# Use ruby_opts="-w" instead.
|
|
38
|
-
#
|
|
39
|
-
# When true, requests that the specs be run with the warning flag set.
|
|
40
|
-
# e.g. "ruby -w"
|
|
41
|
-
#
|
|
42
|
-
# default:
|
|
43
|
-
# false
|
|
44
|
-
def warning=(true_or_false)
|
|
45
|
-
deprecate("RSpec::Core::RakeTask#warning=", :replacement => 'ruby_opts="-w"')
|
|
46
|
-
@warning = true_or_false
|
|
47
|
-
end
|
|
48
|
-
|
|
49
23
|
# Whether or not to fail Rake when an error occurs (typically when examples fail).
|
|
50
24
|
#
|
|
51
25
|
# default:
|
|
@@ -62,51 +36,6 @@ module RSpec
|
|
|
62
36
|
# true
|
|
63
37
|
attr_accessor :verbose
|
|
64
38
|
|
|
65
|
-
# Use rcov for code coverage?
|
|
66
|
-
#
|
|
67
|
-
# Due to the many ways `rcov` can run, if this option is enabled, it is
|
|
68
|
-
# required that `require 'rspec/autorun'` appears in `spec_helper`.rb
|
|
69
|
-
#
|
|
70
|
-
# default:
|
|
71
|
-
# false
|
|
72
|
-
def rcov
|
|
73
|
-
deprecate("RSpec::Core::RakeTask#rcov")
|
|
74
|
-
@rcov
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def rcov=(true_or_false)
|
|
78
|
-
deprecate("RSpec::Core::RakeTask#rcov=")
|
|
79
|
-
@rcov = true_or_false
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# Path to rcov.
|
|
83
|
-
#
|
|
84
|
-
# default:
|
|
85
|
-
# 'rcov'
|
|
86
|
-
def rcov_path
|
|
87
|
-
deprecate("RSpec::Core::RakeTask#rcov_path")
|
|
88
|
-
@rcov_path
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def rcov_path=(path)
|
|
92
|
-
deprecate("RSpec::Core::RakeTask#rcov_path=")
|
|
93
|
-
@rcov_path = path
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
# Command line options to pass to rcov.
|
|
97
|
-
#
|
|
98
|
-
# default:
|
|
99
|
-
# nil
|
|
100
|
-
def rcov_opts
|
|
101
|
-
deprecate("RSpec::Core::RakeTask#rcov_opts")
|
|
102
|
-
@rcov_opts
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def rcov_opts=(opts)
|
|
106
|
-
deprecate("RSpec::Core::RakeTask#rcov_opts=")
|
|
107
|
-
@rcov_opts = opts
|
|
108
|
-
end
|
|
109
|
-
|
|
110
39
|
# Command line options to pass to ruby.
|
|
111
40
|
#
|
|
112
41
|
# default:
|
|
@@ -133,7 +62,7 @@ module RSpec
|
|
|
133
62
|
# default:
|
|
134
63
|
# nil
|
|
135
64
|
def spec_opts=(opts)
|
|
136
|
-
deprecate('RSpec::Core::RakeTask#spec_opts=', :replacement => 'rspec_opts=')
|
|
65
|
+
RSpec.deprecate('RSpec::Core::RakeTask#spec_opts=', :replacement => 'rspec_opts=')
|
|
137
66
|
@rspec_opts = opts
|
|
138
67
|
end
|
|
139
68
|
|
|
@@ -152,11 +81,9 @@ module RSpec
|
|
|
152
81
|
|
|
153
82
|
def setup_ivars(args)
|
|
154
83
|
@name = args.shift || :spec
|
|
155
|
-
@
|
|
156
|
-
@warning, @rcov = false, false
|
|
84
|
+
@ruby_opts, @rspec_opts = nil, nil, nil
|
|
157
85
|
@verbose, @fail_on_error = true, true
|
|
158
86
|
|
|
159
|
-
@rcov_path = 'rcov'
|
|
160
87
|
@rspec_path = 'rspec'
|
|
161
88
|
@pattern = './spec{,/*/**}/*_spec.rb'
|
|
162
89
|
end
|
|
@@ -175,21 +102,11 @@ module RSpec
|
|
|
175
102
|
|
|
176
103
|
private
|
|
177
104
|
|
|
178
|
-
if "".respond_to?(:shellescape)
|
|
179
|
-
def shellescape(string)
|
|
180
|
-
string.shellescape
|
|
181
|
-
end
|
|
182
|
-
else # 1.8.6's shellwords doesn't provide shellescape :(.
|
|
183
|
-
def shellescape(string)
|
|
184
|
-
string.gsub(/"/, '\"').gsub(/'/, "\\\\'")
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
105
|
def files_to_run
|
|
189
106
|
if ENV['SPEC']
|
|
190
107
|
FileList[ ENV['SPEC'] ].sort
|
|
191
108
|
else
|
|
192
|
-
FileList[ pattern ].sort.map
|
|
109
|
+
FileList[ pattern ].sort.map(&:shellescape)
|
|
193
110
|
end
|
|
194
111
|
end
|
|
195
112
|
|
|
@@ -197,35 +114,15 @@ module RSpec
|
|
|
197
114
|
cmd_parts = []
|
|
198
115
|
cmd_parts << RUBY
|
|
199
116
|
cmd_parts << ruby_opts
|
|
200
|
-
cmd_parts << "-
|
|
201
|
-
cmd_parts << "-S" << runner
|
|
202
|
-
cmd_parts << "-Ispec:lib" << @rcov_opts if @rcov
|
|
117
|
+
cmd_parts << "-S" << rspec_path
|
|
203
118
|
cmd_parts << files_to_run
|
|
204
|
-
cmd_parts << "--" if @rcov && rspec_opts
|
|
205
119
|
cmd_parts << rspec_opts
|
|
206
120
|
cmd_parts.flatten.reject(&blank).join(" ")
|
|
207
121
|
end
|
|
208
122
|
|
|
209
|
-
def runner
|
|
210
|
-
@rcov ? @rcov_path : rspec_path
|
|
211
|
-
end
|
|
212
|
-
|
|
213
123
|
def blank
|
|
214
124
|
lambda {|s| s.nil? || s == ""}
|
|
215
125
|
end
|
|
216
|
-
|
|
217
|
-
def deprecate deprecated, opts = {}
|
|
218
|
-
# unless RSpec is loaded, deprecate won't work (simply requiring the
|
|
219
|
-
# deprecate file isn't enough) so this is a check for "is rspec already
|
|
220
|
-
# loaded?" "ok use the main deprecate hook" otherwise "simple fallback"
|
|
221
|
-
# Note that we don't need rspec to be loaded for the rake task to work
|
|
222
|
-
if RSpec.respond_to?(:deprecate)
|
|
223
|
-
RSpec.deprecate deprecated, opts
|
|
224
|
-
else
|
|
225
|
-
warn "DEPRECATION: #{deprecated} is deprecated."
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
|
|
229
126
|
end
|
|
230
127
|
end
|
|
231
128
|
end
|