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
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
module RSpec
|
|
2
|
-
# Consistent implementation for "cleaning" the caller method to strip out
|
|
3
|
-
# non-rspec lines. This enables errors to be reported at the call site in
|
|
4
|
-
# the code using the library, which is far more useful than the particular
|
|
5
|
-
# internal method that raised an error.
|
|
6
|
-
|
|
7
|
-
unless defined?(CallerFilter)
|
|
8
|
-
|
|
9
|
-
class CallerFilter
|
|
10
|
-
|
|
11
|
-
RSPEC_LIBS = %w[
|
|
12
|
-
core
|
|
13
|
-
mocks
|
|
14
|
-
expectations
|
|
15
|
-
matchers
|
|
16
|
-
rails
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
ADDITIONAL_TOP_LEVEL_FILES = %w[ autorun ]
|
|
20
|
-
|
|
21
|
-
LIB_REGEX = %r{/lib/rspec/(#{(RSPEC_LIBS + ADDITIONAL_TOP_LEVEL_FILES).join('|')})(\.rb|/)}
|
|
22
|
-
|
|
23
|
-
if RUBY_VERSION >= '2.0.0'
|
|
24
|
-
def self.first_non_rspec_line
|
|
25
|
-
# `caller` is an expensive method that scales linearly with the size of
|
|
26
|
-
# the stack. The performance hit for fetching it in chunks is small,
|
|
27
|
-
# and since the target line is probably near the top of the stack, the
|
|
28
|
-
# overall improvement of a chunked search like this is significant.
|
|
29
|
-
#
|
|
30
|
-
# See benchmarks/caller.rb for measurements.
|
|
31
|
-
|
|
32
|
-
# Initial value here is mostly arbitrary, but is chosen to give good
|
|
33
|
-
# performance on the common case of creating a double.
|
|
34
|
-
increment = 5
|
|
35
|
-
i = 1
|
|
36
|
-
line = nil
|
|
37
|
-
|
|
38
|
-
while !line
|
|
39
|
-
stack = caller(i, increment)
|
|
40
|
-
return nil unless stack
|
|
41
|
-
|
|
42
|
-
line = stack.find { |l| l !~ LIB_REGEX }
|
|
43
|
-
|
|
44
|
-
i += increment
|
|
45
|
-
increment *= 2 # The choice of two here is arbitrary.
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
line
|
|
49
|
-
end
|
|
50
|
-
else
|
|
51
|
-
# Earlier rubies do not support the two argument form of `caller`. This
|
|
52
|
-
# fallback is logically the same, but slower.
|
|
53
|
-
def self.first_non_rspec_line
|
|
54
|
-
caller.find { |line| line !~ LIB_REGEX }
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
end
|
|
60
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module RSpec
|
|
2
|
-
module Core
|
|
3
|
-
class DeprecatedMutableArrayProxy
|
|
4
|
-
|
|
5
|
-
def initialize(array)
|
|
6
|
-
@array = array
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
mutated_methods =
|
|
10
|
-
[
|
|
11
|
-
:<<, :[]=, :clear, :collect!, :compact!, :concat, :delete,
|
|
12
|
-
:delete_at, :delete_if, :fill, :flatten!, :keep_if, :map!,
|
|
13
|
-
:pop, :push, :reject!, :replace, :reverse!, :rotate!,
|
|
14
|
-
:select!, :shift, :shuffle!, :slice!, :sort!, :sort_by!,
|
|
15
|
-
:uniq!, :unshift
|
|
16
|
-
]
|
|
17
|
-
array_methods = Array.instance_methods.map(&:to_sym)
|
|
18
|
-
|
|
19
|
-
(array_methods & mutated_methods).each do |name|
|
|
20
|
-
define_method(name) do |*args, &block|
|
|
21
|
-
RSpec.deprecate "Mutating the `RSpec.configuration.formatters` array"
|
|
22
|
-
@array.__send__ name, *args, &block
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
(array_methods - mutated_methods).each do |name|
|
|
27
|
-
define_method(name) { |*args, &block| @array.__send__ name, *args, &block }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
module RSpec
|
|
2
|
-
module Core
|
|
3
|
-
module Deprecation
|
|
4
|
-
# @private
|
|
5
|
-
#
|
|
6
|
-
# Used internally to print deprecation warnings
|
|
7
|
-
def deprecate(deprecated, data = {})
|
|
8
|
-
RSpec.configuration.reporter.deprecation(
|
|
9
|
-
{
|
|
10
|
-
:deprecated => deprecated,
|
|
11
|
-
:call_site => CallerFilter.first_non_rspec_line
|
|
12
|
-
}.merge(data)
|
|
13
|
-
)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# @private
|
|
17
|
-
#
|
|
18
|
-
# Used internally to print deprecation warnings
|
|
19
|
-
def warn_deprecation(message)
|
|
20
|
-
RSpec.configuration.reporter.deprecation :message => message
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
extend(Core::Deprecation)
|
|
26
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
module RSpec
|
|
2
|
-
module Core
|
|
3
|
-
module Extensions
|
|
4
|
-
# @private
|
|
5
|
-
module InstanceEvalWithArgs
|
|
6
|
-
# @private
|
|
7
|
-
#
|
|
8
|
-
# Used internally to support `instance_exec` in Ruby 1.8.6.
|
|
9
|
-
#
|
|
10
|
-
# based on Bounded Spec InstanceExec (Mauricio Fernandez)
|
|
11
|
-
# http://eigenclass.org/hiki/bounded+space+instance_exec
|
|
12
|
-
# - uses singleton_class instead of global InstanceExecHelper module
|
|
13
|
-
# - this keeps it scoped to classes/modules that include this module
|
|
14
|
-
# - only necessary for ruby 1.8.6
|
|
15
|
-
def instance_eval_with_args(*args, &block)
|
|
16
|
-
return instance_exec(*args, &block) if respond_to?(:instance_exec)
|
|
17
|
-
|
|
18
|
-
# If there are no args and the block doesn't expect any, there's no
|
|
19
|
-
# need to fake instance_exec with our hack below.
|
|
20
|
-
# Notes:
|
|
21
|
-
# * lambda { }.arity # => -1
|
|
22
|
-
# * lambda { || }.arity # => 0
|
|
23
|
-
# * lambda { |*a| }.arity # -1
|
|
24
|
-
return instance_eval(&block) if block.arity < 1 && args.size.zero?
|
|
25
|
-
|
|
26
|
-
singleton_class = (class << self; self; end)
|
|
27
|
-
begin
|
|
28
|
-
orig_critical, Thread.critical = Thread.critical, true
|
|
29
|
-
n = 0
|
|
30
|
-
n += 1 while respond_to?(method_name="__instance_exec#{n}")
|
|
31
|
-
singleton_class.module_eval{ define_method(method_name, &block) }
|
|
32
|
-
ensure
|
|
33
|
-
Thread.critical = orig_critical
|
|
34
|
-
end
|
|
35
|
-
begin
|
|
36
|
-
return send(method_name, *args)
|
|
37
|
-
ensure
|
|
38
|
-
singleton_class.module_eval{ remove_method(method_name) } rescue nil
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
module Kernel
|
|
2
|
-
unless defined?(debugger)
|
|
3
|
-
# If not already defined by ruby-debug, this implementation prints helpful
|
|
4
|
-
# message to STDERR when ruby-debug is not loaded.
|
|
5
|
-
def debugger(*args)
|
|
6
|
-
(RSpec.configuration.error_stream || $stderr).puts "\n***** debugger statement ignored, use -d or --debug option to enable debugging\n#{caller(0)[1]}"
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module RSpec
|
|
2
|
-
module Core
|
|
3
|
-
module Extensions
|
|
4
|
-
# @private
|
|
5
|
-
module ModuleEvalWithArgs
|
|
6
|
-
include InstanceEvalWithArgs
|
|
7
|
-
|
|
8
|
-
# @private
|
|
9
|
-
#
|
|
10
|
-
# Used internally to support `module_exec` in Ruby 1.8.6.
|
|
11
|
-
def module_eval_with_args(*args, &block)
|
|
12
|
-
# ruby > 1.8.6
|
|
13
|
-
return module_exec(*args, &block) if respond_to?(:module_exec)
|
|
14
|
-
|
|
15
|
-
# If there are no args and the block doesn't expect any, there's no
|
|
16
|
-
# need to fake module_exec with our hack below.
|
|
17
|
-
# Notes:
|
|
18
|
-
# * lambda { }.arity # => -1
|
|
19
|
-
# * lambda { || }.arity # => 0
|
|
20
|
-
# * lambda { |*a| }.arity # => -1
|
|
21
|
-
return module_eval(&block) if block.arity < 1 && args.size.zero?
|
|
22
|
-
|
|
23
|
-
orig_singleton_methods = singleton_methods
|
|
24
|
-
instance_eval_with_args(*args, &block)
|
|
25
|
-
|
|
26
|
-
# The only difference between instance_eval and module_eval is static method defs.
|
|
27
|
-
# * `def foo` in instance_eval defines a singleton method on the instance
|
|
28
|
-
# * `def foo` in class/module_eval defines an instance method for the class/module
|
|
29
|
-
# Here we deal with this difference by defining an instance method for
|
|
30
|
-
# each new singleton method.
|
|
31
|
-
# This has the side effect of duplicating methods (all new class methods will
|
|
32
|
-
# become instance methods and vice versa), but I don't see a way around it...
|
|
33
|
-
(singleton_methods - orig_singleton_methods).each { |m| define_method(m, &method(m)) }
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
module RSpec
|
|
2
|
-
module Core
|
|
3
|
-
# @private
|
|
4
|
-
module Extensions
|
|
5
|
-
# @private
|
|
6
|
-
# Used to extend lists of examples and groups to support ordering
|
|
7
|
-
# strategies like randomization.
|
|
8
|
-
module Ordered
|
|
9
|
-
# @private
|
|
10
|
-
module ExampleGroups
|
|
11
|
-
# @private
|
|
12
|
-
def ordered
|
|
13
|
-
RSpec.configuration.group_ordering_block.call(self)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# @private
|
|
18
|
-
module Examples
|
|
19
|
-
# @private
|
|
20
|
-
def ordered
|
|
21
|
-
RSpec.configuration.example_ordering_block.call(self)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
module RSpec
|
|
2
|
-
module Core
|
|
3
|
-
module Formatters
|
|
4
|
-
module ConsoleCodes
|
|
5
|
-
VT100_CODES =
|
|
6
|
-
{
|
|
7
|
-
:black => 30,
|
|
8
|
-
:red => 31,
|
|
9
|
-
:green => 32,
|
|
10
|
-
:yellow => 33,
|
|
11
|
-
:blue => 34,
|
|
12
|
-
:magenta => 35,
|
|
13
|
-
:cyan => 36,
|
|
14
|
-
:white => 37,
|
|
15
|
-
:bold => 1,
|
|
16
|
-
}
|
|
17
|
-
VT100_CODE_VALUES = VT100_CODES.invert
|
|
18
|
-
|
|
19
|
-
module_function
|
|
20
|
-
|
|
21
|
-
def console_code_for(code_or_symbol)
|
|
22
|
-
if VT100_CODE_VALUES.has_key?(code_or_symbol)
|
|
23
|
-
code_or_symbol
|
|
24
|
-
else
|
|
25
|
-
VT100_CODES.fetch(code_or_symbol) do
|
|
26
|
-
console_code_for(:white)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def wrap(text, code_or_symbol)
|
|
32
|
-
if RSpec.configuration.color_enabled?
|
|
33
|
-
"\e[#{console_code_for(code_or_symbol)}m#{text}\e[0m"
|
|
34
|
-
else
|
|
35
|
-
text
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require 'cgi'
|
|
2
|
-
require 'rspec/core/formatters/html_formatter'
|
|
3
|
-
|
|
4
|
-
module RSpec
|
|
5
|
-
module Core
|
|
6
|
-
module Formatters
|
|
7
|
-
# Formats backtraces so they're clickable by TextMate
|
|
8
|
-
class TextMateFormatter < HtmlFormatter
|
|
9
|
-
def backtrace_line(line, skip_textmate_conversion=false)
|
|
10
|
-
if skip_textmate_conversion
|
|
11
|
-
super(line)
|
|
12
|
-
else
|
|
13
|
-
format_backtrace_line_for_textmate(super(line))
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def format_backtrace_line_for_textmate(line)
|
|
18
|
-
return nil unless line
|
|
19
|
-
CGI.escapeHTML(line).sub(/([^:]*\.e?rb):(\d*)/) do
|
|
20
|
-
"<a href=\"txmt://open?url=file://#{File.expand_path($1)}&line=#{$2}\">#{$1}:#{$2}</a> "
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def extra_failure_content(exception)
|
|
25
|
-
require 'rspec/core/formatters/snippet_extractor'
|
|
26
|
-
backtrace = exception.backtrace.map {|line| backtrace_line(line, :skip_textmate_conversion)}
|
|
27
|
-
backtrace.compact!
|
|
28
|
-
@snippet_extractor ||= SnippetExtractor.new
|
|
29
|
-
" <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(backtrace)}</code></pre>"
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
module RSpec
|
|
2
|
-
module Core
|
|
3
|
-
# @private
|
|
4
|
-
module MetadataHashBuilder
|
|
5
|
-
# @private
|
|
6
|
-
module Common
|
|
7
|
-
def build_metadata_hash_from(args)
|
|
8
|
-
metadata = args.last.is_a?(Hash) ? args.pop : {}
|
|
9
|
-
|
|
10
|
-
if RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values?
|
|
11
|
-
add_symbols_to_hash(metadata, args)
|
|
12
|
-
else
|
|
13
|
-
warn_about_symbol_usage(args)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
metadata
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def add_symbols_to_hash(hash, args)
|
|
22
|
-
while args.last.is_a?(Symbol)
|
|
23
|
-
hash[args.pop] = true
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def warn_about_symbol_usage(args)
|
|
28
|
-
symbols = args.select { |a| a.is_a?(Symbol) }
|
|
29
|
-
return if symbols.empty?
|
|
30
|
-
Kernel.warn symbol_metadata_warning(symbols)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# @private
|
|
35
|
-
module WithConfigWarning
|
|
36
|
-
include Common
|
|
37
|
-
|
|
38
|
-
private
|
|
39
|
-
|
|
40
|
-
def symbol_metadata_warning(symbols)
|
|
41
|
-
<<-NOTICE
|
|
42
|
-
|
|
43
|
-
*****************************************************************
|
|
44
|
-
WARNING: You have passed symbols (#{symbols.inspect}) as metadata
|
|
45
|
-
arguments to a configuration option.
|
|
46
|
-
|
|
47
|
-
In RSpec 3, these symbols will be treated as metadata keys with
|
|
48
|
-
a value of `true`. To get this behavior now (and prevent this
|
|
49
|
-
warning), you can set a configuration option:
|
|
50
|
-
|
|
51
|
-
RSpec.configure do |c|
|
|
52
|
-
c.treat_symbols_as_metadata_keys_with_true_values = true
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
Note that this config setting should go before your other config
|
|
56
|
-
settings so that they can use symbols as metadata.
|
|
57
|
-
*****************************************************************
|
|
58
|
-
|
|
59
|
-
NOTICE
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# @private
|
|
64
|
-
module WithDeprecationWarning
|
|
65
|
-
include Common
|
|
66
|
-
|
|
67
|
-
private
|
|
68
|
-
|
|
69
|
-
def symbol_metadata_warning(symbols)
|
|
70
|
-
<<-NOTICE
|
|
71
|
-
|
|
72
|
-
*****************************************************************
|
|
73
|
-
DEPRECATION WARNING: you are using deprecated behaviour that will
|
|
74
|
-
be removed from RSpec 3.
|
|
75
|
-
|
|
76
|
-
You have passed symbols (#{symbols.inspect}) as additional
|
|
77
|
-
arguments for a doc string.
|
|
78
|
-
|
|
79
|
-
In RSpec 3, these symbols will be treated as metadata keys with
|
|
80
|
-
a value of `true`. To get this behavior now (and prevent this
|
|
81
|
-
warning), you can set a configuration option:
|
|
82
|
-
|
|
83
|
-
RSpec.configure do |c|
|
|
84
|
-
c.treat_symbols_as_metadata_keys_with_true_values = true
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
Alternately, if your intention is to use the symbol as part of the
|
|
88
|
-
doc string (i.e. to specify a method name), you can change it to
|
|
89
|
-
a string such as "#method_name" to remove this warning.
|
|
90
|
-
*****************************************************************
|
|
91
|
-
|
|
92
|
-
NOTICE
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
# Only the minitest 5.x gem includes the minitest.rb and assertions.rb files
|
|
3
|
-
require 'minitest'
|
|
4
|
-
require 'minitest/assertions'
|
|
5
|
-
rescue LoadError => _ignored
|
|
6
|
-
# We must be using Ruby Core's MiniTest or the Minitest gem 4.x
|
|
7
|
-
require 'minitest/unit'
|
|
8
|
-
Minitest = MiniTest
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
module RSpec
|
|
12
|
-
module Core
|
|
13
|
-
# @private
|
|
14
|
-
module MinitestAssertionsAdapter
|
|
15
|
-
include ::Minitest::Assertions
|
|
16
|
-
|
|
17
|
-
# Minitest 5.x requires this accessor to be available. See
|
|
18
|
-
# https://github.com/seattlerb/minitest/blob/38f0a5fcbd9c37c3f80a3eaad4ba84d3fc9947a0/lib/minitest/assertions.rb#L8
|
|
19
|
-
#
|
|
20
|
-
# It is not required for other extension libraries, and RSpec does not
|
|
21
|
-
# report or make this information available to formatters.
|
|
22
|
-
attr_writer :assertions
|
|
23
|
-
def assertions
|
|
24
|
-
@assertions ||= 0
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|