rspec-core 2.99.0 → 3.0.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 +8 -8
- checksums.yaml.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +339 -1
- data/License.txt +1 -0
- data/README.md +19 -37
- data/exe/rspec +2 -23
- data/lib/rspec/core/backport_random.rb +336 -0
- data/lib/rspec/core/backtrace_formatter.rb +70 -0
- data/lib/rspec/core/configuration.rb +479 -577
- data/lib/rspec/core/configuration_options.rb +71 -54
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +86 -18
- data/lib/rspec/core/example.rb +267 -119
- data/lib/rspec/core/example_group.rb +381 -393
- data/lib/rspec/core/filter_manager.rb +133 -114
- data/lib/rspec/core/flat_map.rb +18 -0
- data/lib/rspec/core/formatters/base_formatter.rb +51 -125
- data/lib/rspec/core/formatters/base_text_formatter.rb +34 -286
- data/lib/rspec/core/formatters/console_codes.rb +24 -1
- data/lib/rspec/core/formatters/deprecation_formatter.rb +25 -26
- data/lib/rspec/core/formatters/documentation_formatter.rb +27 -25
- data/lib/rspec/core/formatters/helpers.rb +14 -36
- data/lib/rspec/core/formatters/html_formatter.rb +58 -65
- data/lib/rspec/core/formatters/html_printer.rb +12 -18
- data/lib/rspec/core/formatters/json_formatter.rb +54 -31
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +11 -15
- data/lib/rspec/core/formatters/snippet_extractor.rb +22 -11
- data/lib/rspec/core/formatters.rb +90 -43
- data/lib/rspec/core/hooks.rb +325 -270
- data/lib/rspec/core/memoized_helpers.rb +45 -156
- data/lib/rspec/core/metadata.rb +284 -236
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
- data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
- data/lib/rspec/core/mocking_adapters/null.rb +12 -0
- data/lib/rspec/core/mocking_adapters/rr.rb +29 -0
- data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
- data/lib/rspec/core/notifications.rb +511 -0
- data/lib/rspec/core/option_parser.rb +49 -74
- data/lib/rspec/core/ordering.rb +156 -0
- data/lib/rspec/core/pending.rb +94 -96
- data/lib/rspec/core/project_initializer/.rspec +3 -0
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +78 -0
- data/lib/rspec/core/project_initializer.rb +24 -64
- data/lib/rspec/core/rake_task.rb +44 -130
- data/lib/rspec/core/reporter.rb +76 -59
- data/lib/rspec/core/ruby_project.rb +2 -1
- data/lib/rspec/core/runner.rb +117 -52
- data/lib/rspec/core/shared_context.rb +10 -10
- data/lib/rspec/core/shared_example_group.rb +108 -121
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +40 -0
- data/lib/rspec/core/world.rb +66 -10
- data/lib/rspec/core.rb +64 -104
- data.tar.gz.sig +3 -0
- metadata +75 -322
- metadata.gz.sig +1 -0
- data/exe/autospec +0 -13
- data/features/Autotest.md +0 -38
- data/features/README.md +0 -17
- data/features/Upgrade.md +0 -364
- data/features/command_line/README.md +0 -28
- data/features/command_line/example_name_option.feature +0 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/format_option.feature +0 -75
- data/features/command_line/init.feature +0 -18
- data/features/command_line/line_number_appended_to_path.feature +0 -140
- data/features/command_line/line_number_option.feature +0 -53
- data/features/command_line/order.feature +0 -26
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -22
- 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 -48
- data/features/configuration/backtrace_clean_patterns.feature +0 -102
- 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/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/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/configuration/show_failures_in_pending_blocks.feature +0 -61
- data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
- 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 -294
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -197
- data/features/filtering/exclusion_filters.feature +0 -138
- data/features/filtering/if_and_unless.feature +0 -168
- data/features/filtering/inclusion_filters.feature +0 -105
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -36
- data/features/formatters/json_formatter.feature +0 -30
- 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 -149
- data/features/hooks/around_hooks.feature +0 -343
- data/features/hooks/before_and_after_hooks.feature +0 -427
- data/features/hooks/filtering.feature +0 -234
- data/features/metadata/current_example.feature +0 -56
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -113
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -96
- data/features/mock_framework_integration/use_mocha.feature +0 -97
- data/features/mock_framework_integration/use_rr.feature +0 -98
- data/features/mock_framework_integration/use_rspec.feature +0 -97
- data/features/pending/pending_examples.feature +0 -229
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -49
- data/features/subject/attribute_of_subject.feature +0 -124
- 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 -14
- data/features/support/rubinius.rb +0 -6
- 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/command_line.rb +0 -47
- data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
- data/lib/rspec/core/deprecation.rb +0 -26
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- 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/text_mate_formatter.rb +0 -34
- data/lib/rspec/core/metadata_hash_builder.rb +0 -97
- data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
- data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
- data/lib/rspec/core/mocking/with_rr.rb +0 -27
- data/lib/rspec/core/mocking/with_rspec.rb +0 -27
- data/lib/rspec/core/shared_example_group/collection.rb +0 -45
- 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/command_line/order_spec.rb +0 -204
- data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
- data/spec/rspec/core/caller_filter_spec.rb +0 -58
- data/spec/rspec/core/command_line_spec.rb +0 -127
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -417
- data/spec/rspec/core/configuration_spec.rb +0 -2072
- data/spec/rspec/core/deprecation_spec.rb +0 -27
- data/spec/rspec/core/deprecations_spec.rb +0 -59
- 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 -25
- data/spec/rspec/core/example_group_spec.rb +0 -1337
- data/spec/rspec/core/example_spec.rb +0 -502
- data/spec/rspec/core/filter_manager_spec.rb +0 -246
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -108
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -524
- data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -263
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -89
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -131
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -115
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters/text_mate_formatted.html +0 -397
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -269
- data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -776
- data/spec/rspec/core/metadata_spec.rb +0 -514
- data/spec/rspec/core/option_parser_spec.rb +0 -297
- data/spec/rspec/core/pending_example_spec.rb +0 -260
- data/spec/rspec/core/pending_spec.rb +0 -27
- data/spec/rspec/core/project_initializer_spec.rb +0 -130
- data/spec/rspec/core/rake_task_spec.rb +0 -202
- data/spec/rspec/core/reporter_spec.rb +0 -167
- 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 -60
- 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 -82
- data/spec/rspec/core/shared_context_spec.rb +0 -114
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -70
- data/spec/rspec/core/shared_example_group_spec.rb +0 -138
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -108
- data/spec/spec_helper.rb +0 -135
- data/spec/support/config_options_helper.rb +0 -15
- data/spec/support/helper_methods.rb +0 -55
- data/spec/support/in_sub_process.rb +0 -37
- data/spec/support/isolate_load_path_mutation.rb +0 -6
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/matchers.rb +0 -65
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/sandboxed_mock_space.rb +0 -116
- data/spec/support/shared_example_groups.rb +0 -42
- data/spec/support/silence_dsl_deprecations.rb +0 -32
- data/spec/support/spec_files.rb +0 -44
data/spec/spec_helper.rb
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
|
|
3
|
-
begin
|
|
4
|
-
require 'spork'
|
|
5
|
-
rescue LoadError
|
|
6
|
-
module Spork
|
|
7
|
-
def self.prefork
|
|
8
|
-
yield
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.each_run
|
|
12
|
-
yield
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
Spork.prefork do
|
|
18
|
-
require 'rspec/autorun'
|
|
19
|
-
require 'autotest/rspec2'
|
|
20
|
-
require 'aruba/api'
|
|
21
|
-
|
|
22
|
-
if RUBY_PLATFORM == 'java'
|
|
23
|
-
# Works around https://jira.codehaus.org/browse/JRUBY-5678
|
|
24
|
-
require 'fileutils'
|
|
25
|
-
ENV['TMPDIR'] = File.expand_path('../../tmp', __FILE__)
|
|
26
|
-
FileUtils.mkdir_p(ENV['TMPDIR'])
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
Dir['./spec/support/**/*.rb'].map {|f| require f}
|
|
30
|
-
|
|
31
|
-
class NullObject
|
|
32
|
-
private
|
|
33
|
-
def method_missing(method, *args, &block)
|
|
34
|
-
# ignore
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
module Sandboxing
|
|
39
|
-
def self.sandboxed(&block)
|
|
40
|
-
@orig_config = RSpec.configuration
|
|
41
|
-
@orig_world = RSpec.world
|
|
42
|
-
@orig_example = RSpec.current_example
|
|
43
|
-
new_config = RSpec::Core::Configuration.new
|
|
44
|
-
new_world = RSpec::Core::World.new(new_config)
|
|
45
|
-
RSpec.configuration = new_config
|
|
46
|
-
RSpec.world = new_world
|
|
47
|
-
object = Object.new
|
|
48
|
-
object.extend(RSpec::Core::SharedExampleGroup)
|
|
49
|
-
|
|
50
|
-
(class << RSpec::Core::ExampleGroup; self; end).class_eval do
|
|
51
|
-
alias_method :orig_run, :run
|
|
52
|
-
def run(reporter=nil)
|
|
53
|
-
RSpec.current_example = nil
|
|
54
|
-
orig_run(reporter || NullObject.new)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
RSpec::Core::SandboxedMockSpace.sandboxed do
|
|
59
|
-
object.instance_eval(&block)
|
|
60
|
-
end
|
|
61
|
-
ensure
|
|
62
|
-
(class << RSpec::Core::ExampleGroup; self; end).class_eval do
|
|
63
|
-
remove_method :run
|
|
64
|
-
alias_method :run, :orig_run
|
|
65
|
-
remove_method :orig_run
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
RSpec.configuration = @orig_config
|
|
69
|
-
RSpec.world = @orig_world
|
|
70
|
-
RSpec.current_example = @orig_example
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def in_editor?
|
|
75
|
-
ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM')
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
module EnvHelpers
|
|
79
|
-
def with_env_vars(vars)
|
|
80
|
-
original = ENV.to_hash
|
|
81
|
-
vars.each { |k, v| ENV[k] = v }
|
|
82
|
-
|
|
83
|
-
begin
|
|
84
|
-
yield
|
|
85
|
-
ensure
|
|
86
|
-
ENV.replace(original)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def without_env_vars(*vars)
|
|
91
|
-
original = ENV.to_hash
|
|
92
|
-
vars.each { |k| ENV.delete(k) }
|
|
93
|
-
|
|
94
|
-
begin
|
|
95
|
-
yield
|
|
96
|
-
ensure
|
|
97
|
-
ENV.replace(original)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
RSpec.configure do |c|
|
|
103
|
-
# structural
|
|
104
|
-
c.alias_it_behaves_like_to 'it_has_behavior'
|
|
105
|
-
c.around {|example| Sandboxing.sandboxed { example.run }}
|
|
106
|
-
c.include(RSpecHelpers)
|
|
107
|
-
c.include Aruba::Api, :example_group => {
|
|
108
|
-
:file_path => /spec\/command_line/
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
c.expect_with :rspec do |expectations|
|
|
112
|
-
expectations.syntax = :expect
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# runtime options
|
|
116
|
-
c.treat_symbols_as_metadata_keys_with_true_values = true
|
|
117
|
-
c.color = !in_editor?
|
|
118
|
-
c.filter_run :focus
|
|
119
|
-
c.include EnvHelpers
|
|
120
|
-
c.run_all_when_everything_filtered = true
|
|
121
|
-
c.filter_run_excluding :ruby => lambda {|version|
|
|
122
|
-
case version.to_s
|
|
123
|
-
when "!jruby"
|
|
124
|
-
RUBY_ENGINE == "jruby"
|
|
125
|
-
when /^> (.*)/
|
|
126
|
-
!(RUBY_VERSION.to_s > $1)
|
|
127
|
-
else
|
|
128
|
-
!(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
|
|
129
|
-
end
|
|
130
|
-
}
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
Spork.each_run do
|
|
135
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module ConfigOptionsHelper
|
|
2
|
-
extend RSpec::SharedContext
|
|
3
|
-
|
|
4
|
-
around(:each) { |e| without_env_vars('SPEC_OPTS', &e) }
|
|
5
|
-
|
|
6
|
-
def config_options_object(*args)
|
|
7
|
-
coo = RSpec::Core::ConfigurationOptions.new(args)
|
|
8
|
-
coo.parse_options
|
|
9
|
-
coo
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def parse_options(*args)
|
|
13
|
-
config_options_object(*args).options
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
module RSpecHelpers
|
|
2
|
-
def relative_path(path)
|
|
3
|
-
RSpec::Core::Metadata.relative_path(path)
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
def ignoring_warnings
|
|
7
|
-
original = $VERBOSE
|
|
8
|
-
$VERBOSE = nil
|
|
9
|
-
result = yield
|
|
10
|
-
$VERBOSE = original
|
|
11
|
-
result
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def safely
|
|
15
|
-
Thread.new do
|
|
16
|
-
ignoring_warnings { $SAFE = 3 }
|
|
17
|
-
yield
|
|
18
|
-
end.join
|
|
19
|
-
|
|
20
|
-
# $SAFE is not supported on Rubinius
|
|
21
|
-
unless defined?(Rubinius)
|
|
22
|
-
expect($SAFE).to eql 0 # $SAFE should not have changed in this thread.
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def expect_deprecation_with_call_site(file, line, deprecated = //)
|
|
27
|
-
expect(RSpec.configuration.reporter).to receive(:deprecation) do |options|
|
|
28
|
-
expect(options[:call_site]).to include([file, line].join(':'))
|
|
29
|
-
expect(options[:deprecated]).to match(deprecated)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def expect_deprecation_with_no_call_site(deprecated)
|
|
34
|
-
expect(RSpec.configuration.reporter).to receive(:deprecation) do |options|
|
|
35
|
-
expect(options).to include(:call_site => nil)
|
|
36
|
-
expect(options[:deprecated]).to match(deprecated)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def expect_warn_deprecation_with_call_site(file, line, deprecated = //)
|
|
41
|
-
expect(RSpec.configuration.reporter).to receive(:deprecation) do |options|
|
|
42
|
-
expect(options[:message]).to include([file, line].join(':'))
|
|
43
|
-
expect(options[:message]).to match(deprecated)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def expect_no_deprecation
|
|
48
|
-
expect(RSpec.configuration.reporter).not_to receive(:deprecation)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def allow_deprecation
|
|
52
|
-
allow(RSpec.configuration.reporter).to receive(:deprecation)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
module InSubProcess
|
|
2
|
-
if RUBY_PLATFORM == 'java'
|
|
3
|
-
def in_sub_process
|
|
4
|
-
pending "This spec requires forking to work properly, " +
|
|
5
|
-
"and JRuby does not support forking"
|
|
6
|
-
end
|
|
7
|
-
else
|
|
8
|
-
# Useful as a way to isolate a global change to a subprocess.
|
|
9
|
-
def in_sub_process
|
|
10
|
-
readme, writeme = IO.pipe
|
|
11
|
-
|
|
12
|
-
pid = Process.fork do
|
|
13
|
-
exception = nil
|
|
14
|
-
begin
|
|
15
|
-
yield
|
|
16
|
-
rescue Exception => e
|
|
17
|
-
exception = e
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
writeme.write Marshal.dump(exception)
|
|
21
|
-
|
|
22
|
-
readme.close
|
|
23
|
-
writeme.close
|
|
24
|
-
exit! # prevent at_exit hooks from running (e.g. minitest)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
writeme.close
|
|
28
|
-
Process.waitpid(pid)
|
|
29
|
-
|
|
30
|
-
exception = Marshal.load(readme.read)
|
|
31
|
-
readme.close
|
|
32
|
-
|
|
33
|
-
raise exception if exception
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
require 'tmpdir'
|
|
2
|
-
require 'fileutils'
|
|
3
|
-
|
|
4
|
-
shared_context "isolated home directory", :isolated_home => true do
|
|
5
|
-
around do |ex|
|
|
6
|
-
Dir.mktmpdir do |tmp_dir|
|
|
7
|
-
original_home = ENV['HOME']
|
|
8
|
-
begin
|
|
9
|
-
ENV['HOME'] = tmp_dir
|
|
10
|
-
ex.call
|
|
11
|
-
ensure
|
|
12
|
-
ENV['HOME'] = original_home
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
data/spec/support/matchers.rb
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
RSpec::Matchers.define :map_specs do |specs|
|
|
2
|
-
match do |autotest|
|
|
3
|
-
@specs = specs
|
|
4
|
-
@autotest = prepare(autotest)
|
|
5
|
-
autotest.test_files_for(@file) == specs
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
chain :to do |file|
|
|
9
|
-
@file = file
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
failure_message_for_should do
|
|
13
|
-
"expected #{@autotest.class} to map #{@specs.inspect} to #{@file.inspect}\ngot #{@actual.inspect}"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def prepare(autotest)
|
|
17
|
-
find_order = @specs.dup << @file
|
|
18
|
-
autotest.instance_eval { @find_order = find_order }
|
|
19
|
-
autotest
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
RSpec::Matchers.define :fail_with do |exception_klass|
|
|
24
|
-
match do |example|
|
|
25
|
-
failure_reason(example, exception_klass).nil?
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
failure_message_for_should do |example|
|
|
29
|
-
"expected example to fail with a #{exception_klass} exception, but #{failure_reason(example, exception_klass)}"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def failure_reason(example, exception_klass)
|
|
33
|
-
result = example.metadata[:execution_result]
|
|
34
|
-
case
|
|
35
|
-
when example.metadata[:pending] then "was pending"
|
|
36
|
-
when result[:status] != 'failed' then result[:status]
|
|
37
|
-
when !result[:exception].is_a?(exception_klass) then "failed with a #{result[:exception].class}"
|
|
38
|
-
else nil
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
RSpec::Matchers.define :pass do
|
|
44
|
-
match do |example|
|
|
45
|
-
failure_reason(example).nil?
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
failure_message_for_should do |example|
|
|
49
|
-
"expected example to pass, but #{failure_reason(example)}"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def failure_reason(example)
|
|
53
|
-
result = example.metadata[:execution_result]
|
|
54
|
-
case
|
|
55
|
-
when example.metadata[:pending] then "was pending"
|
|
56
|
-
when result[:status] != 'passed' then result[:status]
|
|
57
|
-
else nil
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
RSpec::Matchers.module_eval do
|
|
63
|
-
alias_method :have_failed_with, :fail_with
|
|
64
|
-
alias_method :have_passed, :pass
|
|
65
|
-
end
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
require 'rspec/mocks'
|
|
2
|
-
|
|
3
|
-
module RSpec
|
|
4
|
-
module Mocks
|
|
5
|
-
Space.class_eval do
|
|
6
|
-
undef print_out_of_example_deprecation
|
|
7
|
-
def print_out_of_example_deprecation
|
|
8
|
-
# The simple "are you outside of an example" detection in rspec-mocks
|
|
9
|
-
# does not properly handle our dog fooding here in rspec core, where we define
|
|
10
|
-
# example groups and examples from within an example and run them.
|
|
11
|
-
# As a result, we get `SystemStackError` in a few specs that are mocking
|
|
12
|
-
# `RSpec.deprecate` and creating nested examples, but we don't care about
|
|
13
|
-
# this warning here in rspec-core.
|
|
14
|
-
#
|
|
15
|
-
# This redefintion silences it.
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
module Core
|
|
21
|
-
# Because rspec-core dog-foods itself, rspec-core's spec suite has
|
|
22
|
-
# examples that define example groups and examples and run them. The
|
|
23
|
-
# usual lifetime of an RSpec::Mocks::Proxy is for one example
|
|
24
|
-
# (the proxy cache gets cleared between each example), but since the
|
|
25
|
-
# specs in rspec-core's suite sometimes create test doubles and pass
|
|
26
|
-
# them to examples a spec defines and runs, the test double's proxy
|
|
27
|
-
# must live beyond the inner example: it must live for the scope
|
|
28
|
-
# of wherever it got defined. Here we implement the necessary semantics
|
|
29
|
-
# for rspec-core's specs:
|
|
30
|
-
#
|
|
31
|
-
# - #verify_all and #reset_all affect only mocks that were created
|
|
32
|
-
# within the current scope.
|
|
33
|
-
# - Mock proxies live for the duration of the scope in which they are
|
|
34
|
-
# created.
|
|
35
|
-
#
|
|
36
|
-
# Thus, mock proxies created in an inner example live for only that
|
|
37
|
-
# example, but mock proxies created in an outer example can be used
|
|
38
|
-
# in an inner example but will only be reset/verified when the outer
|
|
39
|
-
# example completes.
|
|
40
|
-
class SandboxedMockSpace < ::RSpec::Mocks::Space
|
|
41
|
-
def self.sandboxed
|
|
42
|
-
orig_space = RSpec::Mocks.space
|
|
43
|
-
RSpec::Mocks.space = RSpec::Core::SandboxedMockSpace.new
|
|
44
|
-
|
|
45
|
-
RSpec::Core::Example.class_eval do
|
|
46
|
-
alias_method :orig_run, :run
|
|
47
|
-
def run(*args)
|
|
48
|
-
RSpec::Mocks.space.sandboxed do
|
|
49
|
-
orig_run(*args)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
yield
|
|
55
|
-
ensure
|
|
56
|
-
RSpec::Core::Example.class_eval do
|
|
57
|
-
remove_method :run
|
|
58
|
-
alias_method :run, :orig_run
|
|
59
|
-
remove_method :orig_run
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
RSpec::Mocks.space = orig_space
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
class Sandbox
|
|
66
|
-
attr_reader :proxies
|
|
67
|
-
|
|
68
|
-
def initialize
|
|
69
|
-
@proxies = Set.new
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def verify_all
|
|
73
|
-
@proxies.each { |p| p.verify }
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def reset_all
|
|
77
|
-
@proxies.each { |p| p.reset }
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def initialize
|
|
82
|
-
@sandbox_stack = []
|
|
83
|
-
super
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def sandboxed
|
|
87
|
-
@sandbox_stack << Sandbox.new
|
|
88
|
-
yield
|
|
89
|
-
ensure
|
|
90
|
-
@sandbox_stack.pop
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def verify_all
|
|
94
|
-
return super unless sandbox = @sandbox_stack.last
|
|
95
|
-
sandbox.verify_all
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def reset_all
|
|
99
|
-
return super unless sandbox = @sandbox_stack.last
|
|
100
|
-
sandbox.reset_all
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def proxy_for(object)
|
|
104
|
-
new_proxy = !proxies.has_key?(object.__id__)
|
|
105
|
-
proxy = super
|
|
106
|
-
|
|
107
|
-
if new_proxy && sandbox = @sandbox_stack.last
|
|
108
|
-
sandbox.proxies << proxy
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
proxy
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
shared_examples_for "metadata hash builder" do
|
|
2
|
-
context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to true" do
|
|
3
|
-
let(:hash) { metadata_hash(:foo, :bar, :bazz => 23) }
|
|
4
|
-
|
|
5
|
-
before(:each) do
|
|
6
|
-
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = true }
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it 'treats symbols as metadata keys with a true value' do
|
|
10
|
-
expect(hash[:foo]).to be(true)
|
|
11
|
-
expect(hash[:bar]).to be(true)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it 'still processes hash values normally' do
|
|
15
|
-
expect(hash[:bazz]).to be(23)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to false" do
|
|
20
|
-
let(:warning_receiver) { Kernel }
|
|
21
|
-
|
|
22
|
-
before(:each) do
|
|
23
|
-
allow_deprecation
|
|
24
|
-
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = false }
|
|
25
|
-
warning_receiver.stub(:warn)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'prints a deprecation warning about any symbols given as arguments' do
|
|
29
|
-
warning_receiver.should_receive(:warn).with(/In RSpec 3, these symbols will be treated as metadata keys/)
|
|
30
|
-
metadata_hash(:foo, :bar, :key => 'value')
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it 'does not treat symbols as metadata keys' do
|
|
34
|
-
expect(metadata_hash(:foo, :bar, :key => 'value')).not_to include(:foo, :bar)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it 'does not print a warning if there are no symbol arguments' do
|
|
38
|
-
warning_receiver.should_not_receive(:warn)
|
|
39
|
-
metadata_hash(:foo => 23, :bar => 17)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module SilenceDSLDeprecations
|
|
2
|
-
class Reporter
|
|
3
|
-
def initialize(reporter)
|
|
4
|
-
@reporter = reporter
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def deprecation(*)
|
|
8
|
-
# do nothing
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def respond_to?(*args)
|
|
12
|
-
@reporter.respond_to?(*args) || super
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def method_missing(*args, &block)
|
|
16
|
-
@reporter.__send__(*args, &block)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def silence_dsl_deprecations
|
|
21
|
-
old_reporter = RSpec.configuration.reporter
|
|
22
|
-
replace_reporter(Reporter.new(old_reporter))
|
|
23
|
-
yield
|
|
24
|
-
ensure
|
|
25
|
-
replace_reporter(old_reporter)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def replace_reporter(new_reporter)
|
|
29
|
-
RSpec.configuration.instance_variable_set(:@reporter, new_reporter)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
data/spec/support/spec_files.rb
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
shared_context "spec files" do
|
|
2
|
-
def failing_spec_filename
|
|
3
|
-
@failing_spec_filename ||= File.expand_path(File.dirname(__FILE__)) + "/_failing_spec.rb"
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
def passing_spec_filename
|
|
7
|
-
@passing_spec_filename ||= File.expand_path(File.dirname(__FILE__)) + "/_passing_spec.rb"
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def create_passing_spec_file
|
|
11
|
-
File.open(passing_spec_filename, 'w') do |f|
|
|
12
|
-
f.write %q{
|
|
13
|
-
describe "passing spec" do
|
|
14
|
-
it "passes" do
|
|
15
|
-
expect(1).to eq(1)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
}
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def create_failing_spec_file
|
|
23
|
-
File.open(failing_spec_filename, 'w') do |f|
|
|
24
|
-
f.write %q{
|
|
25
|
-
describe "failing spec" do
|
|
26
|
-
it "fails" do
|
|
27
|
-
expect(1).to eq(2)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
}
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
before(:all) do
|
|
35
|
-
create_passing_spec_file
|
|
36
|
-
create_failing_spec_file
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
after(:all) do
|
|
40
|
-
File.delete(passing_spec_filename)
|
|
41
|
-
File.delete(failing_spec_filename)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
end
|