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
|
@@ -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,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
#
|
|
3
|
-
# Created by Jim Weirich on 2007-04-10.
|
|
4
|
-
# Copyright (c) 2007. All rights reserved.
|
|
5
|
-
|
|
6
|
-
require 'flexmock/rspec'
|
|
7
|
-
|
|
8
|
-
module RSpec
|
|
9
|
-
module Core
|
|
10
|
-
module MockFrameworkAdapter
|
|
11
|
-
|
|
12
|
-
def self.framework_name; :flexmock end
|
|
13
|
-
|
|
14
|
-
include FlexMock::MockContainer
|
|
15
|
-
def setup_mocks_for_rspec
|
|
16
|
-
# No setup required
|
|
17
|
-
end
|
|
18
|
-
def verify_mocks_for_rspec
|
|
19
|
-
flexmock_verify
|
|
20
|
-
end
|
|
21
|
-
def teardown_mocks_for_rspec
|
|
22
|
-
flexmock_close
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'rr'
|
|
2
|
-
|
|
3
|
-
RSpec.configuration.backtrace_exclusion_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
|
|
4
|
-
|
|
5
|
-
module RSpec
|
|
6
|
-
module Core
|
|
7
|
-
module MockFrameworkAdapter
|
|
8
|
-
|
|
9
|
-
def self.framework_name; :rr end
|
|
10
|
-
|
|
11
|
-
include RR::Extensions::InstanceMethods
|
|
12
|
-
|
|
13
|
-
def setup_mocks_for_rspec
|
|
14
|
-
RR::Space.instance.reset
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def verify_mocks_for_rspec
|
|
18
|
-
RR::Space.instance.verify_doubles
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def teardown_mocks_for_rspec
|
|
22
|
-
RR::Space.instance.reset
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'rspec/mocks'
|
|
2
|
-
|
|
3
|
-
module RSpec
|
|
4
|
-
module Core
|
|
5
|
-
module MockFrameworkAdapter
|
|
6
|
-
|
|
7
|
-
def self.framework_name; :rspec end
|
|
8
|
-
|
|
9
|
-
def self.configuration
|
|
10
|
-
RSpec::Mocks.configuration
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def setup_mocks_for_rspec
|
|
14
|
-
RSpec::Mocks::setup(self)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def verify_mocks_for_rspec
|
|
18
|
-
RSpec::Mocks::verify
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def teardown_mocks_for_rspec
|
|
22
|
-
RSpec::Mocks::teardown
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
module RSpec
|
|
2
|
-
module Core
|
|
3
|
-
module SharedExampleGroup
|
|
4
|
-
class Collection
|
|
5
|
-
|
|
6
|
-
def initialize(sources, examples)
|
|
7
|
-
@sources, @examples = sources, examples
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def [](key)
|
|
11
|
-
fetch_examples(key) || warn_deprecation_and_fetch_anyway(key)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
def fetch_examples(key)
|
|
17
|
-
@examples[source_for key][key]
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def source_for(key)
|
|
21
|
-
@sources.reverse.find { |source| @examples[source].has_key? key }
|
|
22
|
-
end
|
|
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
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe "autotest/discover.rb" do
|
|
4
|
-
before { File.stub(:exist?).and_call_original }
|
|
5
|
-
|
|
6
|
-
context "with ./.rspec present" do
|
|
7
|
-
before { File.stub(:exist?).with("./.rspec") { true } }
|
|
8
|
-
|
|
9
|
-
context "when RSpec::Autotest is defined" do
|
|
10
|
-
before { stub_const "RSpec::Autotest", Module.new }
|
|
11
|
-
|
|
12
|
-
it "does not add 'rspec2' to the list of discoveries" do
|
|
13
|
-
Autotest.should_not_receive(:add_discovery)
|
|
14
|
-
load File.expand_path("../../../lib/autotest/discover.rb", __FILE__)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when RSpec::Autotest is not defined" do
|
|
19
|
-
before { hide_const "RSpec::Autotest" }
|
|
20
|
-
|
|
21
|
-
it "adds 'rspec2' to the list of discoveries" do
|
|
22
|
-
Autotest.should_receive(:add_discovery)
|
|
23
|
-
load File.expand_path("../../../lib/autotest/discover.rb", __FILE__)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
context "with ./.rspec absent" do
|
|
29
|
-
before { File.stub(:exist?).with("./.rspec") { false } }
|
|
30
|
-
|
|
31
|
-
context "when RSpec::Autotest is defined" do
|
|
32
|
-
before { stub_const "RSpec::Autotest", Module.new }
|
|
33
|
-
|
|
34
|
-
it "does not add 'rspec2' to the list of discoveries" do
|
|
35
|
-
Autotest.should_not_receive(:add_discovery)
|
|
36
|
-
load File.expand_path("../../../lib/autotest/discover.rb", __FILE__)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
context "when RSpec::Autotest is not defined" do
|
|
41
|
-
before { hide_const "RSpec::Autotest" }
|
|
42
|
-
|
|
43
|
-
it "does not add 'rspec2' to the list of discoveries" do
|
|
44
|
-
Autotest.should_not_receive(:add_discovery)
|
|
45
|
-
load File.expand_path("../../../lib/autotest/discover.rb", __FILE__)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe "failed_results_re for autotest" do
|
|
4
|
-
def run_example
|
|
5
|
-
group = RSpec::Core::ExampleGroup.describe("group")
|
|
6
|
-
group.example("example") { yield }
|
|
7
|
-
io = StringIO.new
|
|
8
|
-
formatter = RSpec::Core::Formatters::BaseTextFormatter.new(io)
|
|
9
|
-
reporter = RSpec::Core::Reporter.new(formatter)
|
|
10
|
-
|
|
11
|
-
group.run(reporter)
|
|
12
|
-
reporter.report(1, nil) {}
|
|
13
|
-
io.string
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
shared_examples "autotest failed_results_re" do
|
|
17
|
-
it "matches a failure" do
|
|
18
|
-
output = run_example { fail }
|
|
19
|
-
expect(output).to match(Autotest::Rspec2.new.failed_results_re)
|
|
20
|
-
expect(output).to include(__FILE__.sub(File.expand_path('.'),'.'))
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "does not match when there are no failures" do
|
|
24
|
-
output = run_example { } # pass
|
|
25
|
-
expect(output).not_to match(Autotest::Rspec2.new.failed_results_re)
|
|
26
|
-
expect(output).not_to include(__FILE__.sub(File.expand_path('.'),'.'))
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "with color enabled" do
|
|
31
|
-
before do
|
|
32
|
-
RSpec.configuration.stub(:color_enabled? => true)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
include_examples "autotest failed_results_re"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context "with color disabled " do
|
|
39
|
-
before do
|
|
40
|
-
RSpec.configuration.stub(:color_enabled? => false)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
include_examples "autotest failed_results_re"
|
|
44
|
-
end
|
|
45
|
-
end
|
data/spec/autotest/rspec_spec.rb
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Autotest::Rspec2 do
|
|
4
|
-
let(:rspec_autotest) { Autotest::Rspec2.new }
|
|
5
|
-
let(:spec_cmd) { File.expand_path("../../../exe/rspec", __FILE__) }
|
|
6
|
-
let(:ruby_cmd) { "/path/to/ruby" }
|
|
7
|
-
|
|
8
|
-
before do
|
|
9
|
-
File.stub(:exist?) { false }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "uses autotest's prefix" do
|
|
13
|
-
rspec_autotest.prefix = "this is the prefix "
|
|
14
|
-
expect(rspec_autotest.make_test_cmd({'a' => 'b'})).to match(/this is the prefix/)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
describe "commands" do
|
|
18
|
-
before do
|
|
19
|
-
rspec_autotest.stub(:ruby => ruby_cmd)
|
|
20
|
-
files = %w[file_one file_two]
|
|
21
|
-
@files_to_test = {
|
|
22
|
-
files[0] => [],
|
|
23
|
-
files[1] => []
|
|
24
|
-
}
|
|
25
|
-
# this is not the inner representation of Autotest!
|
|
26
|
-
rspec_autotest.files_to_test = @files_to_test
|
|
27
|
-
@to_test = files.map { |f| File.expand_path(f) }.join ' '
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "uses double quotes for windows compatibility" do
|
|
31
|
-
command = rspec_autotest.make_test_cmd(@files_to_test)
|
|
32
|
-
expect(command).to include('"')
|
|
33
|
-
expect(command).not_to include("'")
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "makes the appropriate test command" do
|
|
37
|
-
actual_command = rspec_autotest.make_test_cmd(@files_to_test)
|
|
38
|
-
expected_command = /#{ruby_cmd}.*"#{spec_cmd}" (.*)/
|
|
39
|
-
|
|
40
|
-
expect(actual_command).to match(expected_command)
|
|
41
|
-
|
|
42
|
-
actual_command =~ expected_command
|
|
43
|
-
expect($1).to match(/#{File.expand_path('file_one')}/)
|
|
44
|
-
expect($1).to match(/#{File.expand_path('file_two')}/)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "returns a blank command for no files" do
|
|
48
|
-
expect(rspec_autotest.make_test_cmd({})).to eq('')
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "quotes the paths of files to test" do
|
|
52
|
-
cmd = rspec_autotest.make_test_cmd(@files_to_test)
|
|
53
|
-
@files_to_test.keys.each do |file_to_test|
|
|
54
|
-
expect(cmd).to match(/"#{File.expand_path(file_to_test)}"/)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "quotes the path of the ruby executable" do
|
|
59
|
-
cmd = rspec_autotest.make_test_cmd(@files_to_test)
|
|
60
|
-
expect(cmd).to match(%r("/path/to/ruby"))
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "gives '--tty' to #{Autotest::Rspec2::RSPEC_EXECUTABLE}, not '--autotest'" do
|
|
64
|
-
cmd = rspec_autotest.make_test_cmd(@files_to_test)
|
|
65
|
-
expect(cmd).to match(' --tty ')
|
|
66
|
-
expect(cmd).not_to match(' --autotest ')
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
describe "mappings" do
|
|
71
|
-
before do
|
|
72
|
-
@lib_file = "lib/something.rb"
|
|
73
|
-
@spec_file = "spec/something_spec.rb"
|
|
74
|
-
rspec_autotest.hook :initialize
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "finds the spec file for a given lib file" do
|
|
78
|
-
expect(rspec_autotest).to map_specs([@spec_file]).to(@lib_file)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "finds the spec file if given a spec file" do
|
|
82
|
-
expect(rspec_autotest).to map_specs([@spec_file]).to(@spec_file)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it "ignores files in spec dir that aren't specs" do
|
|
86
|
-
expect(rspec_autotest).to map_specs([]).to("spec/spec_helper.rb")
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "ignores untracked files (in @file)" do
|
|
90
|
-
expect(rspec_autotest).to map_specs([]).to("lib/untracked_file")
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
describe "consolidating failures" do
|
|
95
|
-
let(:subject_file) { "lib/autotest/some.rb" }
|
|
96
|
-
let(:spec_file) { "spec/autotest/some_spec.rb" }
|
|
97
|
-
|
|
98
|
-
it "returns no failures if no failures were given in the output" do
|
|
99
|
-
expect(rspec_autotest.consolidate_failures([[]])).to eq({})
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
it "returns a hash with the spec filename => spec name for each failure or error" do
|
|
103
|
-
failures = [ [ "false should be false", spec_file ] ]
|
|
104
|
-
expect(rspec_autotest.consolidate_failures(failures)).to eq({
|
|
105
|
-
spec_file => ["false should be false"]
|
|
106
|
-
})
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
context "when subject file appears before the spec file in the backtrace" do
|
|
110
|
-
let(:failures) do
|
|
111
|
-
[ [ "false should be false", "#{subject_file}:143:\n#{spec_file}:203:" ] ]
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
it "excludes the subject file" do
|
|
115
|
-
expect(rspec_autotest.consolidate_failures(failures).keys).not_to include(subject_file)
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
it "includes the spec file" do
|
|
119
|
-
expect(rspec_autotest.consolidate_failures(failures).keys).to include(spec_file)
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
describe "normalizing file names" do
|
|
125
|
-
it "ensures that a single file appears in files_to_test only once" do
|
|
126
|
-
@files_to_test = {}
|
|
127
|
-
['filename.rb', './filename.rb', File.expand_path('filename.rb')].each do |file|
|
|
128
|
-
@files_to_test[file] = []
|
|
129
|
-
end
|
|
130
|
-
expect(rspec_autotest.normalize(@files_to_test)).to have(1).file
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
end
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe 'command line', :ui do
|
|
4
|
-
let(:stderr) { StringIO.new }
|
|
5
|
-
let(:stdout) { StringIO.new }
|
|
6
|
-
|
|
7
|
-
before :all do
|
|
8
|
-
write_file 'spec/simple_spec.rb', """
|
|
9
|
-
describe 'group 1' do
|
|
10
|
-
specify('group 1 example 1') {}
|
|
11
|
-
specify('group 1 example 2') {}
|
|
12
|
-
specify('group 1 example 3') {}
|
|
13
|
-
describe 'group 1-1' do
|
|
14
|
-
specify('group 1-1 example 1') {}
|
|
15
|
-
specify('group 1-1 example 2') {}
|
|
16
|
-
specify('group 1-1 example 3') {}
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
write_file 'spec/simple_spec2.rb', """
|
|
22
|
-
describe 'group 2' do
|
|
23
|
-
specify('group 2 example 1') {}
|
|
24
|
-
specify('group 2 example 2') {}
|
|
25
|
-
specify('group 2 example 3') {}
|
|
26
|
-
describe 'group 2-1' do
|
|
27
|
-
specify('group 2-1 example 1') {}
|
|
28
|
-
specify('group 2-1 example 2') {}
|
|
29
|
-
specify('group 2-1 example 3') {}
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
write_file 'spec/order_spec.rb', """
|
|
35
|
-
describe 'group 1' do
|
|
36
|
-
specify('group 1 example 1') {}
|
|
37
|
-
specify('group 1 example 2') {}
|
|
38
|
-
specify('group 1 example 3') {}
|
|
39
|
-
specify('group 1 example 4') {}
|
|
40
|
-
specify('group 1 example 5') {}
|
|
41
|
-
specify('group 1 example 6') {}
|
|
42
|
-
specify('group 1 example 5') {}
|
|
43
|
-
specify('group 1 example 7') {}
|
|
44
|
-
specify('group 1 example 8') {}
|
|
45
|
-
specify('group 1 example 9') {}
|
|
46
|
-
specify('group 1 example 10') {}
|
|
47
|
-
|
|
48
|
-
describe 'group 1-1' do
|
|
49
|
-
specify('group 1-1 example 1') {}
|
|
50
|
-
specify('group 1-1 example 2') {}
|
|
51
|
-
specify('group 1-1 example 3') {}
|
|
52
|
-
specify('group 1-1 example 4') {}
|
|
53
|
-
specify('group 1-1 example 5') {}
|
|
54
|
-
specify('group 1-1 example 6') {}
|
|
55
|
-
specify('group 1-1 example 7') {}
|
|
56
|
-
specify('group 1-1 example 8') {}
|
|
57
|
-
specify('group 1-1 example 9') {}
|
|
58
|
-
specify('group 1-1 example 10') {}
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe('group 1-2') { specify('example') {} }
|
|
62
|
-
describe('group 1-3') { specify('example') {} }
|
|
63
|
-
describe('group 1-4') { specify('example') {} }
|
|
64
|
-
describe('group 1-5') { specify('example') {} }
|
|
65
|
-
describe('group 1-6') { specify('example') {} }
|
|
66
|
-
describe('group 1-7') { specify('example') {} }
|
|
67
|
-
describe('group 1-8') { specify('example') {} }
|
|
68
|
-
describe('group 1-9') { specify('example') {} }
|
|
69
|
-
describe('group 1-10') { specify('example') {} }
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
describe('group 2') { specify('example') {} }
|
|
73
|
-
describe('group 3') { specify('example') {} }
|
|
74
|
-
describe('group 4') { specify('example') {} }
|
|
75
|
-
describe('group 5') { specify('example') {} }
|
|
76
|
-
describe('group 6') { specify('example') {} }
|
|
77
|
-
describe('group 7') { specify('example') {} }
|
|
78
|
-
describe('group 8') { specify('example') {} }
|
|
79
|
-
describe('group 9') { specify('example') {} }
|
|
80
|
-
describe('group 10') { specify('example') {} }
|
|
81
|
-
"""
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
describe '--order rand' do
|
|
85
|
-
it 'runs the examples and groups in a different order each time' do
|
|
86
|
-
run_command 'tmp/aruba/spec/order_spec.rb --order rand -f doc'
|
|
87
|
-
RSpec.configuration.seed = srand && srand # reset seed in same process
|
|
88
|
-
run_command 'tmp/aruba/spec/order_spec.rb --order rand -f doc'
|
|
89
|
-
|
|
90
|
-
expect(stdout.string).to match(/Randomized with seed \d+/)
|
|
91
|
-
|
|
92
|
-
top_level_groups {|first_run, second_run| expect(first_run).to_not eq(second_run)}
|
|
93
|
-
nested_groups {|first_run, second_run| expect(first_run).to_not eq(second_run)}
|
|
94
|
-
examples('group 1') {|first_run, second_run| expect(first_run).to_not eq(second_run)}
|
|
95
|
-
examples('group 1-1') {|first_run, second_run| expect(first_run).to_not eq(second_run)}
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
describe '--order rand:SEED' do
|
|
100
|
-
it 'runs the examples and groups in the same order each time' do
|
|
101
|
-
2.times { run_command 'tmp/aruba/spec/order_spec.rb --order rand:123 -f doc' }
|
|
102
|
-
|
|
103
|
-
expect(stdout.string).to match(/Randomized with seed 123/)
|
|
104
|
-
|
|
105
|
-
top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
106
|
-
nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
107
|
-
examples('group 1') {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
108
|
-
examples('group 1-1') {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
describe '--seed SEED' do
|
|
113
|
-
it "forces '--order rand' and runs the examples and groups in the same order each time" do
|
|
114
|
-
2.times { run_command 'tmp/aruba/spec/order_spec.rb --seed 123 -f doc' }
|
|
115
|
-
|
|
116
|
-
expect(stdout.string).to match(/Randomized with seed \d+/)
|
|
117
|
-
|
|
118
|
-
top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
119
|
-
nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
120
|
-
examples('group 1') {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
121
|
-
examples('group 1-1') {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
it "runs examples in the same order, regardless of the order in which files are given" do
|
|
125
|
-
run_command 'tmp/aruba/spec/simple_spec.rb tmp/aruba/spec/simple_spec2.rb --seed 1337 -f doc'
|
|
126
|
-
run_command 'tmp/aruba/spec/simple_spec2.rb tmp/aruba/spec/simple_spec.rb --seed 1337 -f doc'
|
|
127
|
-
|
|
128
|
-
top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
129
|
-
nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
describe '--order defined on CLI with --order rand in .rspec' do
|
|
134
|
-
it "overrides --order rand with --order defined" do
|
|
135
|
-
write_file '.rspec', '--order rand'
|
|
136
|
-
|
|
137
|
-
run_command 'tmp/aruba/spec/order_spec.rb --order defined -f doc'
|
|
138
|
-
|
|
139
|
-
expect(stdout.string).not_to match(/Randomized/)
|
|
140
|
-
|
|
141
|
-
expect(stdout.string).to match(
|
|
142
|
-
/group 1.*group 1 example 1.*group 1 example 2.*group 1-1.*group 1-2.*group 2.*/m
|
|
143
|
-
)
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
context 'when a custom order is configured' do
|
|
148
|
-
before do
|
|
149
|
-
write_file 'spec/custom_order_spec.rb', """
|
|
150
|
-
RSpec.configure do |config|
|
|
151
|
-
config.register_ordering(:global) do |list|
|
|
152
|
-
list.sort_by { |item| item.description }
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
describe 'group B' do
|
|
157
|
-
specify('group B example D') {}
|
|
158
|
-
specify('group B example B') {}
|
|
159
|
-
specify('group B example A') {}
|
|
160
|
-
specify('group B example C') {}
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
describe 'group A' do
|
|
164
|
-
specify('group A example 1') {}
|
|
165
|
-
end
|
|
166
|
-
"""
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
it 'orders the groups and examples by the provided strategy' do
|
|
170
|
-
run_command 'tmp/aruba/spec/custom_order_spec.rb -f doc'
|
|
171
|
-
|
|
172
|
-
top_level_groups { |groups| expect(groups.flatten).to eq(['group A', 'group B']) }
|
|
173
|
-
examples('group B') do |examples|
|
|
174
|
-
letters = examples.flatten.map { |e| e[/(.)\z/, 1] }
|
|
175
|
-
expect(letters).to eq(['A', 'B', 'C', 'D'])
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
def examples(group)
|
|
181
|
-
yield split_in_half(stdout.string.scan(/^\s+#{group} example.*$/))
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
def top_level_groups
|
|
185
|
-
yield example_groups_at_level(0)
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
def nested_groups
|
|
189
|
-
yield example_groups_at_level(2)
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
def example_groups_at_level(level)
|
|
193
|
-
split_in_half(stdout.string.scan(/^\s{#{level*2}}group.*$/))
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def split_in_half(array)
|
|
197
|
-
length, midpoint = array.length, array.length / 2
|
|
198
|
-
return array.slice(0, midpoint), array.slice(midpoint, length)
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
def run_command(cmd)
|
|
202
|
-
RSpec::Core::Runner.run(cmd.split, stderr, stdout)
|
|
203
|
-
end
|
|
204
|
-
end
|