rspec-core 3.1.7 → 3.2.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +84 -0
- data/README.md +10 -1
- data/lib/rspec/core.rb +28 -8
- data/lib/rspec/core/backport_random.rb +12 -9
- data/lib/rspec/core/configuration.rb +350 -112
- data/lib/rspec/core/configuration_options.rb +14 -7
- data/lib/rspec/core/dsl.rb +7 -4
- data/lib/rspec/core/example.rb +86 -50
- data/lib/rspec/core/example_group.rb +247 -86
- data/lib/rspec/core/filter_manager.rb +38 -93
- data/lib/rspec/core/flat_map.rb +4 -4
- data/lib/rspec/core/formatters.rb +10 -6
- data/lib/rspec/core/formatters/base_formatter.rb +7 -4
- data/lib/rspec/core/formatters/base_text_formatter.rb +12 -12
- data/lib/rspec/core/formatters/console_codes.rb +8 -7
- data/lib/rspec/core/formatters/deprecation_formatter.rb +5 -3
- data/lib/rspec/core/formatters/documentation_formatter.rb +10 -4
- data/lib/rspec/core/formatters/helpers.rb +6 -4
- data/lib/rspec/core/formatters/html_formatter.rb +13 -8
- data/lib/rspec/core/formatters/html_printer.rb +26 -10
- data/lib/rspec/core/formatters/profile_formatter.rb +10 -7
- data/lib/rspec/core/formatters/protocol.rb +27 -18
- data/lib/rspec/core/formatters/snippet_extractor.rb +14 -7
- data/lib/rspec/core/hooks.rb +252 -211
- data/lib/rspec/core/memoized_helpers.rb +16 -16
- data/lib/rspec/core/metadata.rb +67 -28
- data/lib/rspec/core/metadata_filter.rb +151 -24
- data/lib/rspec/core/minitest_assertions_adapter.rb +5 -2
- data/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
- data/lib/rspec/core/mocking_adapters/mocha.rb +8 -8
- data/lib/rspec/core/notifications.rb +155 -94
- data/lib/rspec/core/option_parser.rb +16 -10
- data/lib/rspec/core/pending.rb +11 -9
- data/lib/rspec/core/project_initializer.rb +1 -1
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +10 -8
- data/lib/rspec/core/rake_task.rb +37 -52
- data/lib/rspec/core/reporter.rb +30 -7
- data/lib/rspec/core/ruby_project.rb +12 -4
- data/lib/rspec/core/runner.rb +5 -8
- data/lib/rspec/core/sandbox.rb +37 -0
- data/lib/rspec/core/shared_example_group.rb +41 -15
- data/lib/rspec/core/test_unit_assertions_adapter.rb +3 -3
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/warnings.rb +2 -2
- data/lib/rspec/core/world.rb +12 -28
- metadata +44 -31
- metadata.gz.sig +0 -0
@@ -25,9 +25,9 @@ module RSpec::Core
|
|
25
25
|
OptionParser.new do |parser|
|
26
26
|
parser.banner = "Usage: rspec [options] [files or directories]\n\n"
|
27
27
|
|
28
|
-
parser.on('-I PATH', 'Specify PATH to add to $LOAD_PATH (may be used more than once).') do |
|
28
|
+
parser.on('-I PATH', 'Specify PATH to add to $LOAD_PATH (may be used more than once).') do |dirs|
|
29
29
|
options[:libs] ||= []
|
30
|
-
options[:libs]
|
30
|
+
options[:libs].concat(dirs.split(File::PATH_SEPARATOR))
|
31
31
|
end
|
32
32
|
|
33
33
|
parser.on('-r', '--require PATH', 'Require a file.') do |path|
|
@@ -59,7 +59,8 @@ module RSpec::Core
|
|
59
59
|
options[:fail_fast] = false
|
60
60
|
end
|
61
61
|
|
62
|
-
parser.on('--failure-exit-code CODE', Integer,
|
62
|
+
parser.on('--failure-exit-code CODE', Integer,
|
63
|
+
'Override the exit code used when there are failing specs.') do |code|
|
63
64
|
options[:failure_exit_code] = code
|
64
65
|
end
|
65
66
|
|
@@ -115,7 +116,8 @@ module RSpec::Core
|
|
115
116
|
options[:color] = o
|
116
117
|
end
|
117
118
|
|
118
|
-
parser.on('-p', '--[no-]profile [COUNT]',
|
119
|
+
parser.on('-p', '--[no-]profile [COUNT]',
|
120
|
+
'Enable profiling of examples and list the slowest examples (default: 10).') do |argument|
|
119
121
|
options[:profile_examples] = if argument.nil?
|
120
122
|
true
|
121
123
|
elsif argument == false
|
@@ -153,7 +155,8 @@ FILTERING
|
|
153
155
|
options[:pattern] = o
|
154
156
|
end
|
155
157
|
|
156
|
-
parser.on('--exclude-pattern PATTERN',
|
158
|
+
parser.on('--exclude-pattern PATTERN',
|
159
|
+
'Load files except those matching pattern. Opposite effect of --pattern.') do |o|
|
157
160
|
options[:exclude_pattern] = o
|
158
161
|
end
|
159
162
|
|
@@ -198,18 +201,21 @@ FILTERING
|
|
198
201
|
exit
|
199
202
|
end
|
200
203
|
|
201
|
-
#
|
202
|
-
#
|
203
|
-
#
|
204
|
+
# These options would otherwise be confusing to users, so we forcibly
|
205
|
+
# prevent them from executing.
|
206
|
+
#
|
207
|
+
# * --I is too similar to -I.
|
208
|
+
# * -d was a shorthand for --debugger, which is removed, but now would
|
209
|
+
# trigger --default-path.
|
204
210
|
invalid_options = %w[-d --I]
|
205
211
|
|
206
212
|
parser.on_tail('-h', '--help', "You're looking at it.") do
|
207
|
-
#
|
213
|
+
# Removing the blank invalid options from the output.
|
208
214
|
puts parser.to_s.gsub(/^\s+(#{invalid_options.join('|')})\s*$\n/, '')
|
209
215
|
exit
|
210
216
|
end
|
211
217
|
|
212
|
-
#
|
218
|
+
# This prevents usage of the invalid_options.
|
213
219
|
invalid_options.each do |option|
|
214
220
|
parser.on(option) do
|
215
221
|
raise OptionParser::InvalidOption.new
|
data/lib/rspec/core/pending.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Core
|
3
|
-
# Provides methods to mark examples as pending. These methods are available
|
4
|
-
# called from within any example or hook.
|
3
|
+
# Provides methods to mark examples as pending. These methods are available
|
4
|
+
# to be called from within any example or hook.
|
5
5
|
module Pending
|
6
|
-
# Raised in the middle of an example to indicate that it should be marked
|
6
|
+
# Raised in the middle of an example to indicate that it should be marked
|
7
|
+
# as skipped.
|
7
8
|
class SkipDeclaredInExample < StandardError
|
8
9
|
attr_reader :argument
|
9
10
|
|
@@ -12,8 +13,9 @@ module RSpec
|
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
|
-
# If Test::Unit is loaded, we'll use its error as baseclass, so that
|
16
|
-
# will report unmet RSpec expectations as failures rather than
|
16
|
+
# If Test::Unit is loaded, we'll use its error as baseclass, so that
|
17
|
+
# Test::Unit will report unmet RSpec expectations as failures rather than
|
18
|
+
# errors.
|
17
19
|
begin
|
18
20
|
class PendingExampleFixedError < Test::Unit::AssertionFailedError; end
|
19
21
|
rescue
|
@@ -71,7 +73,7 @@ module RSpec
|
|
71
73
|
if block_given?
|
72
74
|
raise ArgumentError, <<-EOS.gsub(/^\s+\|/, '')
|
73
75
|
|The semantics of `RSpec::Core::Pending#pending` have changed in
|
74
|
-
|RSpec 3.
|
76
|
+
|RSpec 3. In RSpec 2.x, it caused the example to be skipped. In
|
75
77
|
|RSpec 3, the rest of the example is still run but is expected to
|
76
78
|
|fail, and will be marked as a failure (rather than as pending) if
|
77
79
|
|the example passes.
|
@@ -123,7 +125,7 @@ module RSpec
|
|
123
125
|
|
124
126
|
# @private
|
125
127
|
#
|
126
|
-
# Mark example as skipped
|
128
|
+
# Mark example as skipped.
|
127
129
|
#
|
128
130
|
# @param example [RSpec::Core::Example] the example to mark as skipped
|
129
131
|
# @param message_or_bool [Boolean, String] the message to use, or true
|
@@ -134,7 +136,7 @@ module RSpec
|
|
134
136
|
|
135
137
|
# @private
|
136
138
|
#
|
137
|
-
# Mark example as pending
|
139
|
+
# Mark example as pending.
|
138
140
|
#
|
139
141
|
# @param example [RSpec::Core::Example] the example to mark as pending
|
140
142
|
# @param message_or_bool [Boolean, String] the message to use, or true
|
@@ -152,7 +154,7 @@ module RSpec
|
|
152
154
|
|
153
155
|
# @private
|
154
156
|
#
|
155
|
-
# Mark example as fixed
|
157
|
+
# Mark example as fixed.
|
156
158
|
#
|
157
159
|
# @param example [RSpec::Core::Example] the example to mark as fixed
|
158
160
|
def self.mark_fixed!(example)
|
@@ -3,7 +3,7 @@ RSpec::Support.require_rspec_support "directory_maker"
|
|
3
3
|
module RSpec
|
4
4
|
module Core
|
5
5
|
# @private
|
6
|
-
# Generates conventional files for an
|
6
|
+
# Generates conventional files for an RSpec project.
|
7
7
|
class ProjectInitializer
|
8
8
|
attr_reader :destination, :stream, :template_path
|
9
9
|
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
2
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
-
# file to always be loaded, without a need to explicitly require it in any
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
5
6
|
#
|
6
7
|
# Given that it is always loaded, you are encouraged to keep this file as
|
7
8
|
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
9
|
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
10
|
# individual file that may not need all of that loaded. Instead, consider making
|
10
11
|
# a separate helper file that requires the additional dependencies and performs
|
11
|
-
# the additional setup, and require it from the spec files that actually need
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
12
14
|
#
|
13
15
|
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
16
|
# users commonly want.
|
@@ -22,10 +24,10 @@ RSpec.configure do |config|
|
|
22
24
|
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
25
|
# and `failure_message` of custom matchers include text for helper methods
|
24
26
|
# defined using `chain`, e.g.:
|
25
|
-
#
|
26
|
-
#
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
27
29
|
# ...rather than:
|
28
|
-
#
|
30
|
+
# # => "be bigger than 2"
|
29
31
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
32
|
end
|
31
33
|
|
@@ -48,8 +50,8 @@ RSpec.configure do |config|
|
|
48
50
|
config.filter_run :focus
|
49
51
|
config.run_all_when_everything_filtered = true
|
50
52
|
|
51
|
-
# Limits the available syntax to the non-monkey patched syntax that is
|
52
|
-
# For more details, see:
|
53
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
54
|
+
# recommended. For more details, see:
|
53
55
|
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
54
56
|
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
55
57
|
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
data/lib/rspec/core/rake_task.rb
CHANGED
@@ -1,71 +1,51 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/tasklib'
|
3
|
-
require '
|
3
|
+
require 'rspec/support/ruby_features'
|
4
4
|
|
5
5
|
module RSpec
|
6
6
|
module Core
|
7
|
-
#
|
7
|
+
# RSpec rake task
|
8
8
|
#
|
9
9
|
# @see Rakefile
|
10
10
|
class RakeTask < ::Rake::TaskLib
|
11
11
|
include ::Rake::DSL if defined?(::Rake::DSL)
|
12
12
|
|
13
|
-
# Default path to the
|
13
|
+
# Default path to the RSpec executable.
|
14
14
|
DEFAULT_RSPEC_PATH = File.expand_path('../../../../exe/rspec', __FILE__)
|
15
15
|
|
16
16
|
# Default pattern for spec files.
|
17
17
|
DEFAULT_PATTERN = 'spec/**{,/*/**}/*_spec.rb'
|
18
18
|
|
19
|
-
# Name of task.
|
20
|
-
#
|
21
|
-
# default:
|
22
|
-
# :spec
|
19
|
+
# Name of task. Defaults to `:spec`.
|
23
20
|
attr_accessor :name
|
24
21
|
|
25
22
|
# Files matching this pattern will be loaded.
|
26
|
-
#
|
27
|
-
# default:
|
28
|
-
# 'spec/**{,/*/**}/*_spec.rb'
|
23
|
+
# Defaults to `'spec/**{,/*/**}/*_spec.rb'`.
|
29
24
|
attr_accessor :pattern
|
30
25
|
|
31
26
|
# Files matching this pattern will be excluded.
|
32
|
-
#
|
33
|
-
# default:
|
34
|
-
# 'spec/**/*_spec.rb'
|
27
|
+
# Defaults to `nil`.
|
35
28
|
attr_accessor :exclude_pattern
|
36
29
|
|
37
|
-
# Whether or not to fail Rake when an error occurs (typically when
|
38
|
-
#
|
39
|
-
# default:
|
40
|
-
# true
|
30
|
+
# Whether or not to fail Rake when an error occurs (typically when
|
31
|
+
# examples fail). Defaults to `true`.
|
41
32
|
attr_accessor :fail_on_error
|
42
33
|
|
43
34
|
# A message to print to stderr when there are failures.
|
44
35
|
attr_accessor :failure_message
|
45
36
|
|
46
37
|
# Use verbose output. If this is set to true, the task will print the
|
47
|
-
# executed spec command to stdout.
|
48
|
-
#
|
49
|
-
# default:
|
50
|
-
# true
|
38
|
+
# executed spec command to stdout. Defaults to `true`.
|
51
39
|
attr_accessor :verbose
|
52
40
|
|
53
|
-
# Command line options to pass to ruby.
|
54
|
-
#
|
55
|
-
# default:
|
56
|
-
# nil
|
41
|
+
# Command line options to pass to ruby. Defaults to `nil`.
|
57
42
|
attr_accessor :ruby_opts
|
58
43
|
|
59
|
-
# Path to
|
60
|
-
#
|
61
|
-
# default:
|
62
|
-
# 'rspec'
|
44
|
+
# Path to RSpec. Defaults to the absolute path to the
|
45
|
+
# rspec binary from the loaded rspec-core gem.
|
63
46
|
attr_accessor :rspec_path
|
64
47
|
|
65
|
-
# Command line options to pass to
|
66
|
-
#
|
67
|
-
# default:
|
68
|
-
# nil
|
48
|
+
# Command line options to pass to RSpec. Defaults to `nil`.
|
69
49
|
attr_accessor :rspec_opts
|
70
50
|
|
71
51
|
def initialize(*args, &task_block)
|
@@ -93,7 +73,7 @@ module RSpec
|
|
93
73
|
|
94
74
|
return unless fail_on_error && !success
|
95
75
|
|
96
|
-
$stderr.puts "#{command} failed"
|
76
|
+
$stderr.puts "#{command} failed" if verbose
|
97
77
|
exit $?.exitstatus
|
98
78
|
end
|
99
79
|
|
@@ -117,31 +97,36 @@ module RSpec
|
|
117
97
|
elsif String === pattern && !File.exist?(pattern)
|
118
98
|
"--pattern #{escape pattern}"
|
119
99
|
else
|
120
|
-
# Before RSpec 3.1, we used `FileList` to get the list of matched
|
121
|
-
# then pass that along to the `rspec` command. Starting
|
122
|
-
# pass along the pattern as-is to the `rspec`
|
100
|
+
# Before RSpec 3.1, we used `FileList` to get the list of matched
|
101
|
+
# files, and then pass that along to the `rspec` command. Starting
|
102
|
+
# with 3.1, we prefer to pass along the pattern as-is to the `rspec`
|
103
|
+
# command, for 3 reasons:
|
123
104
|
#
|
124
|
-
# * It's *much* less verbose to pass one `--pattern` option than a
|
125
|
-
#
|
126
|
-
# * It
|
127
|
-
#
|
128
|
-
#
|
105
|
+
# * It's *much* less verbose to pass one `--pattern` option than a
|
106
|
+
# long list of files.
|
107
|
+
# * It ensures `task.pattern` and `--pattern` have the same
|
108
|
+
# behavior.
|
109
|
+
# * It fixes a bug, where
|
110
|
+
# `task.pattern = pattern_that_matches_no_files` would run *all*
|
111
|
+
# files because it would cause no pattern or file args to get
|
112
|
+
# passed to `rspec`, which causes all files to get run.
|
129
113
|
#
|
130
|
-
# However, `FileList` is *far* more flexible than the `--pattern`
|
131
|
-
#
|
132
|
-
# as well as
|
114
|
+
# However, `FileList` is *far* more flexible than the `--pattern`
|
115
|
+
# option. Specifically, it supports individual files and directories,
|
116
|
+
# as well as arrays of files, directories and globs, as well as other
|
117
|
+
# `FileList` objects.
|
133
118
|
#
|
134
|
-
# For backwards compatibility, we have to fall back to using FileList
|
135
|
-
# a `pattern` option that will not work with
|
119
|
+
# For backwards compatibility, we have to fall back to using FileList
|
120
|
+
# if the user has passed a `pattern` option that will not work with
|
121
|
+
# `--pattern`.
|
136
122
|
#
|
137
|
-
# TODO: consider deprecating support for this and removing it in
|
123
|
+
# TODO: consider deprecating support for this and removing it in
|
124
|
+
# RSpec 4.
|
138
125
|
FileList[pattern].sort.map { |file| escape file }
|
139
126
|
end
|
140
127
|
end
|
141
128
|
|
142
|
-
|
143
|
-
# but in 3.1 we don't and requiring rspec/world would be weighty here.
|
144
|
-
if RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/
|
129
|
+
if RSpec::Support::OS.windows?
|
145
130
|
def escape(shell_command)
|
146
131
|
"'#{shell_command.gsub("'", "\'")}'"
|
147
132
|
end
|
@@ -162,7 +147,7 @@ module RSpec
|
|
162
147
|
cmd_parts << RUBY
|
163
148
|
cmd_parts << ruby_opts
|
164
149
|
cmd_parts << rspec_load_path
|
165
|
-
cmd_parts << rspec_path
|
150
|
+
cmd_parts << escape(rspec_path)
|
166
151
|
cmd_parts << file_inclusion_specification
|
167
152
|
cmd_parts << file_exclusion_specification
|
168
153
|
cmd_parts << rspec_opts
|
data/lib/rspec/core/reporter.rb
CHANGED
@@ -14,11 +14,20 @@ module RSpec::Core
|
|
14
14
|
# @private
|
15
15
|
attr_reader :examples, :failed_examples, :pending_examples
|
16
16
|
|
17
|
-
#
|
18
|
-
|
17
|
+
# @private
|
18
|
+
def reset
|
19
|
+
@examples = []
|
20
|
+
@failed_examples = []
|
21
|
+
@pending_examples = []
|
22
|
+
end
|
23
|
+
|
24
|
+
# Registers a listener to a list of notifications. The reporter will send
|
25
|
+
# notification of events to all registered listeners.
|
19
26
|
#
|
20
|
-
# @param listener [Object] An obect that wishes to be notified of reporter
|
21
|
-
#
|
27
|
+
# @param listener [Object] An obect that wishes to be notified of reporter
|
28
|
+
# events
|
29
|
+
# @param notifications [Array] Array of symbols represents the events a
|
30
|
+
# listener wishes to subscribe too
|
22
31
|
def register_listener(listener, *notifications)
|
23
32
|
notifications.each do |notification|
|
24
33
|
@listeners[notification.to_sym] << listener
|
@@ -61,6 +70,7 @@ module RSpec::Core
|
|
61
70
|
@start = time
|
62
71
|
@load_time = (@start - @configuration.start_time).to_f
|
63
72
|
notify :start, Notifications::StartNotification.new(expected_example_count, @load_time)
|
73
|
+
notify :seed, Notifications::SeedNotification.new(@configuration.seed, seed_used?)
|
64
74
|
end
|
65
75
|
|
66
76
|
# @private
|
@@ -113,10 +123,12 @@ module RSpec::Core
|
|
113
123
|
notify :dump_pending, Notifications::ExamplesNotification.new(self)
|
114
124
|
notify :dump_failures, Notifications::ExamplesNotification.new(self)
|
115
125
|
notify :deprecation_summary, Notifications::NullNotification
|
116
|
-
notify :dump_summary, Notifications::SummaryNotification.new(@duration, @examples, @failed_examples, @pending_examples, @load_time)
|
117
126
|
unless mute_profile_output?
|
118
|
-
notify :dump_profile, Notifications::ProfileNotification.new(@duration, @examples,
|
127
|
+
notify :dump_profile, Notifications::ProfileNotification.new(@duration, @examples,
|
128
|
+
@configuration.profile_examples)
|
119
129
|
end
|
130
|
+
notify :dump_summary, Notifications::SummaryNotification.new(@duration, @examples, @failed_examples,
|
131
|
+
@pending_examples, @load_time)
|
120
132
|
notify :seed, Notifications::SeedNotification.new(@configuration.seed, seed_used?)
|
121
133
|
ensure
|
122
134
|
notify :close, Notifications::NullNotification
|
@@ -138,7 +150,8 @@ module RSpec::Core
|
|
138
150
|
private
|
139
151
|
|
140
152
|
def mute_profile_output?
|
141
|
-
# Don't print out profiled info if there are failures and `--fail-fast` is
|
153
|
+
# Don't print out profiled info if there are failures and `--fail-fast` is
|
154
|
+
# used, it just clutters the output.
|
142
155
|
!@configuration.profile_examples? || (@configuration.fail_fast? && @failed_examples.size > 0)
|
143
156
|
end
|
144
157
|
|
@@ -146,4 +159,14 @@ module RSpec::Core
|
|
146
159
|
@configuration.seed && @configuration.seed_used?
|
147
160
|
end
|
148
161
|
end
|
162
|
+
|
163
|
+
# @private
|
164
|
+
# # Used in place of a {Reporter} for situations where we don't want reporting output.
|
165
|
+
class NullReporter
|
166
|
+
private
|
167
|
+
|
168
|
+
def method_missing(*)
|
169
|
+
# ignore
|
170
|
+
end
|
171
|
+
end
|
149
172
|
end
|
@@ -1,9 +1,6 @@
|
|
1
1
|
# This is borrowed (slightly modified) from Scott Taylor's
|
2
2
|
# project_path project:
|
3
3
|
# http://github.com/smtlaissezfaire/project_path
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
|
7
4
|
module RSpec
|
8
5
|
module Core
|
9
6
|
# @private
|
@@ -29,8 +26,19 @@ module RSpec
|
|
29
26
|
end
|
30
27
|
|
31
28
|
def ascend_until
|
32
|
-
|
29
|
+
fs = File::SEPARATOR
|
30
|
+
escaped_slash = "\\#{fs}"
|
31
|
+
special = "_RSPEC_ESCAPED_SLASH_"
|
32
|
+
project_path = File.expand_path(".")
|
33
|
+
parts = project_path.gsub(escaped_slash, special).squeeze(fs).split(fs).map do |x|
|
34
|
+
x.gsub(special, escaped_slash)
|
35
|
+
end
|
36
|
+
|
37
|
+
until parts.empty?
|
38
|
+
path = parts.join(fs)
|
39
|
+
path = fs if path == ""
|
33
40
|
return path if yield(path)
|
41
|
+
parts.pop
|
34
42
|
end
|
35
43
|
end
|
36
44
|
|
data/lib/rspec/core/runner.rb
CHANGED
@@ -24,14 +24,15 @@ module RSpec
|
|
24
24
|
next unless $!.nil? || $!.is_a?(SystemExit)
|
25
25
|
|
26
26
|
# We got here because either the end of the program was reached or
|
27
|
-
# somebody called Kernel#exit.
|
27
|
+
# somebody called Kernel#exit. Run the specs and then override any
|
28
28
|
# existing exit status with RSpec's exit status if any specs failed.
|
29
29
|
invoke
|
30
30
|
end
|
31
31
|
@installed_at_exit = true
|
32
32
|
end
|
33
33
|
|
34
|
-
# Runs the suite of specs and exits the process with an appropriate exit
|
34
|
+
# Runs the suite of specs and exits the process with an appropriate exit
|
35
|
+
# code.
|
35
36
|
def self.invoke
|
36
37
|
disable_autorun!
|
37
38
|
status = run(ARGV, $stderr, $stdout).to_i
|
@@ -105,12 +106,8 @@ module RSpec
|
|
105
106
|
# failed.
|
106
107
|
def run_specs(example_groups)
|
107
108
|
@configuration.reporter.report(@world.example_count(example_groups)) do |reporter|
|
108
|
-
|
109
|
-
hook_context = SuiteHookContext.new
|
110
|
-
@configuration.hooks.run(:before, :suite, hook_context)
|
109
|
+
@configuration.with_suite_hooks do
|
111
110
|
example_groups.map { |g| g.run(reporter) }.all? ? 0 : @configuration.failure_exit_code
|
112
|
-
ensure
|
113
|
-
@configuration.hooks.run(:after, :suite, hook_context)
|
114
111
|
end
|
115
112
|
end
|
116
113
|
end
|
@@ -150,7 +147,7 @@ module RSpec
|
|
150
147
|
trap('INT') do
|
151
148
|
exit!(1) if RSpec.world.wants_to_quit
|
152
149
|
RSpec.world.wants_to_quit = true
|
153
|
-
STDERR.puts "\
|
150
|
+
STDERR.puts "\nRSpec is shutting down and will print the summary report... Interrupt again to force quit."
|
154
151
|
end
|
155
152
|
end
|
156
153
|
end
|