rspec-core 2.13.1 → 2.14.0.rc1
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/Changelog.md +80 -0
- data/exe/autospec +1 -1
- data/features/README.md +2 -2
- data/features/command_line/format_option.feature +8 -14
- data/features/command_line/line_number_appended_to_path.feature +4 -4
- data/features/command_line/line_number_option.feature +1 -1
- data/features/command_line/rake_task.feature +2 -2
- data/features/command_line/require_option.feature +43 -0
- data/features/command_line/ruby.feature +2 -2
- data/features/command_line/warnings_option.feature +27 -0
- data/features/configuration/backtrace_clean_patterns.feature +2 -2
- data/features/configuration/deprecation_stream.feature +58 -0
- data/features/configuration/pattern.feature +8 -0
- data/features/configuration/profile.feature +59 -2
- data/features/configuration/read_options_from_file.feature +8 -5
- data/features/configuration/run_all_when_everything_filtered.feature +20 -4
- data/features/example_groups/basic_structure.feature +1 -1
- data/features/example_groups/shared_context.feature +1 -1
- data/features/example_groups/shared_examples.feature +72 -0
- data/features/filtering/exclusion_filters.feature +10 -10
- data/features/formatters/custom_formatter.feature +1 -1
- data/features/hooks/before_and_after_hooks.feature +19 -19
- data/features/mock_framework_integration/use_any_framework.feature +6 -6
- data/features/mock_framework_integration/use_flexmock.feature +3 -3
- data/features/mock_framework_integration/use_mocha.feature +3 -3
- data/features/mock_framework_integration/use_rr.feature +3 -3
- data/features/mock_framework_integration/use_rspec.feature +3 -3
- data/features/subject/implicit_subject.feature +1 -1
- data/lib/rspec/core.rb +20 -3
- data/lib/rspec/core/backtrace_cleaner.rb +46 -0
- data/lib/rspec/core/backward_compatibility.rb +3 -13
- data/lib/rspec/core/configuration.rb +136 -49
- data/lib/rspec/core/configuration_options.rb +19 -8
- data/lib/rspec/core/deprecation.rb +18 -30
- data/lib/rspec/core/example.rb +3 -3
- data/lib/rspec/core/example_group.rb +4 -3
- data/lib/rspec/core/extensions/kernel.rb +1 -1
- data/lib/rspec/core/filter_manager.rb +1 -1
- data/lib/rspec/core/formatters.rb +1 -1
- data/lib/rspec/core/formatters/base_formatter.rb +10 -1
- data/lib/rspec/core/formatters/base_text_formatter.rb +47 -10
- data/lib/rspec/core/formatters/deprecation_formatter.rb +35 -0
- data/lib/rspec/core/formatters/helpers.rb +12 -5
- data/lib/rspec/core/formatters/html_formatter.rb +7 -6
- data/lib/rspec/core/formatters/html_printer.rb +13 -12
- data/lib/rspec/core/formatters/json_formatter.rb +1 -2
- data/lib/rspec/core/formatters/text_mate_formatter.rb +1 -1
- data/lib/rspec/core/hooks.rb +9 -0
- data/lib/rspec/core/memoized_helpers.rb +19 -8
- data/lib/rspec/core/metadata.rb +3 -1
- data/lib/rspec/core/mocking/with_flexmock.rb +1 -1
- data/lib/rspec/core/mocking/with_rr.rb +1 -1
- data/lib/rspec/core/option_parser.rb +6 -2
- data/lib/rspec/core/pending.rb +1 -0
- data/lib/rspec/core/rake_task.rb +11 -19
- data/lib/rspec/core/reporter.rb +33 -4
- data/lib/rspec/core/shared_example_group.rb +56 -16
- data/lib/rspec/core/shared_example_group/collection.rb +42 -0
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +2 -3
- data/spec/autotest/rspec_spec.rb +2 -2
- data/spec/rspec/core/backtrace_cleaner_spec.rb +68 -0
- data/spec/rspec/core/configuration_options_spec.rb +15 -4
- data/spec/rspec/core/configuration_spec.rb +202 -19
- data/spec/rspec/core/deprecation_spec.rb +41 -0
- data/spec/rspec/core/deprecations_spec.rb +10 -12
- data/spec/rspec/core/drb_command_line_spec.rb +1 -1
- data/spec/rspec/core/example_group_spec.rb +37 -36
- data/spec/rspec/core/example_spec.rb +25 -4
- data/spec/rspec/core/filter_manager_spec.rb +6 -6
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +101 -36
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +78 -0
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +2 -2
- data/spec/rspec/core/formatters/helpers_spec.rb +23 -7
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +20 -14
- data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +69 -169
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +28 -23
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +42 -33
- data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +17 -23
- data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +57 -157
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +42 -33
- data/spec/rspec/core/formatters/html_formatted-2.0.0.html +42 -33
- data/spec/rspec/core/formatters/html_formatter_spec.rb +1 -0
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +3 -3
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +11 -14
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-rbx.html +103 -203
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +30 -25
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +42 -33
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-jruby.html +20 -14
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-rbx.html +103 -203
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +42 -33
- data/spec/rspec/core/formatters/text_mate_formatted-2.0.0.html +42 -33
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +1 -0
- data/spec/rspec/core/memoized_helpers_spec.rb +28 -0
- data/spec/rspec/core/metadata_spec.rb +8 -3
- data/spec/rspec/core/option_parser_spec.rb +8 -0
- data/spec/rspec/core/project_initializer_spec.rb +2 -2
- data/spec/rspec/core/rake_task_spec.rb +8 -8
- data/spec/rspec/core/reporter_spec.rb +26 -6
- data/spec/rspec/core/resources/formatter_specs.rb +3 -3
- data/spec/rspec/core/shared_context_spec.rb +20 -0
- data/spec/rspec/core/shared_example_group/collection_spec.rb +70 -0
- data/spec/rspec/core/shared_example_group_spec.rb +4 -4
- data/spec/rspec/core/world_spec.rb +1 -3
- data/spec/rspec/core_spec.rb +20 -0
- data/spec/spec_helper.rb +29 -29
- data/spec/support/helper_methods.rb +9 -1
- data/spec/support/isolate_load_path_mutation.rb +6 -0
- data/spec/support/sandboxed_mock_space.rb +100 -0
- metadata +28 -13
- data/features/filtering/run_all_when_everything_filtered.feature +0 -46
- data/lib/rspec/core/load_path.rb +0 -3
@@ -19,7 +19,7 @@ Feature: mock with rspec
|
|
19
19
|
end
|
20
20
|
"""
|
21
21
|
When I run `rspec example_spec.rb`
|
22
|
-
Then the examples should all pass
|
22
|
+
Then the examples should all pass
|
23
23
|
|
24
24
|
Scenario: failing message expecation
|
25
25
|
Given a file named "example_spec.rb" with:
|
@@ -80,7 +80,7 @@ Feature: mock with rspec
|
|
80
80
|
Then the output should contain "1 example, 1 failure"
|
81
81
|
And the exit status should be 1
|
82
82
|
|
83
|
-
Scenario: accessing RSpec.configuration.mock_framework.framework_name
|
83
|
+
Scenario: accessing RSpec.configuration.mock_framework.framework_name
|
84
84
|
Given a file named "example_spec.rb" with:
|
85
85
|
"""ruby
|
86
86
|
RSpec.configure do |config|
|
@@ -94,4 +94,4 @@ Feature: mock with rspec
|
|
94
94
|
end
|
95
95
|
"""
|
96
96
|
When I run `rspec example_spec.rb`
|
97
|
-
Then the examples should all pass
|
97
|
+
Then the examples should all pass
|
@@ -6,7 +6,7 @@ Feature: implicitly defined subject
|
|
6
6
|
While the examples below demonstrate how `subject` can be used as a
|
7
7
|
user-facing concept, we recommend that you reserve it for support of custom
|
8
8
|
matchers and/or extension libraries that hide its use from examples.
|
9
|
-
|
9
|
+
|
10
10
|
Scenario: subject exposed in top level group
|
11
11
|
Given a file named "top_level_subject_spec.rb" with:
|
12
12
|
"""ruby
|
data/lib/rspec/core.rb
CHANGED
@@ -9,6 +9,7 @@ else
|
|
9
9
|
end
|
10
10
|
|
11
11
|
require 'set'
|
12
|
+
require 'time'
|
12
13
|
require 'rbconfig'
|
13
14
|
require_rspec['core/filter_manager']
|
14
15
|
require_rspec['core/dsl']
|
@@ -16,7 +17,6 @@ require_rspec['core/extensions/kernel']
|
|
16
17
|
require_rspec['core/extensions/instance_eval_with_args']
|
17
18
|
require_rspec['core/extensions/module_eval_with_args']
|
18
19
|
require_rspec['core/extensions/ordered']
|
19
|
-
require_rspec['core/load_path']
|
20
20
|
require_rspec['core/deprecation']
|
21
21
|
require_rspec['core/backward_compatibility']
|
22
22
|
require_rspec['core/reporter']
|
@@ -36,6 +36,7 @@ require_rspec['core/configuration_options']
|
|
36
36
|
require_rspec['core/command_line']
|
37
37
|
require_rspec['core/runner']
|
38
38
|
require_rspec['core/example']
|
39
|
+
require_rspec['core/shared_example_group/collection']
|
39
40
|
require_rspec['core/shared_example_group']
|
40
41
|
require_rspec['core/example_group']
|
41
42
|
require_rspec['core/version']
|
@@ -61,6 +62,12 @@ module RSpec
|
|
61
62
|
@world ||= RSpec::Core::World.new
|
62
63
|
end
|
63
64
|
|
65
|
+
# @private
|
66
|
+
# Used internally to set the global object
|
67
|
+
def self.world=(new_world)
|
68
|
+
@world = new_world
|
69
|
+
end
|
70
|
+
|
64
71
|
# @private
|
65
72
|
# Used internally to ensure examples get reloaded between multiple runs in
|
66
73
|
# the same process.
|
@@ -95,6 +102,12 @@ WARNING
|
|
95
102
|
@configuration ||= RSpec::Core::Configuration.new
|
96
103
|
end
|
97
104
|
|
105
|
+
# @private
|
106
|
+
# Used internally to set the global object
|
107
|
+
def self.configuration=(new_configuration)
|
108
|
+
@configuration = new_configuration
|
109
|
+
end
|
110
|
+
|
98
111
|
# Yields the global configuration to a block.
|
99
112
|
# @yield [Configuration] global configuration
|
100
113
|
#
|
@@ -115,7 +128,7 @@ WARNING
|
|
115
128
|
|
116
129
|
# @private
|
117
130
|
def self.windows_os?
|
118
|
-
|
131
|
+
RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/
|
119
132
|
end
|
120
133
|
|
121
134
|
module Core
|
@@ -123,7 +136,11 @@ WARNING
|
|
123
136
|
# This avoids issues with reporting time caused by examples that
|
124
137
|
# change the value/meaning of Time.now without properly restoring
|
125
138
|
# it.
|
126
|
-
|
139
|
+
class Time
|
140
|
+
class << self
|
141
|
+
define_method(:now,&::Time.method(:now))
|
142
|
+
end
|
143
|
+
end
|
127
144
|
end
|
128
145
|
|
129
146
|
def self.const_missing(name)
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Core
|
3
|
+
class BacktraceCleaner
|
4
|
+
|
5
|
+
DEFAULT_EXCLUSION_PATTERNS = [
|
6
|
+
/\/lib\d*\/ruby\//,
|
7
|
+
/org\/jruby\//,
|
8
|
+
/bin\//,
|
9
|
+
%r|/gems/|,
|
10
|
+
/spec\/spec_helper\.rb/,
|
11
|
+
/lib\/rspec\/(core|expectations|matchers|mocks)/
|
12
|
+
]
|
13
|
+
|
14
|
+
attr_accessor :inclusion_patterns
|
15
|
+
attr_accessor :exclusion_patterns
|
16
|
+
|
17
|
+
def initialize(inclusion_patterns=nil, exclusion_patterns=DEFAULT_EXCLUSION_PATTERNS.dup)
|
18
|
+
@exclusion_patterns = exclusion_patterns
|
19
|
+
|
20
|
+
if inclusion_patterns.nil?
|
21
|
+
@inclusion_patterns = (matches_an_exclusion_pattern? Dir.getwd) ? [Regexp.new(Dir.getwd)] : []
|
22
|
+
else
|
23
|
+
@inclusion_patterns = inclusion_patterns
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def exclude?(line)
|
28
|
+
@inclusion_patterns.none? {|p| line =~ p} and matches_an_exclusion_pattern?(line)
|
29
|
+
end
|
30
|
+
|
31
|
+
def full_backtrace=(true_or_false)
|
32
|
+
@exclusion_patterns = true_or_false ? [] : DEFAULT_EXCLUSION_PATTERNS.dup
|
33
|
+
end
|
34
|
+
|
35
|
+
def full_backtrace?
|
36
|
+
@exclusion_patterns.empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def matches_an_exclusion_pattern?(line)
|
42
|
+
@exclusion_patterns.any? {|p| line =~ p}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -7,17 +7,7 @@ module RSpec
|
|
7
7
|
def const_missing(name)
|
8
8
|
case name
|
9
9
|
when :Rspec, :Spec
|
10
|
-
RSpec.
|
11
|
-
*****************************************************************
|
12
|
-
DEPRECATION WARNING: you are using a deprecated constant that will
|
13
|
-
be removed from a future version of RSpec.
|
14
|
-
|
15
|
-
#{caller(0)[2]}
|
16
|
-
|
17
|
-
* #{name} is deprecated.
|
18
|
-
* RSpec is the new top-level module in RSpec-2
|
19
|
-
*****************************************************************
|
20
|
-
WARNING
|
10
|
+
RSpec.deprecate(name.to_s, :replacement => "RSpec")
|
21
11
|
RSpec
|
22
12
|
else
|
23
13
|
begin
|
@@ -34,7 +24,7 @@ WARNING
|
|
34
24
|
module Runner
|
35
25
|
# @deprecated use RSpec.configure instead.
|
36
26
|
def self.configure(&block)
|
37
|
-
RSpec.deprecate("Spec::Runner.configure", "RSpec.configure")
|
27
|
+
RSpec.deprecate("Spec::Runner.configure", :replacement => "RSpec.configure")
|
38
28
|
RSpec.configure(&block)
|
39
29
|
end
|
40
30
|
end
|
@@ -46,7 +36,7 @@ WARNING
|
|
46
36
|
def self.const_missing(name)
|
47
37
|
case name
|
48
38
|
when :SpecTask
|
49
|
-
RSpec.deprecate("Spec::Rake::SpecTask", "RSpec::Core::RakeTask")
|
39
|
+
RSpec.deprecate("Spec::Rake::SpecTask", :replacement => "RSpec::Core::RakeTask")
|
50
40
|
require 'rspec/core/rake_task'
|
51
41
|
RSpec::Core::RakeTask
|
52
42
|
else
|
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'rspec/core/backtrace_cleaner'
|
3
|
+
require 'rspec/core/ruby_project'
|
4
|
+
require 'rspec/core/formatters/deprecation_formatter.rb'
|
2
5
|
|
3
6
|
module RSpec
|
4
7
|
module Core
|
@@ -32,19 +35,15 @@ module RSpec
|
|
32
35
|
|
33
36
|
# @private
|
34
37
|
def self.define_reader(name)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
CODE
|
38
|
+
define_method(name) do
|
39
|
+
variable = instance_variable_defined?("@#{name}") ? instance_variable_get("@#{name}") : nil
|
40
|
+
value_for(name, variable)
|
41
|
+
end
|
40
42
|
end
|
41
43
|
|
42
44
|
# @private
|
43
45
|
def self.deprecate_alias_key
|
44
|
-
RSpec.
|
45
|
-
The :alias option to add_setting is deprecated. Use :alias_with on the original setting instead.
|
46
|
-
Called from #{caller(0)[5]}
|
47
|
-
MESSAGE
|
46
|
+
RSpec.deprecate("add_setting with :alias option", :replacement => ":alias_with")
|
48
47
|
end
|
49
48
|
|
50
49
|
# @private
|
@@ -80,15 +79,6 @@ MESSAGE
|
|
80
79
|
|
81
80
|
# @macro [attach] add_setting
|
82
81
|
# @attribute $1
|
83
|
-
# Patterns to match against lines in backtraces presented in failure
|
84
|
-
# messages in order to filter them out (default:
|
85
|
-
# DEFAULT_BACKTRACE_PATTERNS). You can either replace this list using
|
86
|
-
# the setter or modify it using the getter.
|
87
|
-
#
|
88
|
-
# To override this behavior and display a full backtrace, use
|
89
|
-
# `--backtrace` on the command line, in a `.rspec` file, or in the
|
90
|
-
# `rspec_options` attribute of RSpec's rake task.
|
91
|
-
add_setting :backtrace_clean_patterns
|
92
82
|
|
93
83
|
# Path to use if no path is provided to the `rspec` command (default:
|
94
84
|
# `"spec"`). Allows you to just type `rspec` instead of `rspec spec` to
|
@@ -105,6 +95,9 @@ MESSAGE
|
|
105
95
|
# Default: `$stderr`.
|
106
96
|
add_setting :error_stream
|
107
97
|
|
98
|
+
# Default: `$stderr`.
|
99
|
+
add_setting :deprecation_stream
|
100
|
+
|
108
101
|
# Clean up and exit after the first failure (default: `false`).
|
109
102
|
add_setting :fail_fast
|
110
103
|
|
@@ -115,6 +108,12 @@ MESSAGE
|
|
115
108
|
# load order for files, declaration order for groups and examples).
|
116
109
|
define_reader :order
|
117
110
|
|
111
|
+
# Indicates files configured to be required
|
112
|
+
define_reader :requires
|
113
|
+
|
114
|
+
# Returns dirs that have been prepended to the load path by #lib=
|
115
|
+
define_reader :libs
|
116
|
+
|
118
117
|
# Default: `$stdout`.
|
119
118
|
# Also known as `output` and `out`
|
120
119
|
add_setting :output_stream, :alias_with => [:output, :out]
|
@@ -182,14 +181,7 @@ MESSAGE
|
|
182
181
|
# @private
|
183
182
|
attr_accessor :filter_manager
|
184
183
|
|
185
|
-
|
186
|
-
/\/lib\d*\/ruby\//,
|
187
|
-
/org\/jruby\//,
|
188
|
-
/bin\//,
|
189
|
-
%r|/gems/|,
|
190
|
-
/spec\/spec_helper\.rb/,
|
191
|
-
/lib\/rspec\/(core|expectations|matchers|mocks)/
|
192
|
-
]
|
184
|
+
attr_reader :backtrace_cleaner
|
193
185
|
|
194
186
|
def initialize
|
195
187
|
@expectation_frameworks = []
|
@@ -200,8 +192,11 @@ MESSAGE
|
|
200
192
|
@color = false
|
201
193
|
@pattern = '**/*_spec.rb'
|
202
194
|
@failure_exit_code = 1
|
203
|
-
|
195
|
+
|
196
|
+
@backtrace_cleaner = BacktraceCleaner.new
|
197
|
+
|
204
198
|
@default_path = 'spec'
|
199
|
+
@deprecation_stream = $stderr
|
205
200
|
@filter_manager = FilterManager.new
|
206
201
|
@preferred_options = {}
|
207
202
|
@seed = srand % 0xFFFF
|
@@ -212,6 +207,8 @@ MESSAGE
|
|
212
207
|
@fixed_color = :blue
|
213
208
|
@detail_color = :cyan
|
214
209
|
@profile_examples = false
|
210
|
+
@requires = []
|
211
|
+
@libs = []
|
215
212
|
end
|
216
213
|
|
217
214
|
# @private
|
@@ -224,6 +221,7 @@ MESSAGE
|
|
224
221
|
set_order_and_seed(hash)
|
225
222
|
end
|
226
223
|
@preferred_options.merge!(hash)
|
224
|
+
self.warnings = value_for :warnings, nil
|
227
225
|
end
|
228
226
|
|
229
227
|
# @private
|
@@ -275,15 +273,6 @@ MESSAGE
|
|
275
273
|
send("#{name}=", default) if default
|
276
274
|
end
|
277
275
|
|
278
|
-
# Used by formatters to ask whether a backtrace line should be displayed
|
279
|
-
# or not, based on the line matching any `backtrace_clean_patterns`.
|
280
|
-
def cleaned_from_backtrace?(line)
|
281
|
-
# TODO (David 2011-12-25) why are we asking the configuration to do
|
282
|
-
# stuff? Either use the patterns directly or enapsulate the filtering
|
283
|
-
# in a BacktraceCleaner object.
|
284
|
-
backtrace_clean_patterns.any? { |regex| line =~ regex }
|
285
|
-
end
|
286
|
-
|
287
276
|
# Returns the configured mock framework adapter module
|
288
277
|
def mock_framework
|
289
278
|
mock_with :rspec unless @mock_framework
|
@@ -295,6 +284,62 @@ MESSAGE
|
|
295
284
|
mock_with framework
|
296
285
|
end
|
297
286
|
|
287
|
+
# The patterns to discard from backtraces. Deprecated, use
|
288
|
+
# Configuration#backtrace_exclusion_patterns instead
|
289
|
+
#
|
290
|
+
# Defaults to RSpec::Core::BacktraceCleaner::DEFAULT_EXCLUSION_PATTERNS
|
291
|
+
#
|
292
|
+
# One can replace the list by using the setter or modify it through the
|
293
|
+
# getter
|
294
|
+
#
|
295
|
+
# To override this behaviour and display a full backtrace, use
|
296
|
+
# `--backtrace`on the command line, in a `.rspec` file, or in the
|
297
|
+
# `rspec_options` attribute of RSpec's rake task.
|
298
|
+
def backtrace_clean_patterns
|
299
|
+
RSpec.deprecate("RSpec::Core::Configuration#backtrace_clean_patterns",
|
300
|
+
:replacement => "RSpec::Core::Configuration#backtrace_exclusion_patterns")
|
301
|
+
@backtrace_cleaner.exclusion_patterns
|
302
|
+
end
|
303
|
+
|
304
|
+
def backtrace_clean_patterns=(patterns)
|
305
|
+
RSpec.deprecate("RSpec::Core::Configuration#backtrace_clean_patterns",
|
306
|
+
:replacement => "RSpec::Core::Configuration#backtrace_exclusion_patterns")
|
307
|
+
@backtrace_cleaner.exclusion_patterns = patterns
|
308
|
+
end
|
309
|
+
|
310
|
+
# The patterns to always include to backtraces.
|
311
|
+
#
|
312
|
+
# Defaults to [Regexp.new Dir.getwd] if the current working directory
|
313
|
+
# matches any of the exclusion patterns. Otherwise it defaults to empty.
|
314
|
+
#
|
315
|
+
# One can replace the list by using the setter or modify it through the
|
316
|
+
# getter
|
317
|
+
def backtrace_inclusion_patterns
|
318
|
+
@backtrace_cleaner.inclusion_patterns
|
319
|
+
end
|
320
|
+
|
321
|
+
def backtrace_inclusion_patterns=(patterns)
|
322
|
+
@backtrace_cleaner.inclusion_patterns = patterns
|
323
|
+
end
|
324
|
+
|
325
|
+
# The patterns to discard from backtraces.
|
326
|
+
#
|
327
|
+
# Defaults to RSpec::Core::BacktraceCleaner::DEFAULT_EXCLUSION_PATTERNS
|
328
|
+
#
|
329
|
+
# One can replace the list by using the setter or modify it through the
|
330
|
+
# getter
|
331
|
+
#
|
332
|
+
# To override this behaviour and display a full backtrace, use
|
333
|
+
# `--backtrace`on the command line, in a `.rspec` file, or in the
|
334
|
+
# `rspec_options` attribute of RSpec's rake task.
|
335
|
+
def backtrace_exclusion_patterns
|
336
|
+
@backtrace_cleaner.exclusion_patterns
|
337
|
+
end
|
338
|
+
|
339
|
+
def backtrace_exclusion_patterns=(patterns)
|
340
|
+
@backtrace_cleaner.exclusion_patterns = patterns
|
341
|
+
end
|
342
|
+
|
298
343
|
# Sets the mock framework adapter module.
|
299
344
|
#
|
300
345
|
# `framework` can be a Symbol or a Module.
|
@@ -423,8 +468,12 @@ MESSAGE
|
|
423
468
|
@expectation_frameworks.push(*modules)
|
424
469
|
end
|
425
470
|
|
471
|
+
def full_backtrace?
|
472
|
+
@backtrace_cleaner.full_backtrace?
|
473
|
+
end
|
474
|
+
|
426
475
|
def full_backtrace=(true_or_false)
|
427
|
-
@
|
476
|
+
@backtrace_cleaner.full_backtrace = true_or_false
|
428
477
|
end
|
429
478
|
|
430
479
|
def color(output=output_stream)
|
@@ -453,11 +502,17 @@ MESSAGE
|
|
453
502
|
define_predicate_for :color_enabled, :color
|
454
503
|
|
455
504
|
def libs=(libs)
|
456
|
-
libs.map
|
505
|
+
libs.map do |lib|
|
506
|
+
@libs.unshift lib
|
507
|
+
$LOAD_PATH.unshift lib
|
508
|
+
end
|
457
509
|
end
|
458
510
|
|
459
511
|
def requires=(paths)
|
512
|
+
RSpec.deprecate("RSpec::Core::Configuration#requires=(paths)",
|
513
|
+
:replacement => "paths.each {|path| require path}")
|
460
514
|
paths.map {|path| require path}
|
515
|
+
@requires += paths
|
461
516
|
end
|
462
517
|
|
463
518
|
def debug=(bool)
|
@@ -481,15 +536,27 @@ EOM
|
|
481
536
|
end
|
482
537
|
end
|
483
538
|
|
539
|
+
def debug?
|
540
|
+
!!defined?(Debugger)
|
541
|
+
end
|
542
|
+
|
484
543
|
# Run examples defined on `line_numbers` in all files to run.
|
485
544
|
def line_numbers=(line_numbers)
|
486
545
|
filter_run :line_numbers => line_numbers.map{|l| l.to_i}
|
487
546
|
end
|
488
547
|
|
548
|
+
def line_numbers
|
549
|
+
filter.fetch(:line_numbers,[])
|
550
|
+
end
|
551
|
+
|
489
552
|
def full_description=(description)
|
490
553
|
filter_run :full_description => Regexp.union(*Array(description).map {|d| Regexp.new(d) })
|
491
554
|
end
|
492
555
|
|
556
|
+
def full_description
|
557
|
+
filter.fetch :full_description, nil
|
558
|
+
end
|
559
|
+
|
493
560
|
# @overload add_formatter(formatter)
|
494
561
|
#
|
495
562
|
# Adds a formatter to the formatters collection. `formatter` can be a
|
@@ -499,15 +566,16 @@ EOM
|
|
499
566
|
# ### Note
|
500
567
|
#
|
501
568
|
# For internal purposes, `add_formatter` also accepts the name of a class
|
502
|
-
# and
|
503
|
-
#
|
504
|
-
def add_formatter(formatter_to_use,
|
569
|
+
# and paths to use for output streams, but you should consider that a
|
570
|
+
# private api that may change at any time without notice.
|
571
|
+
def add_formatter(formatter_to_use, *paths)
|
505
572
|
formatter_class =
|
506
573
|
built_in_formatter(formatter_to_use) ||
|
507
574
|
custom_formatter(formatter_to_use) ||
|
508
575
|
(raise ArgumentError, "Formatter '#{formatter_to_use}' unknown - maybe you meant 'documentation' or 'progress'?.")
|
509
576
|
|
510
|
-
|
577
|
+
paths << output if paths.empty?
|
578
|
+
formatters << formatter_class.new(*paths.map {|p| String === p ? file_at(p) : p})
|
511
579
|
end
|
512
580
|
|
513
581
|
alias_method :formatter=, :add_formatter
|
@@ -519,6 +587,7 @@ EOM
|
|
519
587
|
def reporter
|
520
588
|
@reporter ||= begin
|
521
589
|
add_formatter('progress') if formatters.empty?
|
590
|
+
add_formatter(RSpec::Core::Formatters::DeprecationFormatter, deprecation_stream, output_stream)
|
522
591
|
Reporter.new(*formatters)
|
523
592
|
end
|
524
593
|
end
|
@@ -791,6 +860,14 @@ EOM
|
|
791
860
|
host.send(:include,mod) unless host < mod
|
792
861
|
end
|
793
862
|
|
863
|
+
# @private
|
864
|
+
def setup_load_path_and_require(paths)
|
865
|
+
directories = ['lib', default_path].select { |p| File.directory? p }
|
866
|
+
RSpec::Core::RubyProject.add_to_load_path(*directories)
|
867
|
+
paths.each {|path| require path}
|
868
|
+
@requires += paths
|
869
|
+
end
|
870
|
+
|
794
871
|
# @private
|
795
872
|
if RUBY_VERSION.to_f >= 1.9
|
796
873
|
def safe_extend(mod, host)
|
@@ -863,7 +940,9 @@ EOM
|
|
863
940
|
# @private
|
864
941
|
RANDOM_ORDERING = lambda do |list|
|
865
942
|
Kernel.srand RSpec.configuration.seed
|
866
|
-
list.sort_by { Kernel.rand(list.size) }
|
943
|
+
ordering = list.sort_by { Kernel.rand(list.size) }
|
944
|
+
Kernel.srand # reset random generation
|
945
|
+
ordering
|
867
946
|
end
|
868
947
|
|
869
948
|
# Sets a strategy by which to order examples.
|
@@ -930,20 +1009,28 @@ EOM
|
|
930
1009
|
order_examples(&block)
|
931
1010
|
end
|
932
1011
|
|
1012
|
+
# Set Ruby warnings on or off
|
1013
|
+
def warnings= value
|
1014
|
+
$VERBOSE = !!value
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
def warnings
|
1018
|
+
$VERBOSE
|
1019
|
+
end
|
1020
|
+
|
933
1021
|
private
|
934
1022
|
|
935
1023
|
def get_files_to_run(paths)
|
936
|
-
patterns = pattern.split(",")
|
937
1024
|
paths.map do |path|
|
938
1025
|
path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
|
939
|
-
File.directory?(path) ? gather_directories(path
|
1026
|
+
File.directory?(path) ? gather_directories(path) : extract_location(path)
|
940
1027
|
end.flatten.sort
|
941
1028
|
end
|
942
1029
|
|
943
|
-
def gather_directories(path
|
944
|
-
|
945
|
-
|
946
|
-
|
1030
|
+
def gather_directories(path)
|
1031
|
+
stripped = "{#{pattern.gsub(/\s*,\s*/, ',')}}"
|
1032
|
+
files = pattern =~ /^#{Regexp.escape path}/ ? Dir[stripped] : Dir["#{path}/#{stripped}"]
|
1033
|
+
files.sort
|
947
1034
|
end
|
948
1035
|
|
949
1036
|
def extract_location(path)
|