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
data/lib/rspec/core/reporter.rb
CHANGED
|
@@ -2,9 +2,10 @@ module RSpec::Core
|
|
|
2
2
|
class Reporter
|
|
3
3
|
NOTIFICATIONS = %W[start message example_group_started example_group_finished example_started
|
|
4
4
|
example_passed example_failed example_pending start_dump dump_pending
|
|
5
|
-
dump_failures dump_summary seed close stop deprecation deprecation_summary].map
|
|
5
|
+
dump_failures dump_summary seed close stop deprecation deprecation_summary].map(&:to_sym)
|
|
6
6
|
|
|
7
|
-
def initialize(*formatters)
|
|
7
|
+
def initialize(configuration, *formatters)
|
|
8
|
+
@configuration = configuration
|
|
8
9
|
@listeners = Hash.new { |h,k| h[k] = [] }
|
|
9
10
|
formatters.each do |formatter|
|
|
10
11
|
register_listener(formatter, *NOTIFICATIONS)
|
|
@@ -32,32 +33,26 @@ module RSpec::Core
|
|
|
32
33
|
|
|
33
34
|
# @api
|
|
34
35
|
# @overload report(count, &block)
|
|
35
|
-
# @overload report(count,
|
|
36
|
+
# @overload report(count, &block)
|
|
36
37
|
# @param [Integer] count the number of examples being run
|
|
37
|
-
# @param [Integer] seed the seed used to randomize the spec run
|
|
38
38
|
# @param [Block] block yields itself for further reporting.
|
|
39
39
|
#
|
|
40
40
|
# Initializes the report run and yields itself for further reporting. The
|
|
41
41
|
# block is required, so that the reporter can manage cleaning up after the
|
|
42
42
|
# run.
|
|
43
43
|
#
|
|
44
|
-
# ### Warning:
|
|
45
|
-
#
|
|
46
|
-
# The `seed` argument is an internal API and is not guaranteed to be
|
|
47
|
-
# supported in the future.
|
|
48
|
-
#
|
|
49
44
|
# @example
|
|
50
45
|
#
|
|
51
46
|
# reporter.report(group.examples.size) do |r|
|
|
52
47
|
# example_groups.map {|g| g.run(r) }
|
|
53
48
|
# end
|
|
54
49
|
#
|
|
55
|
-
def report(expected_example_count
|
|
50
|
+
def report(expected_example_count)
|
|
56
51
|
start(expected_example_count)
|
|
57
52
|
begin
|
|
58
53
|
yield self
|
|
59
54
|
ensure
|
|
60
|
-
finish
|
|
55
|
+
finish
|
|
61
56
|
end
|
|
62
57
|
end
|
|
63
58
|
|
|
@@ -101,24 +96,21 @@ module RSpec::Core
|
|
|
101
96
|
notify :deprecation, message
|
|
102
97
|
end
|
|
103
98
|
|
|
104
|
-
def finish
|
|
99
|
+
def finish
|
|
105
100
|
begin
|
|
106
101
|
stop
|
|
107
102
|
notify :start_dump
|
|
108
103
|
notify :dump_pending
|
|
109
104
|
notify :dump_failures
|
|
110
|
-
notify :deprecation_summary
|
|
111
105
|
notify :dump_summary, @duration, @example_count, @failure_count, @pending_count
|
|
112
|
-
notify :
|
|
106
|
+
notify :deprecation_summary
|
|
107
|
+
notify :seed, @configuration.seed if seed_used?
|
|
113
108
|
ensure
|
|
114
109
|
notify :close
|
|
115
110
|
end
|
|
116
111
|
end
|
|
117
112
|
|
|
118
|
-
|
|
119
|
-
RSpec.deprecate "RSpec::Core::Reporter#abort", :replacement => "RSpec::Core::Reporter#finish"
|
|
120
|
-
finish(seed)
|
|
121
|
-
end
|
|
113
|
+
alias_method :abort, :finish
|
|
122
114
|
|
|
123
115
|
def stop
|
|
124
116
|
@duration = (RSpec::Core::Time.now - @start).to_f if @start
|
|
@@ -131,5 +123,10 @@ module RSpec::Core
|
|
|
131
123
|
end
|
|
132
124
|
end
|
|
133
125
|
|
|
126
|
+
private
|
|
127
|
+
|
|
128
|
+
def seed_used?
|
|
129
|
+
@configuration.seed && @configuration.seed_used?
|
|
130
|
+
end
|
|
134
131
|
end
|
|
135
132
|
end
|
data/lib/rspec/core/runner.rb
CHANGED
|
@@ -34,9 +34,19 @@ module RSpec
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def self.running_in_drb?
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
begin
|
|
38
|
+
if defined?(DRb) && DRb.current_server
|
|
39
|
+
require 'socket'
|
|
40
|
+
require 'uri'
|
|
41
|
+
|
|
42
|
+
local_ipv4 = IPSocket.getaddress(Socket.gethostname)
|
|
43
|
+
|
|
44
|
+
local_drb = ["127.0.0.1", "localhost", local_ipv4].any? { |addr| addr == URI(DRb.current_server.uri).host }
|
|
45
|
+
end
|
|
46
|
+
rescue DRb::DRbServerNotFound
|
|
47
|
+
ensure
|
|
48
|
+
return local_drb || false
|
|
49
|
+
end
|
|
40
50
|
end
|
|
41
51
|
|
|
42
52
|
def self.trap_interrupt
|
|
@@ -47,18 +57,6 @@ module RSpec
|
|
|
47
57
|
end
|
|
48
58
|
end
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
# @private
|
|
52
|
-
# Warns that RSpec 3.0.0 will no longer call reset for users
|
|
53
|
-
def self.warn_about_calling_reset
|
|
54
|
-
RSpec.configuration.deprecation_stream.puts(<<-EOD)
|
|
55
|
-
Calling `RSpec::Core::Runner.run` will no longer implicitly invoke
|
|
56
|
-
`RSpec.reset` as of RSpec 3.0.0. If you need RSpec to be reset between your
|
|
57
|
-
calls to `RSpec::Core::Runner.run` please invoke `RSpec.reset` manually in the
|
|
58
|
-
appropriate place.
|
|
59
|
-
EOD
|
|
60
|
-
end
|
|
61
|
-
|
|
62
60
|
# Run a suite of RSpec examples.
|
|
63
61
|
#
|
|
64
62
|
# This is used internally by RSpec to run a suite, but is available
|
|
@@ -76,36 +74,24 @@ appropriate place.
|
|
|
76
74
|
# #### Returns
|
|
77
75
|
# * +Fixnum+ - exit status code (0/1)
|
|
78
76
|
def self.run(args, err=$stderr, out=$stdout)
|
|
79
|
-
warn_about_calling_reset if RSpec.resets_required > 0
|
|
80
|
-
RSpec.resets_required += 1
|
|
81
77
|
trap_interrupt
|
|
82
78
|
options = ConfigurationOptions.new(args)
|
|
83
79
|
options.parse_options
|
|
84
80
|
|
|
85
|
-
major, minor, point = RUBY_VERSION.split('.').map { |v| v.to_i }
|
|
86
|
-
|
|
87
|
-
if major == 1 && ( (minor == 9 && point < 2) || (minor == 8 && point < 7) )
|
|
88
|
-
RSpec.deprecate "RSpec support for Ruby #{RUBY_VERSION}",
|
|
89
|
-
:replacement => "1.8.7 or >= 1.9.2",
|
|
90
|
-
:call_site => nil
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
|
|
94
81
|
if options.options[:drb]
|
|
95
82
|
require 'rspec/core/drb_command_line'
|
|
96
83
|
begin
|
|
97
84
|
DRbCommandLine.new(options).run(err, out)
|
|
98
85
|
rescue DRb::DRbConnError
|
|
99
86
|
err.puts "No DRb server is running. Running in local process instead ..."
|
|
100
|
-
new(options).run(err, out)
|
|
87
|
+
CommandLine.new(options).run(err, out)
|
|
101
88
|
end
|
|
102
89
|
else
|
|
103
|
-
new(options).run(err, out)
|
|
90
|
+
CommandLine.new(options).run(err, out)
|
|
104
91
|
end
|
|
105
92
|
ensure
|
|
106
|
-
RSpec.
|
|
93
|
+
RSpec.reset
|
|
107
94
|
end
|
|
108
95
|
end
|
|
109
|
-
|
|
110
96
|
end
|
|
111
97
|
end
|
|
@@ -38,11 +38,9 @@ module RSpec
|
|
|
38
38
|
# @api private
|
|
39
39
|
def self.record(methods)
|
|
40
40
|
methods.each do |meth|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
EOS
|
|
41
|
+
define_method(meth) do |*args, &block|
|
|
42
|
+
__shared_context_recordings << Recording.new(meth, args, block)
|
|
43
|
+
end
|
|
46
44
|
end
|
|
47
45
|
end
|
|
48
46
|
|
|
@@ -33,20 +33,9 @@ module RSpec
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
alias_method :shared_context, :shared_examples
|
|
36
|
+
alias_method :share_examples_for, :shared_examples
|
|
36
37
|
alias_method :shared_examples_for, :shared_examples
|
|
37
38
|
|
|
38
|
-
def share_examples_for(*args, &block)
|
|
39
|
-
RSpec.deprecate("`share_examples_for`", :replacement => "`shared_examples` or `shared_examples_for`")
|
|
40
|
-
shared_examples(*args, &block)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# @deprecated
|
|
44
|
-
def share_as(name, &block)
|
|
45
|
-
RSpec.deprecate("Rspec::Core::SharedExampleGroup#share_as",
|
|
46
|
-
:replacement => "RSpec::SharedContext or shared_examples")
|
|
47
|
-
SharedExampleGroup.registry.add_const(self, name, &block)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
39
|
def shared_example_groups
|
|
51
40
|
SharedExampleGroup.registry.shared_example_groups_for('main', *ancestors[0..-1])
|
|
52
41
|
end
|
|
@@ -57,18 +46,9 @@ module RSpec
|
|
|
57
46
|
end
|
|
58
47
|
|
|
59
48
|
alias_method :shared_context, :shared_examples
|
|
49
|
+
alias_method :share_examples_for, :shared_examples
|
|
60
50
|
alias_method :shared_examples_for, :shared_examples
|
|
61
51
|
|
|
62
|
-
def share_examples_for(*args, &block)
|
|
63
|
-
RSpec.deprecate("`share_examples_for`", :replacement => "`shared_examples` or `shared_examples_for`")
|
|
64
|
-
shared_examples(*args, &block)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def share_as(name, &block)
|
|
68
|
-
RSpec.deprecate("`share_as`", :replacement => "`RSpec::SharedContext` or `shared_examples`")
|
|
69
|
-
SharedExampleGroup.registry.add_const('main', name, &block)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
52
|
def shared_example_groups
|
|
73
53
|
SharedExampleGroup.registry.shared_example_groups_for('main')
|
|
74
54
|
end
|
|
@@ -104,30 +84,6 @@ module RSpec
|
|
|
104
84
|
end
|
|
105
85
|
end
|
|
106
86
|
|
|
107
|
-
def add_const(source, name, &block)
|
|
108
|
-
if Object.const_defined?(name)
|
|
109
|
-
mod = Object.const_get(name)
|
|
110
|
-
raise_name_error unless mod.created_from_caller(caller)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
mod = Module.new do
|
|
114
|
-
@shared_block = block
|
|
115
|
-
@caller_line = caller.last
|
|
116
|
-
|
|
117
|
-
def self.created_from_caller(other_caller)
|
|
118
|
-
@caller_line == other_caller.last
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def self.included(kls)
|
|
122
|
-
kls.describe(&@shared_block)
|
|
123
|
-
kls.children.first.metadata[:shared_group_name] = name
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
shared_const = Object.const_set(name, mod)
|
|
128
|
-
add_shared_example_group source, shared_const, block
|
|
129
|
-
end
|
|
130
|
-
|
|
131
87
|
def shared_example_groups_for(*sources)
|
|
132
88
|
Collection.new(sources, shared_example_groups)
|
|
133
89
|
end
|
|
@@ -150,14 +106,10 @@ module RSpec
|
|
|
150
106
|
[String, Symbol, Module].any? { |cls| cls === candidate }
|
|
151
107
|
end
|
|
152
108
|
|
|
153
|
-
def raise_name_error
|
|
154
|
-
raise NameError, "The first argument (#{name}) to share_as must be a legal name for a constant not already in use."
|
|
155
|
-
end
|
|
156
|
-
|
|
157
109
|
def warn_if_key_taken(source, key, new_block)
|
|
158
110
|
return unless existing_block = example_block_for(source, key)
|
|
159
111
|
|
|
160
|
-
|
|
112
|
+
RSpec.warn_with <<-WARNING.gsub(/^ +\|/, ''), :call_site => nil
|
|
161
113
|
|WARNING: Shared example group '#{key}' has been previously defined at:
|
|
162
114
|
| #{formatted_location existing_block}
|
|
163
115
|
|...and you are now defining it at:
|
|
@@ -8,7 +8,7 @@ module RSpec
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def [](key)
|
|
11
|
-
fetch_examples(key)
|
|
11
|
+
fetch_examples(key)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
private
|
|
@@ -21,24 +21,6 @@ module RSpec
|
|
|
21
21
|
@sources.reverse.find { |source| @examples[source].has_key? key }
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def fetch_anyway(key)
|
|
25
|
-
@examples.values.inject({}, &:merge)[key]
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def warn_deprecation_and_fetch_anyway(key)
|
|
29
|
-
if (example = fetch_anyway key)
|
|
30
|
-
backtrace_line = CallerFilter.first_non_rspec_line
|
|
31
|
-
|
|
32
|
-
RSpec.warn_deprecation <<-WARNING.gsub(/^ /, '')
|
|
33
|
-
Accessing shared_examples defined across contexts is deprecated.
|
|
34
|
-
Please declare shared_examples within a shared context, or at the top level.
|
|
35
|
-
This message was generated at: #{backtrace_line}
|
|
36
|
-
WARNING
|
|
37
|
-
|
|
38
|
-
example
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
24
|
end
|
|
43
25
|
end
|
|
44
26
|
end
|
data/lib/rspec/core/version.rb
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module RSpec
|
|
2
|
+
|
|
3
|
+
# @private
|
|
4
|
+
#
|
|
5
|
+
# Used internally to print deprecation warnings
|
|
6
|
+
def self.deprecate(deprecated, data = {})
|
|
7
|
+
RSpec.configuration.reporter.deprecation(
|
|
8
|
+
{
|
|
9
|
+
:deprecated => deprecated,
|
|
10
|
+
:call_site => CallerFilter.first_non_rspec_line
|
|
11
|
+
}.merge(data)
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @private
|
|
16
|
+
#
|
|
17
|
+
# Used internally to print deprecation warnings
|
|
18
|
+
def self.warn_deprecation(message)
|
|
19
|
+
RSpec.configuration.reporter.deprecation :message => message
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
data/lib/rspec/core/world.rb
CHANGED
|
@@ -9,17 +9,22 @@ module RSpec
|
|
|
9
9
|
|
|
10
10
|
def initialize(configuration=RSpec.configuration)
|
|
11
11
|
@configuration = configuration
|
|
12
|
-
@example_groups = []
|
|
12
|
+
@example_groups = []
|
|
13
13
|
@filtered_examples = Hash.new { |hash,group|
|
|
14
14
|
hash[group] = begin
|
|
15
15
|
examples = group.examples.dup
|
|
16
16
|
examples = filter_manager.prune(examples)
|
|
17
|
-
examples.uniq
|
|
18
|
-
examples
|
|
17
|
+
examples.uniq!
|
|
18
|
+
examples
|
|
19
19
|
end
|
|
20
20
|
}
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
def ordered_example_groups
|
|
24
|
+
ordering_strategy = @configuration.ordering_registry.fetch(:global)
|
|
25
|
+
ordering_strategy.order(@example_groups)
|
|
26
|
+
end
|
|
27
|
+
|
|
23
28
|
def reset
|
|
24
29
|
example_groups.clear
|
|
25
30
|
SharedExampleGroup.registry.clear
|
|
@@ -47,9 +52,8 @@ module RSpec
|
|
|
47
52
|
end
|
|
48
53
|
|
|
49
54
|
def example_count
|
|
50
|
-
example_groups
|
|
51
|
-
sum
|
|
52
|
-
end
|
|
55
|
+
FlatMap.flat_map(example_groups) {|g| g.descendants}.
|
|
56
|
+
inject(0) {|sum, g| sum + g.filtered_examples.size}
|
|
53
57
|
end
|
|
54
58
|
|
|
55
59
|
def preceding_declaration_line(filter_line)
|
|
@@ -86,7 +90,7 @@ module RSpec
|
|
|
86
90
|
example_groups.clear
|
|
87
91
|
if filter_manager.empty?
|
|
88
92
|
reporter.message("No examples found.")
|
|
89
|
-
elsif exclusion_filter.
|
|
93
|
+
elsif exclusion_filter.empty_without_conditional_filters?
|
|
90
94
|
message = everything_filtered_message
|
|
91
95
|
if @configuration.run_all_when_everything_filtered?
|
|
92
96
|
message << "; ignoring #{inclusion_filter.description}"
|
|
@@ -109,7 +113,7 @@ module RSpec
|
|
|
109
113
|
end
|
|
110
114
|
|
|
111
115
|
def announce_exclusion_filter(announcements)
|
|
112
|
-
unless exclusion_filter.
|
|
116
|
+
unless exclusion_filter.empty_without_conditional_filters?
|
|
113
117
|
announcements << "exclude #{exclusion_filter.description}"
|
|
114
118
|
end
|
|
115
119
|
end
|
|
@@ -39,7 +39,6 @@ describe 'command line', :ui do
|
|
|
39
39
|
specify('group 1 example 4') {}
|
|
40
40
|
specify('group 1 example 5') {}
|
|
41
41
|
specify('group 1 example 6') {}
|
|
42
|
-
specify('group 1 example 5') {}
|
|
43
42
|
specify('group 1 example 7') {}
|
|
44
43
|
specify('group 1 example 8') {}
|
|
45
44
|
specify('group 1 example 9') {}
|
|
@@ -81,19 +80,13 @@ describe 'command line', :ui do
|
|
|
81
80
|
"""
|
|
82
81
|
end
|
|
83
82
|
|
|
84
|
-
after do
|
|
85
|
-
RSpec.resets_required = 0
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
before do
|
|
89
|
-
RSpec.resets_required = 0
|
|
90
|
-
end
|
|
91
|
-
|
|
92
83
|
describe '--order rand' do
|
|
93
84
|
it 'runs the examples and groups in a different order each time' do
|
|
94
|
-
run_command '
|
|
95
|
-
|
|
96
|
-
|
|
85
|
+
run_command 'spec/order_spec.rb --order rand -f doc'
|
|
86
|
+
original_seed = srand
|
|
87
|
+
RSpec.configuration.seed = srand # reset seed in same process
|
|
88
|
+
run_command 'spec/order_spec.rb --order rand -f doc'
|
|
89
|
+
srand original_seed
|
|
97
90
|
|
|
98
91
|
expect(stdout.string).to match(/Randomized with seed \d+/)
|
|
99
92
|
|
|
@@ -106,7 +99,7 @@ describe 'command line', :ui do
|
|
|
106
99
|
|
|
107
100
|
describe '--order rand:SEED' do
|
|
108
101
|
it 'runs the examples and groups in the same order each time' do
|
|
109
|
-
2.times { run_command '
|
|
102
|
+
2.times { run_command 'spec/order_spec.rb --order rand:123 -f doc' }
|
|
110
103
|
|
|
111
104
|
expect(stdout.string).to match(/Randomized with seed 123/)
|
|
112
105
|
|
|
@@ -119,9 +112,9 @@ describe 'command line', :ui do
|
|
|
119
112
|
|
|
120
113
|
describe '--seed SEED' do
|
|
121
114
|
it "forces '--order rand' and runs the examples and groups in the same order each time" do
|
|
122
|
-
2.times { run_command '
|
|
115
|
+
2.times { run_command 'spec/order_spec.rb --seed 123 -f doc' }
|
|
123
116
|
|
|
124
|
-
expect(stdout.string).to match(/Randomized with seed
|
|
117
|
+
expect(stdout.string).to match(/Randomized with seed 123/)
|
|
125
118
|
|
|
126
119
|
top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
127
120
|
nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
@@ -130,8 +123,8 @@ describe 'command line', :ui do
|
|
|
130
123
|
end
|
|
131
124
|
|
|
132
125
|
it "runs examples in the same order, regardless of the order in which files are given" do
|
|
133
|
-
run_command '
|
|
134
|
-
run_command '
|
|
126
|
+
run_command 'spec/simple_spec.rb spec/simple_spec2.rb --seed 1337 -f doc'
|
|
127
|
+
run_command 'spec/simple_spec2.rb spec/simple_spec.rb --seed 1337 -f doc'
|
|
135
128
|
|
|
136
129
|
top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
137
130
|
nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
@@ -139,10 +132,12 @@ describe 'command line', :ui do
|
|
|
139
132
|
end
|
|
140
133
|
|
|
141
134
|
describe '--order defined on CLI with --order rand in .rspec' do
|
|
135
|
+
after { remove_file '.rspec' }
|
|
136
|
+
|
|
142
137
|
it "overrides --order rand with --order defined" do
|
|
143
138
|
write_file '.rspec', '--order rand'
|
|
144
139
|
|
|
145
|
-
run_command '
|
|
140
|
+
run_command 'spec/order_spec.rb --order defined -f doc'
|
|
146
141
|
|
|
147
142
|
expect(stdout.string).not_to match(/Randomized/)
|
|
148
143
|
|
|
@@ -153,10 +148,12 @@ describe 'command line', :ui do
|
|
|
153
148
|
end
|
|
154
149
|
|
|
155
150
|
context 'when a custom order is configured' do
|
|
151
|
+
after { remove_file 'spec/custom_order_spec.rb' }
|
|
152
|
+
|
|
156
153
|
before do
|
|
157
154
|
write_file 'spec/custom_order_spec.rb', """
|
|
158
155
|
RSpec.configure do |config|
|
|
159
|
-
config.register_ordering
|
|
156
|
+
config.register_ordering :global do |list|
|
|
160
157
|
list.sort_by { |item| item.description }
|
|
161
158
|
end
|
|
162
159
|
end
|
|
@@ -175,7 +172,7 @@ describe 'command line', :ui do
|
|
|
175
172
|
end
|
|
176
173
|
|
|
177
174
|
it 'orders the groups and examples by the provided strategy' do
|
|
178
|
-
run_command '
|
|
175
|
+
run_command 'spec/custom_order_spec.rb -f doc'
|
|
179
176
|
|
|
180
177
|
top_level_groups { |groups| expect(groups.flatten).to eq(['group A', 'group B']) }
|
|
181
178
|
examples('group B') do |examples|
|
|
@@ -207,8 +204,8 @@ describe 'command line', :ui do
|
|
|
207
204
|
end
|
|
208
205
|
|
|
209
206
|
def run_command(cmd)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
in_current_dir do
|
|
208
|
+
RSpec::Core::Runner.run(cmd.split, stderr, stdout)
|
|
209
|
+
end
|
|
213
210
|
end
|
|
214
211
|
end
|