rspec-core 3.0.0.beta2 → 3.0.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.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +297 -57
- data/README.md +16 -13
- data/lib/rspec/core.rb +55 -84
- data/lib/rspec/core/backport_random.rb +35 -3
- data/lib/rspec/core/backtrace_formatter.rb +4 -13
- data/lib/rspec/core/configuration.rb +330 -114
- data/lib/rspec/core/configuration_options.rb +38 -22
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +8 -2
- data/lib/rspec/core/example.rb +203 -94
- data/lib/rspec/core/example_group.rb +344 -316
- data/lib/rspec/core/filter_manager.rb +135 -90
- data/lib/rspec/core/flat_map.rb +1 -0
- data/lib/rspec/core/formatters.rb +50 -14
- data/lib/rspec/core/formatters/base_formatter.rb +32 -138
- data/lib/rspec/core/formatters/base_text_formatter.rb +32 -253
- data/lib/rspec/core/formatters/console_codes.rb +65 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +24 -15
- data/lib/rspec/core/formatters/documentation_formatter.rb +7 -10
- data/lib/rspec/core/formatters/helpers.rb +15 -9
- data/lib/rspec/core/formatters/html_formatter.rb +17 -16
- data/lib/rspec/core/formatters/html_printer.rb +1 -0
- data/lib/rspec/core/formatters/json_formatter.rb +18 -20
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +6 -7
- data/lib/rspec/core/formatters/snippet_extractor.rb +8 -6
- data/lib/rspec/core/hooks.rb +131 -125
- data/lib/rspec/core/memoized_helpers.rb +31 -26
- data/lib/rspec/core/metadata.rb +277 -184
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
- data/lib/rspec/core/mocking_adapters/mocha.rb +1 -1
- data/lib/rspec/core/mocking_adapters/null.rb +1 -1
- data/lib/rspec/core/mocking_adapters/rr.rb +2 -1
- data/lib/rspec/core/mocking_adapters/rspec.rb +1 -1
- data/lib/rspec/core/notifications.rb +435 -24
- data/lib/rspec/core/option_parser.rb +16 -25
- data/lib/rspec/core/ordering.rb +3 -1
- data/lib/rspec/core/pending.rb +57 -33
- data/lib/rspec/core/project_initializer.rb +2 -0
- data/lib/rspec/core/project_initializer/spec_helper.rb +5 -4
- data/lib/rspec/core/rake_task.rb +45 -20
- data/lib/rspec/core/reporter.rb +50 -22
- data/lib/rspec/core/ruby_project.rb +1 -0
- data/lib/rspec/core/runner.rb +93 -39
- data/lib/rspec/core/shared_context.rb +7 -5
- data/lib/rspec/core/shared_example_group.rb +85 -77
- data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +35 -17
- data/lib/rspec/core/world.rb +57 -5
- metadata +56 -369
- metadata.gz.sig +3 -3
- data/features/README.md +0 -13
- data/features/Upgrade.md +0 -352
- data/features/command_line/README.md +0 -25
- data/features/command_line/dry_run.feature +0 -29
- data/features/command_line/example_name_option.feature +0 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/fail_fast.feature +0 -26
- data/features/command_line/format_option.feature +0 -75
- data/features/command_line/init.feature +0 -57
- data/features/command_line/line_number_appended_to_path.feature +0 -140
- data/features/command_line/line_number_option.feature +0 -58
- data/features/command_line/order.feature +0 -25
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/randomization.feature +0 -63
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -23
- data/features/command_line/tag.feature +0 -98
- data/features/command_line/warnings_option.feature +0 -29
- data/features/configuration/alias_example_to.feature +0 -39
- data/features/configuration/backtrace_exclusion_patterns.feature +0 -105
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/deprecation_stream.feature +0 -58
- data/features/configuration/enable_global_dsl.feature +0 -54
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/failure_exit_code.feature +0 -36
- data/features/configuration/order_and_seed.feature +0 -3
- data/features/configuration/output_stream.feature +0 -24
- data/features/configuration/overriding_global_ordering.feature +0 -93
- data/features/configuration/pattern.feature +0 -38
- data/features/configuration/profile.feature +0 -220
- data/features/configuration/read_options_from_file.feature +0 -90
- data/features/configuration/run_all_when_everything_filtered.feature +0 -76
- data/features/example_groups/aliasing.feature +0 -48
- data/features/example_groups/basic_structure.feature +0 -55
- data/features/example_groups/shared_context.feature +0 -74
- data/features/example_groups/shared_examples.feature +0 -286
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
- data/features/filtering/exclusion_filters.feature +0 -135
- data/features/filtering/if_and_unless.feature +0 -138
- data/features/filtering/inclusion_filters.feature +0 -101
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -68
- data/features/formatters/json_formatter.feature +0 -30
- data/features/formatters/regression_tests.feature +0 -95
- data/features/formatters/text_formatter.feature +0 -46
- data/features/helper_methods/arbitrary_methods.feature +0 -40
- data/features/helper_methods/let.feature +0 -50
- data/features/helper_methods/modules.feature +0 -146
- data/features/hooks/around_hooks.feature +0 -344
- data/features/hooks/before_and_after_hooks.feature +0 -427
- data/features/hooks/filtering.feature +0 -232
- data/features/metadata/current_example.feature +0 -56
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -100
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -94
- data/features/mock_framework_integration/use_mocha.feature +0 -95
- data/features/mock_framework_integration/use_rr.feature +0 -96
- data/features/mock_framework_integration/use_rspec.feature +0 -95
- data/features/pending_and_skipped_examples/README.md +0 -3
- data/features/pending_and_skipped_examples/pending_examples.feature +0 -118
- data/features/pending_and_skipped_examples/skipped_examples.feature +0 -106
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -83
- data/features/subject/explicit_subject.feature +0 -101
- data/features/subject/implicit_subject.feature +0 -63
- data/features/subject/one_liner_syntax.feature +0 -71
- data/features/support/env.rb +0 -21
- data/features/support/require_expect_syntax_in_aruba_specs.rb +0 -16
- data/features/support/rubinius.rb +0 -6
- data/lib/rspec/core/command_line.rb +0 -35
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/formatters/legacy_formatter.rb +0 -227
- data/lib/rspec/core/shared_example_group/collection.rb +0 -27
- data/spec/command_line/order_spec.rb +0 -211
- data/spec/rspec/core/backtrace_formatter_spec.rb +0 -230
- data/spec/rspec/core/command_line_spec.rb +0 -112
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -409
- data/spec/rspec/core/configuration_spec.rb +0 -1479
- data/spec/rspec/core/drb_command_line_spec.rb +0 -102
- data/spec/rspec/core/drb_options_spec.rb +0 -193
- data/spec/rspec/core/dsl_spec.rb +0 -88
- data/spec/rspec/core/example_group_spec.rb +0 -1533
- data/spec/rspec/core/example_spec.rb +0 -642
- data/spec/rspec/core/filter_manager_spec.rb +0 -229
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -64
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -303
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -208
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -75
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted-2.1.0.html +0 -392
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -122
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -206
- data/spec/rspec/core/formatters/legacy_formatter_spec.rb +0 -137
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -43
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters_spec.rb +0 -120
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -294
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -495
- data/spec/rspec/core/metadata_spec.rb +0 -491
- data/spec/rspec/core/option_parser_spec.rb +0 -262
- data/spec/rspec/core/ordering_spec.rb +0 -102
- data/spec/rspec/core/pending_example_spec.rb +0 -117
- data/spec/rspec/core/pending_spec.rb +0 -8
- data/spec/rspec/core/project_initializer_spec.rb +0 -73
- data/spec/rspec/core/rake_task_spec.rb +0 -146
- data/spec/rspec/core/random_spec.rb +0 -47
- data/spec/rspec/core/reporter_spec.rb +0 -155
- data/spec/rspec/core/resources/a_bar.rb +0 -0
- data/spec/rspec/core/resources/a_foo.rb +0 -0
- data/spec/rspec/core/resources/a_spec.rb +0 -1
- data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
- data/spec/rspec/core/resources/formatter_specs.rb +0 -58
- data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
- data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
- data/spec/rspec/core/ruby_project_spec.rb +0 -26
- data/spec/rspec/core/runner_spec.rb +0 -151
- data/spec/rspec/core/shared_context_spec.rb +0 -102
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -57
- data/spec/rspec/core/shared_example_group_spec.rb +0 -114
- data/spec/rspec/core/warnings_spec.rb +0 -29
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -91
- data/spec/spec_helper.rb +0 -160
- data/spec/support/config_options_helper.rb +0 -13
- data/spec/support/formatter_support.rb +0 -83
- data/spec/support/helper_methods.rb +0 -26
- data/spec/support/isolate_load_path_mutation.rb +0 -5
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +0 -87
- data/spec/support/matchers.rb +0 -85
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/old_style_formatter_example.rb +0 -69
- data/spec/support/shared_example_groups.rb +0 -13
- data/spec/support/spec_files.rb +0 -44
- data/spec/support/stderr_splitter.rb +0 -36
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'optparse'
|
3
3
|
|
4
4
|
module RSpec::Core
|
5
|
-
# @
|
5
|
+
# @private
|
6
6
|
class Parser
|
7
7
|
def self.parse(args)
|
8
8
|
new.parse(args)
|
@@ -11,8 +11,6 @@ module RSpec::Core
|
|
11
11
|
def parse(args)
|
12
12
|
return {} if args.empty?
|
13
13
|
|
14
|
-
convert_deprecated_args(args)
|
15
|
-
|
16
14
|
options = args.delete('--tty') ? {:tty => true} : {}
|
17
15
|
begin
|
18
16
|
parser(options).parse!(args)
|
@@ -23,19 +21,6 @@ module RSpec::Core
|
|
23
21
|
options
|
24
22
|
end
|
25
23
|
|
26
|
-
def convert_deprecated_args(args)
|
27
|
-
args.map! { |arg|
|
28
|
-
case arg
|
29
|
-
when "--default_path"
|
30
|
-
"--default-path"
|
31
|
-
when "--line_number"
|
32
|
-
"--line-number"
|
33
|
-
else
|
34
|
-
arg
|
35
|
-
end
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
24
|
def parser(options)
|
40
25
|
OptionParser.new do |parser|
|
41
26
|
parser.banner = "Usage: rspec [options] [files or directories]\n\n"
|
@@ -92,7 +77,7 @@ module RSpec::Core
|
|
92
77
|
end
|
93
78
|
|
94
79
|
parser.on('--init', 'Initialize your project with RSpec.') do |cmd|
|
95
|
-
|
80
|
+
RSpec::Support.require_rspec_core "project_initializer"
|
96
81
|
ProjectInitializer.new.run
|
97
82
|
exit
|
98
83
|
end
|
@@ -118,6 +103,10 @@ module RSpec::Core
|
|
118
103
|
options[:formatters].last << o
|
119
104
|
end
|
120
105
|
|
106
|
+
parser.on('--deprecation-out FILE', 'Write deprecation warnings to a file instead of $stderr.') do |file|
|
107
|
+
options[:deprecation_stream] = file
|
108
|
+
end
|
109
|
+
|
121
110
|
parser.on('-b', '--backtrace', 'Enable full backtrace.') do |o|
|
122
111
|
options[:full_backtrace] = true
|
123
112
|
end
|
@@ -145,7 +134,7 @@ module RSpec::Core
|
|
145
134
|
end
|
146
135
|
|
147
136
|
parser.on('-w', '--warnings', 'Enable ruby warnings') do
|
148
|
-
|
137
|
+
$VERBOSE = true
|
149
138
|
end
|
150
139
|
|
151
140
|
parser.separator <<-FILTERING
|
@@ -169,11 +158,6 @@ FILTERING
|
|
169
158
|
(options[:full_description] ||= []) << Regexp.compile(Regexp.escape(o))
|
170
159
|
end
|
171
160
|
|
172
|
-
parser.on('-l', '--line-number LINE', 'Specify line number of an example or group (may be',
|
173
|
-
' used more than once).') do |o|
|
174
|
-
(options[:line_numbers] ||= []) << o
|
175
|
-
end
|
176
|
-
|
177
161
|
parser.on('-t', '--tag TAG[:VALUE]',
|
178
162
|
'Run examples with the specified tag, or exclude examples',
|
179
163
|
'by adding ~ before the tag.',
|
@@ -210,12 +194,19 @@ FILTERING
|
|
210
194
|
exit
|
211
195
|
end
|
212
196
|
|
197
|
+
# these options would otherwise be confusing to users, so we forcibly prevent them from executing
|
198
|
+
# --I is too similar to -I
|
199
|
+
# -d was a shorthand for --debugger, which is removed, but now would trigger --default-path
|
200
|
+
invalid_options = %w[-d --I]
|
201
|
+
|
213
202
|
parser.on_tail('-h', '--help', "You're looking at it.") do
|
214
|
-
|
203
|
+
# removing the blank invalid options from the output
|
204
|
+
puts parser.to_s.gsub(/^\s+(#{invalid_options.join('|')})\s*$\n/,'')
|
215
205
|
exit
|
216
206
|
end
|
217
207
|
|
218
|
-
|
208
|
+
# this prevents usage of the invalid_options
|
209
|
+
invalid_options.each do |option|
|
219
210
|
parser.on(option) do
|
220
211
|
raise OptionParser::InvalidOption.new
|
221
212
|
end
|
data/lib/rspec/core/ordering.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Core
|
3
3
|
if defined?(::Random)
|
4
|
+
# @private
|
4
5
|
RandomNumberGenerator = ::Random
|
5
6
|
else
|
6
|
-
|
7
|
+
RSpec::Support.require_rspec_core "backport_random"
|
8
|
+
# @private
|
7
9
|
RandomNumberGenerator = RSpec::Core::Backports::Random
|
8
10
|
end
|
9
11
|
|
data/lib/rspec/core/pending.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Core
|
3
|
+
# Provides methods to mark examples as pending. These methods are available to be
|
4
|
+
# called from within any example or hook.
|
3
5
|
module Pending
|
6
|
+
# Raised in the middle of an example to indicate that it should be marked as skipped.
|
4
7
|
class SkipDeclaredInExample < StandardError
|
5
8
|
attr_reader :argument
|
6
9
|
|
@@ -9,7 +12,7 @@ module RSpec
|
|
9
12
|
end
|
10
13
|
end
|
11
14
|
|
12
|
-
# If Test::Unit is
|
15
|
+
# If Test::Unit is loaded, we'll use its error as baseclass, so that Test::Unit
|
13
16
|
# will report unmet RSpec expectations as failures rather than errors.
|
14
17
|
begin
|
15
18
|
class PendingExampleFixedError < Test::Unit::AssertionFailedError; end
|
@@ -17,26 +20,27 @@ module RSpec
|
|
17
20
|
class PendingExampleFixedError < StandardError; end
|
18
21
|
end
|
19
22
|
|
23
|
+
# @private
|
20
24
|
NO_REASON_GIVEN = 'No reason given'
|
25
|
+
|
26
|
+
# @private
|
21
27
|
NOT_YET_IMPLEMENTED = 'Not yet implemented'
|
22
28
|
|
23
29
|
# @overload pending()
|
24
30
|
# @overload pending(message)
|
25
|
-
# @overload pending(message, &block)
|
26
31
|
#
|
27
32
|
# Marks an example as pending. The rest of the example will still be
|
28
33
|
# executed, and if it passes the example will fail to indicate that the
|
29
34
|
# pending can be removed.
|
30
35
|
#
|
31
|
-
# @param [String]
|
36
|
+
# @param message [String] optional message to add to the summary report.
|
32
37
|
#
|
33
38
|
# @example
|
34
|
-
#
|
35
39
|
# describe "an example" do
|
36
40
|
# # reported as "Pending: no reason given"
|
37
41
|
# it "is pending with no message" do
|
38
42
|
# pending
|
39
|
-
# raise "broken"
|
43
|
+
# raise "broken"
|
40
44
|
# end
|
41
45
|
#
|
42
46
|
# # reported as "Pending: something else getting finished"
|
@@ -46,7 +50,7 @@ module RSpec
|
|
46
50
|
# end
|
47
51
|
# end
|
48
52
|
#
|
49
|
-
# @note `before(:
|
53
|
+
# @note `before(:example)` hooks are eval'd when you use the `pending`
|
50
54
|
# method within an example. If you want to declare an example `pending`
|
51
55
|
# and bypass the `before` hooks as well, you can pass `:pending => true`
|
52
56
|
# to the `it` method:
|
@@ -61,32 +65,43 @@ module RSpec
|
|
61
65
|
# it "does something", :pending => "something else getting finished" do
|
62
66
|
# # ...
|
63
67
|
# end
|
64
|
-
def pending(
|
68
|
+
def pending(message=nil)
|
65
69
|
current_example = RSpec.current_example
|
66
70
|
|
67
|
-
if
|
68
|
-
|
71
|
+
if block_given?
|
72
|
+
raise ArgumentError, <<-EOS.gsub(/^\s+\|/, '')
|
73
|
+
|The semantics of `RSpec::Core::Pending#pending` have changed in
|
74
|
+
|RSpec 3. In RSpec 2.x, it caused the example to be skipped. In
|
75
|
+
|RSpec 3, the rest of the example is still run but is expected to
|
76
|
+
|fail, and will be marked as a failure (rather than as pending) if
|
77
|
+
|the example passes.
|
78
|
+
|
|
79
|
+
|Passing a block within an example is now deprecated. Marking the
|
80
|
+
|example as pending provides the same behavior in RSpec 3 which was
|
81
|
+
|provided only by the block in RSpec 2.x.
|
82
|
+
|
|
83
|
+
|Move the code in the block provided to `pending` into the rest of
|
84
|
+
|the example body.
|
85
|
+
|
|
86
|
+
|Called from #{CallerFilter.first_non_rspec_line}.
|
87
|
+
|
|
88
|
+
EOS
|
89
|
+
elsif current_example
|
90
|
+
Pending.mark_pending! current_example, message
|
69
91
|
else
|
70
92
|
raise "`pending` may not be used outside of examples, such as in " +
|
71
|
-
"before(:
|
93
|
+
"before(:context). Maybe you want `skip`?"
|
72
94
|
end
|
73
95
|
end
|
74
96
|
|
75
97
|
# @overload skip()
|
76
98
|
# @overload skip(message)
|
77
|
-
# @overload skip(message, &block)
|
78
99
|
#
|
79
|
-
# Marks an example as pending and skips execution
|
80
|
-
# block. When called with a block, skips just that block and does not
|
81
|
-
# mark the example as pending. The block form is provided as replacement
|
82
|
-
# for RSpec 2's pending-with-block feature, and is not recommended for
|
83
|
-
# new code. Use simple conditionals instead.
|
100
|
+
# Marks an example as pending and skips execution.
|
84
101
|
#
|
85
|
-
# @param [String]
|
86
|
-
# @block [Block] block optional block to be skipped
|
102
|
+
# @param message [String] optional message to add to the summary report.
|
87
103
|
#
|
88
104
|
# @example
|
89
|
-
#
|
90
105
|
# describe "an example" do
|
91
106
|
# # reported as "Pending: no reason given"
|
92
107
|
# it "is skipped with no message" do
|
@@ -97,29 +112,34 @@ module RSpec
|
|
97
112
|
# it "is skipped with a custom message" do
|
98
113
|
# skip "something else getting finished"
|
99
114
|
# end
|
100
|
-
#
|
101
|
-
# # Passes
|
102
|
-
# it "contains a skipped statement" do
|
103
|
-
# skip do
|
104
|
-
# fail
|
105
|
-
# end
|
106
|
-
# end
|
107
115
|
# end
|
108
|
-
def skip(
|
116
|
+
def skip(message=nil)
|
109
117
|
current_example = RSpec.current_example
|
110
118
|
|
111
119
|
if current_example
|
112
|
-
Pending.mark_skipped! current_example,
|
120
|
+
Pending.mark_skipped! current_example, message
|
113
121
|
end
|
114
122
|
|
115
|
-
raise SkipDeclaredInExample.new(
|
123
|
+
raise SkipDeclaredInExample.new(message)
|
116
124
|
end
|
117
125
|
|
126
|
+
# @private
|
127
|
+
#
|
128
|
+
# Mark example as skipped
|
129
|
+
#
|
130
|
+
# @param example [RSpec::Core::Example] the example to mark as skipped
|
131
|
+
# @param message_or_bool [Boolean, String] the message to use, or true
|
118
132
|
def self.mark_skipped!(example, message_or_bool)
|
119
133
|
Pending.mark_pending! example, message_or_bool
|
120
134
|
example.metadata[:skip] = true
|
121
135
|
end
|
122
136
|
|
137
|
+
# @private
|
138
|
+
#
|
139
|
+
# Mark example as pending
|
140
|
+
#
|
141
|
+
# @param example [RSpec::Core::Example] the example to mark as pending
|
142
|
+
# @param message_or_bool [Boolean, String] the message to use, or true
|
123
143
|
def self.mark_pending!(example, message_or_bool)
|
124
144
|
message = if !message_or_bool || !(String === message_or_bool)
|
125
145
|
NO_REASON_GIVEN
|
@@ -128,13 +148,17 @@ module RSpec
|
|
128
148
|
end
|
129
149
|
|
130
150
|
example.metadata[:pending] = true
|
131
|
-
example.
|
132
|
-
example.execution_result
|
151
|
+
example.execution_result.pending_message = message
|
152
|
+
example.execution_result.pending_fixed = false
|
133
153
|
end
|
134
154
|
|
155
|
+
# @private
|
156
|
+
#
|
157
|
+
# Mark example as fixed
|
158
|
+
#
|
159
|
+
# @param example [RSpec::Core::Example] the example to mark as fixed
|
135
160
|
def self.mark_fixed!(example)
|
136
|
-
example.
|
137
|
-
example.metadata[:execution_result][:pending_fixed] = true
|
161
|
+
example.execution_result.pending_fixed = true
|
138
162
|
end
|
139
163
|
end
|
140
164
|
end
|
@@ -5,9 +5,10 @@
|
|
5
5
|
#
|
6
6
|
# Given that it is always loaded, you are encouraged to keep this file as
|
7
7
|
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, make a
|
10
|
+
# separate helper file that requires this one and then use it only in the specs
|
11
|
+
# that actually need it.
|
11
12
|
#
|
12
13
|
# The `.rspec` file also contains a few flags that are not defaults but that
|
13
14
|
# users commonly want.
|
@@ -36,7 +37,7 @@ RSpec.configure do |config|
|
|
36
37
|
# Use the documentation formatter for detailed output,
|
37
38
|
# unless a formatter has already been configured
|
38
39
|
# (e.g. via a command-line flag).
|
39
|
-
config.
|
40
|
+
config.default_formatter = 'doc'
|
40
41
|
end
|
41
42
|
|
42
43
|
# Print the 10 slowest examples and example groups at the
|
data/lib/rspec/core/rake_task.rb
CHANGED
@@ -1,13 +1,25 @@
|
|
1
|
-
require 'rspec/support
|
1
|
+
require 'rspec/support'
|
2
|
+
require 'rspec/core/version'
|
3
|
+
RSpec::Support.require_rspec_support "warnings"
|
4
|
+
|
2
5
|
require 'rake'
|
3
6
|
require 'rake/tasklib'
|
4
7
|
require 'shellwords'
|
5
8
|
|
6
9
|
module RSpec
|
7
10
|
module Core
|
11
|
+
# Rspec rake task
|
12
|
+
#
|
13
|
+
# @see Rakefile
|
8
14
|
class RakeTask < ::Rake::TaskLib
|
9
15
|
include ::Rake::DSL if defined?(::Rake::DSL)
|
10
16
|
|
17
|
+
# Default path to the rspec executable
|
18
|
+
DEFAULT_RSPEC_PATH = File.expand_path('../../../../exe/rspec', __FILE__)
|
19
|
+
|
20
|
+
# Default pattern for spec files.
|
21
|
+
DEFAULT_PATTERN = './spec{,/*/**}/*_spec.rb'
|
22
|
+
|
11
23
|
# Name of task.
|
12
24
|
#
|
13
25
|
# default:
|
@@ -55,27 +67,18 @@ module RSpec
|
|
55
67
|
attr_accessor :rspec_opts
|
56
68
|
|
57
69
|
def initialize(*args, &task_block)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def setup_ivars(args)
|
71
|
-
@name = args.shift || :spec
|
72
|
-
@ruby_opts, @rspec_opts = nil, nil, nil
|
73
|
-
@verbose, @fail_on_error = true, true
|
74
|
-
|
75
|
-
@rspec_path = 'rspec'
|
76
|
-
@pattern = './spec{,/*/**}/*_spec.rb'
|
70
|
+
@name = args.shift || :spec
|
71
|
+
@ruby_opts = nil
|
72
|
+
@rspec_opts = nil
|
73
|
+
@verbose = true
|
74
|
+
@fail_on_error = true
|
75
|
+
@rspec_path = DEFAULT_RSPEC_PATH
|
76
|
+
@pattern = DEFAULT_PATTERN
|
77
|
+
|
78
|
+
define(args, &task_block)
|
77
79
|
end
|
78
80
|
|
81
|
+
# @private
|
79
82
|
def run_task(verbose)
|
80
83
|
command = spec_command
|
81
84
|
|
@@ -93,6 +96,18 @@ module RSpec
|
|
93
96
|
|
94
97
|
private
|
95
98
|
|
99
|
+
# @private
|
100
|
+
def define(args, &task_block)
|
101
|
+
desc "Run RSpec code examples" unless ::Rake.application.last_comment
|
102
|
+
|
103
|
+
task name, *args do |_, task_args|
|
104
|
+
RakeFileUtils.__send__(:verbose, verbose) do
|
105
|
+
task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block
|
106
|
+
run_task verbose
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
96
111
|
def files_to_run
|
97
112
|
if ENV['SPEC']
|
98
113
|
FileList[ ENV['SPEC'] ].sort
|
@@ -105,6 +120,7 @@ module RSpec
|
|
105
120
|
cmd_parts = []
|
106
121
|
cmd_parts << RUBY
|
107
122
|
cmd_parts << ruby_opts
|
123
|
+
cmd_parts << rspec_load_path
|
108
124
|
cmd_parts << "-S" << rspec_path
|
109
125
|
cmd_parts << files_to_run
|
110
126
|
cmd_parts << rspec_opts
|
@@ -114,6 +130,15 @@ module RSpec
|
|
114
130
|
def blank
|
115
131
|
lambda {|s| s.nil? || s == ""}
|
116
132
|
end
|
133
|
+
|
134
|
+
def rspec_load_path
|
135
|
+
@rspec_load_path ||= begin
|
136
|
+
core_and_support = $LOAD_PATH.grep \
|
137
|
+
%r{#{File::SEPARATOR}rspec-(core|support)[^#{File::SEPARATOR}]*#{File::SEPARATOR}lib}
|
138
|
+
|
139
|
+
"-I#{core_and_support.map(&:shellescape).join(File::PATH_SEPARATOR)}"
|
140
|
+
end
|
141
|
+
end
|
117
142
|
end
|
118
143
|
end
|
119
144
|
end
|
data/lib/rspec/core/reporter.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
module RSpec::Core
|
2
|
+
# A reporter will send notifications to listeners, usually formatters for the
|
3
|
+
# spec suite run.
|
2
4
|
class Reporter
|
3
5
|
|
4
6
|
def initialize(configuration)
|
5
7
|
@configuration = configuration
|
6
8
|
@listeners = Hash.new { |h,k| h[k] = Set.new }
|
7
|
-
@
|
8
|
-
@
|
9
|
+
@examples = []
|
10
|
+
@failed_examples = []
|
11
|
+
@pending_examples = []
|
12
|
+
@duration = @start = @load_time = nil
|
9
13
|
end
|
10
14
|
|
11
|
-
# @
|
12
|
-
|
13
|
-
|
14
|
-
#
|
15
|
+
# @private
|
16
|
+
attr_reader :examples, :failed_examples, :pending_examples
|
17
|
+
|
15
18
|
# Registers a listener to a list of notifications. The reporter will send notification of
|
16
19
|
# events to all registered listeners
|
20
|
+
#
|
21
|
+
# @param listener [Object] An obect that wishes to be notified of reporter events
|
22
|
+
# @param notifications [Array] Array of symbols represents the events a listener wishes to subscribe too
|
17
23
|
def register_listener(listener, *notifications)
|
18
24
|
notifications.each do |notification|
|
19
25
|
@listeners[notification.to_sym] << listener
|
@@ -21,6 +27,7 @@ module RSpec::Core
|
|
21
27
|
true
|
22
28
|
end
|
23
29
|
|
30
|
+
# @private
|
24
31
|
def registered_listeners(notification)
|
25
32
|
@listeners[notification].to_a
|
26
33
|
end
|
@@ -28,8 +35,8 @@ module RSpec::Core
|
|
28
35
|
# @api
|
29
36
|
# @overload report(count, &block)
|
30
37
|
# @overload report(count, &block)
|
31
|
-
# @param [Integer]
|
32
|
-
# @
|
38
|
+
# @param expected_example_count [Integer] the number of examples being run
|
39
|
+
# @yield [Block] block yields itself for further reporting.
|
33
40
|
#
|
34
41
|
# Initializes the report run and yields itself for further reporting. The
|
35
42
|
# block is required, so that the reporter can manage cleaning up after the
|
@@ -50,65 +57,81 @@ module RSpec::Core
|
|
50
57
|
end
|
51
58
|
end
|
52
59
|
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
# @private
|
61
|
+
def start(expected_example_count, time = RSpec::Core::Time.now)
|
62
|
+
@start = time
|
63
|
+
@load_time = (@start - @configuration.start_time).to_f
|
64
|
+
notify :start, Notifications::StartNotification.new(expected_example_count, @load_time)
|
56
65
|
end
|
57
66
|
|
67
|
+
# @private
|
58
68
|
def message(message)
|
59
69
|
notify :message, Notifications::MessageNotification.new(message)
|
60
70
|
end
|
61
71
|
|
72
|
+
# @private
|
62
73
|
def example_group_started(group)
|
63
74
|
notify :example_group_started, Notifications::GroupNotification.new(group) unless group.descendant_filtered_examples.empty?
|
64
75
|
end
|
65
76
|
|
77
|
+
# @private
|
66
78
|
def example_group_finished(group)
|
67
79
|
notify :example_group_finished, Notifications::GroupNotification.new(group) unless group.descendant_filtered_examples.empty?
|
68
80
|
end
|
69
81
|
|
82
|
+
# @private
|
70
83
|
def example_started(example)
|
71
|
-
@
|
72
|
-
notify :example_started, Notifications::ExampleNotification.
|
84
|
+
@examples << example
|
85
|
+
notify :example_started, Notifications::ExampleNotification.for(example)
|
73
86
|
end
|
74
87
|
|
88
|
+
# @private
|
75
89
|
def example_passed(example)
|
76
|
-
notify :example_passed, Notifications::ExampleNotification.
|
90
|
+
notify :example_passed, Notifications::ExampleNotification.for(example)
|
77
91
|
end
|
78
92
|
|
93
|
+
# @private
|
79
94
|
def example_failed(example)
|
80
|
-
@
|
81
|
-
notify :example_failed, Notifications::ExampleNotification.
|
95
|
+
@failed_examples << example
|
96
|
+
notify :example_failed, Notifications::ExampleNotification.for(example)
|
82
97
|
end
|
83
98
|
|
99
|
+
# @private
|
84
100
|
def example_pending(example)
|
85
|
-
@
|
86
|
-
notify :example_pending, Notifications::ExampleNotification.
|
101
|
+
@pending_examples << example
|
102
|
+
notify :example_pending, Notifications::ExampleNotification.for(example)
|
87
103
|
end
|
88
104
|
|
105
|
+
# @private
|
89
106
|
def deprecation(hash)
|
90
107
|
notify :deprecation, Notifications::DeprecationNotification.from_hash(hash)
|
91
108
|
end
|
92
109
|
|
110
|
+
# @private
|
93
111
|
def finish
|
94
112
|
begin
|
95
113
|
stop
|
96
114
|
notify :start_dump, Notifications::NullNotification
|
97
|
-
notify :dump_pending, Notifications::
|
98
|
-
notify :dump_failures, Notifications::
|
99
|
-
notify :dump_summary, Notifications::SummaryNotification.new(@duration, @example_count, @failure_count, @pending_count)
|
115
|
+
notify :dump_pending, Notifications::ExamplesNotification.new(self)
|
116
|
+
notify :dump_failures, Notifications::ExamplesNotification.new(self)
|
100
117
|
notify :deprecation_summary, Notifications::NullNotification
|
118
|
+
notify :dump_summary, Notifications::SummaryNotification.new(@duration, @examples, @failed_examples, @pending_examples, @load_time)
|
119
|
+
unless mute_profile_output?
|
120
|
+
notify :dump_profile, Notifications::ProfileNotification.new(@duration, @examples, @configuration.profile_examples)
|
121
|
+
end
|
101
122
|
notify :seed, Notifications::SeedNotification.new(@configuration.seed, seed_used?)
|
102
123
|
ensure
|
103
124
|
notify :close, Notifications::NullNotification
|
104
125
|
end
|
105
126
|
end
|
106
127
|
|
128
|
+
# @private
|
107
129
|
def stop
|
108
130
|
@duration = (RSpec::Core::Time.now - @start).to_f if @start
|
109
|
-
notify :stop, Notifications::
|
131
|
+
notify :stop, Notifications::ExamplesNotification.new(self)
|
110
132
|
end
|
111
133
|
|
134
|
+
# @private
|
112
135
|
def notify(event, notification)
|
113
136
|
registered_listeners(event).each do |formatter|
|
114
137
|
formatter.__send__(event, notification)
|
@@ -117,6 +140,11 @@ module RSpec::Core
|
|
117
140
|
|
118
141
|
private
|
119
142
|
|
143
|
+
def mute_profile_output?
|
144
|
+
# Don't print out profiled info if there are failures and `--fail-fast` is used, it just clutters the output
|
145
|
+
!@configuration.profile_examples? || (@configuration.fail_fast? && @failed_examples.size > 0)
|
146
|
+
end
|
147
|
+
|
120
148
|
def seed_used?
|
121
149
|
@configuration.seed && @configuration.seed_used?
|
122
150
|
end
|