rspec-core 3.0.0.beta2 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +297 -57
- data/README.md +16 -13
- data/lib/rspec/core.rb +55 -84
- data/lib/rspec/core/backport_random.rb +35 -3
- data/lib/rspec/core/backtrace_formatter.rb +4 -13
- data/lib/rspec/core/configuration.rb +330 -114
- data/lib/rspec/core/configuration_options.rb +38 -22
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +8 -2
- data/lib/rspec/core/example.rb +203 -94
- data/lib/rspec/core/example_group.rb +344 -316
- data/lib/rspec/core/filter_manager.rb +135 -90
- data/lib/rspec/core/flat_map.rb +1 -0
- data/lib/rspec/core/formatters.rb +50 -14
- data/lib/rspec/core/formatters/base_formatter.rb +32 -138
- data/lib/rspec/core/formatters/base_text_formatter.rb +32 -253
- data/lib/rspec/core/formatters/console_codes.rb +65 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +24 -15
- data/lib/rspec/core/formatters/documentation_formatter.rb +7 -10
- data/lib/rspec/core/formatters/helpers.rb +15 -9
- data/lib/rspec/core/formatters/html_formatter.rb +17 -16
- data/lib/rspec/core/formatters/html_printer.rb +1 -0
- data/lib/rspec/core/formatters/json_formatter.rb +18 -20
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +6 -7
- data/lib/rspec/core/formatters/snippet_extractor.rb +8 -6
- data/lib/rspec/core/hooks.rb +131 -125
- data/lib/rspec/core/memoized_helpers.rb +31 -26
- data/lib/rspec/core/metadata.rb +277 -184
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
- data/lib/rspec/core/mocking_adapters/mocha.rb +1 -1
- data/lib/rspec/core/mocking_adapters/null.rb +1 -1
- data/lib/rspec/core/mocking_adapters/rr.rb +2 -1
- data/lib/rspec/core/mocking_adapters/rspec.rb +1 -1
- data/lib/rspec/core/notifications.rb +435 -24
- data/lib/rspec/core/option_parser.rb +16 -25
- data/lib/rspec/core/ordering.rb +3 -1
- data/lib/rspec/core/pending.rb +57 -33
- data/lib/rspec/core/project_initializer.rb +2 -0
- data/lib/rspec/core/project_initializer/spec_helper.rb +5 -4
- data/lib/rspec/core/rake_task.rb +45 -20
- data/lib/rspec/core/reporter.rb +50 -22
- data/lib/rspec/core/ruby_project.rb +1 -0
- data/lib/rspec/core/runner.rb +93 -39
- data/lib/rspec/core/shared_context.rb +7 -5
- data/lib/rspec/core/shared_example_group.rb +85 -77
- data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +35 -17
- data/lib/rspec/core/world.rb +57 -5
- metadata +56 -369
- metadata.gz.sig +3 -3
- data/features/README.md +0 -13
- data/features/Upgrade.md +0 -352
- data/features/command_line/README.md +0 -25
- data/features/command_line/dry_run.feature +0 -29
- data/features/command_line/example_name_option.feature +0 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/fail_fast.feature +0 -26
- data/features/command_line/format_option.feature +0 -75
- data/features/command_line/init.feature +0 -57
- data/features/command_line/line_number_appended_to_path.feature +0 -140
- data/features/command_line/line_number_option.feature +0 -58
- data/features/command_line/order.feature +0 -25
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/randomization.feature +0 -63
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -23
- data/features/command_line/tag.feature +0 -98
- data/features/command_line/warnings_option.feature +0 -29
- data/features/configuration/alias_example_to.feature +0 -39
- data/features/configuration/backtrace_exclusion_patterns.feature +0 -105
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/deprecation_stream.feature +0 -58
- data/features/configuration/enable_global_dsl.feature +0 -54
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/failure_exit_code.feature +0 -36
- data/features/configuration/order_and_seed.feature +0 -3
- data/features/configuration/output_stream.feature +0 -24
- data/features/configuration/overriding_global_ordering.feature +0 -93
- data/features/configuration/pattern.feature +0 -38
- data/features/configuration/profile.feature +0 -220
- data/features/configuration/read_options_from_file.feature +0 -90
- data/features/configuration/run_all_when_everything_filtered.feature +0 -76
- data/features/example_groups/aliasing.feature +0 -48
- data/features/example_groups/basic_structure.feature +0 -55
- data/features/example_groups/shared_context.feature +0 -74
- data/features/example_groups/shared_examples.feature +0 -286
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
- data/features/filtering/exclusion_filters.feature +0 -135
- data/features/filtering/if_and_unless.feature +0 -138
- data/features/filtering/inclusion_filters.feature +0 -101
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -68
- data/features/formatters/json_formatter.feature +0 -30
- data/features/formatters/regression_tests.feature +0 -95
- data/features/formatters/text_formatter.feature +0 -46
- data/features/helper_methods/arbitrary_methods.feature +0 -40
- data/features/helper_methods/let.feature +0 -50
- data/features/helper_methods/modules.feature +0 -146
- data/features/hooks/around_hooks.feature +0 -344
- data/features/hooks/before_and_after_hooks.feature +0 -427
- data/features/hooks/filtering.feature +0 -232
- data/features/metadata/current_example.feature +0 -56
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -100
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -94
- data/features/mock_framework_integration/use_mocha.feature +0 -95
- data/features/mock_framework_integration/use_rr.feature +0 -96
- data/features/mock_framework_integration/use_rspec.feature +0 -95
- data/features/pending_and_skipped_examples/README.md +0 -3
- data/features/pending_and_skipped_examples/pending_examples.feature +0 -118
- data/features/pending_and_skipped_examples/skipped_examples.feature +0 -106
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -83
- data/features/subject/explicit_subject.feature +0 -101
- data/features/subject/implicit_subject.feature +0 -63
- data/features/subject/one_liner_syntax.feature +0 -71
- data/features/support/env.rb +0 -21
- data/features/support/require_expect_syntax_in_aruba_specs.rb +0 -16
- data/features/support/rubinius.rb +0 -6
- data/lib/rspec/core/command_line.rb +0 -35
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/formatters/legacy_formatter.rb +0 -227
- data/lib/rspec/core/shared_example_group/collection.rb +0 -27
- data/spec/command_line/order_spec.rb +0 -211
- data/spec/rspec/core/backtrace_formatter_spec.rb +0 -230
- data/spec/rspec/core/command_line_spec.rb +0 -112
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -409
- data/spec/rspec/core/configuration_spec.rb +0 -1479
- data/spec/rspec/core/drb_command_line_spec.rb +0 -102
- data/spec/rspec/core/drb_options_spec.rb +0 -193
- data/spec/rspec/core/dsl_spec.rb +0 -88
- data/spec/rspec/core/example_group_spec.rb +0 -1533
- data/spec/rspec/core/example_spec.rb +0 -642
- data/spec/rspec/core/filter_manager_spec.rb +0 -229
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -64
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -303
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -208
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -75
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted-2.1.0.html +0 -392
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -122
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -206
- data/spec/rspec/core/formatters/legacy_formatter_spec.rb +0 -137
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -43
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters_spec.rb +0 -120
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -294
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -495
- data/spec/rspec/core/metadata_spec.rb +0 -491
- data/spec/rspec/core/option_parser_spec.rb +0 -262
- data/spec/rspec/core/ordering_spec.rb +0 -102
- data/spec/rspec/core/pending_example_spec.rb +0 -117
- data/spec/rspec/core/pending_spec.rb +0 -8
- data/spec/rspec/core/project_initializer_spec.rb +0 -73
- data/spec/rspec/core/rake_task_spec.rb +0 -146
- data/spec/rspec/core/random_spec.rb +0 -47
- data/spec/rspec/core/reporter_spec.rb +0 -155
- data/spec/rspec/core/resources/a_bar.rb +0 -0
- data/spec/rspec/core/resources/a_foo.rb +0 -0
- data/spec/rspec/core/resources/a_spec.rb +0 -1
- data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
- data/spec/rspec/core/resources/formatter_specs.rb +0 -58
- data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
- data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
- data/spec/rspec/core/ruby_project_spec.rb +0 -26
- data/spec/rspec/core/runner_spec.rb +0 -151
- data/spec/rspec/core/shared_context_spec.rb +0 -102
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -57
- data/spec/rspec/core/shared_example_group_spec.rb +0 -114
- data/spec/rspec/core/warnings_spec.rb +0 -29
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -91
- data/spec/spec_helper.rb +0 -160
- data/spec/support/config_options_helper.rb +0 -13
- data/spec/support/formatter_support.rb +0 -83
- data/spec/support/helper_methods.rb +0 -26
- data/spec/support/isolate_load_path_mutation.rb +0 -5
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +0 -87
- data/spec/support/matchers.rb +0 -85
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/old_style_formatter_example.rb +0 -69
- data/spec/support/shared_example_groups.rb +0 -13
- data/spec/support/spec_files.rb +0 -44
- data/spec/support/stderr_splitter.rb +0 -36
@@ -1,16 +0,0 @@
|
|
1
|
-
if defined?(Cucumber)
|
2
|
-
require 'shellwords'
|
3
|
-
Before do
|
4
|
-
set_env('SPEC_OPTS', "-r#{Shellwords.escape(__FILE__)}")
|
5
|
-
end
|
6
|
-
else
|
7
|
-
RSpec.configure do |rspec|
|
8
|
-
rspec.mock_with :rspec do |mocks|
|
9
|
-
mocks.syntax = :expect
|
10
|
-
end
|
11
|
-
|
12
|
-
rspec.expect_with :rspec do |expectations|
|
13
|
-
expectations.syntax = :expect
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module RSpec
|
2
|
-
module Core
|
3
|
-
class CommandLine
|
4
|
-
def initialize(options, configuration=RSpec::configuration, world=RSpec::world)
|
5
|
-
if Array === options
|
6
|
-
options = ConfigurationOptions.new(options)
|
7
|
-
end
|
8
|
-
@options = options
|
9
|
-
@configuration = configuration
|
10
|
-
@world = world
|
11
|
-
end
|
12
|
-
|
13
|
-
# Configures and runs a suite
|
14
|
-
#
|
15
|
-
# @param [IO] err
|
16
|
-
# @param [IO] out
|
17
|
-
def run(err, out)
|
18
|
-
@configuration.error_stream = err
|
19
|
-
@configuration.output_stream = out if @configuration.output_stream == $stdout
|
20
|
-
@options.configure(@configuration)
|
21
|
-
@configuration.load_spec_files
|
22
|
-
@world.announce_filters
|
23
|
-
|
24
|
-
@configuration.reporter.report(@world.example_count) do |reporter|
|
25
|
-
begin
|
26
|
-
@configuration.hooks.run(:before, :suite)
|
27
|
-
@world.ordered_example_groups.map {|g| g.run(reporter) }.all? ? 0 : @configuration.failure_exit_code
|
28
|
-
ensure
|
29
|
-
@configuration.hooks.run(:after, :suite)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'drb/drb'
|
2
|
-
require 'rspec/core/drb_options'
|
3
|
-
|
4
|
-
module RSpec
|
5
|
-
module Core
|
6
|
-
class DRbCommandLine
|
7
|
-
def initialize(options)
|
8
|
-
@options = options
|
9
|
-
end
|
10
|
-
|
11
|
-
def drb_port
|
12
|
-
@options.options[:drb_port] || ENV['RSPEC_DRB'] || 8989
|
13
|
-
end
|
14
|
-
|
15
|
-
def run(err, out)
|
16
|
-
begin
|
17
|
-
DRb.start_service("druby://localhost:0")
|
18
|
-
rescue SocketError, Errno::EADDRNOTAVAIL
|
19
|
-
DRb.start_service("druby://:0")
|
20
|
-
end
|
21
|
-
spec_server = DRbObject.new_with_uri("druby://127.0.0.1:#{drb_port}")
|
22
|
-
spec_server.run(@options.drb_argv, err, out)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
# Builds command line arguments to pass to the rspec command over DRb
|
2
|
-
|
3
|
-
module RSpec::Core
|
4
|
-
# @private
|
5
|
-
class DrbOptions
|
6
|
-
def initialize(submitted_options, filter_manager)
|
7
|
-
@submitted_options = submitted_options
|
8
|
-
@filter_manager = filter_manager
|
9
|
-
end
|
10
|
-
|
11
|
-
def options
|
12
|
-
argv = []
|
13
|
-
argv << "--color" if @submitted_options[:color]
|
14
|
-
argv << "--profile" if @submitted_options[:profile_examples]
|
15
|
-
argv << "--backtrace" if @submitted_options[:full_backtrace]
|
16
|
-
argv << "--tty" if @submitted_options[:tty]
|
17
|
-
argv << "--fail-fast" if @submitted_options[:fail_fast]
|
18
|
-
argv << "--options" << @submitted_options[:custom_options_file] if @submitted_options[:custom_options_file]
|
19
|
-
argv << "--order" << @submitted_options[:order] if @submitted_options[:order]
|
20
|
-
|
21
|
-
add_failure_exit_code(argv)
|
22
|
-
add_full_description(argv)
|
23
|
-
add_line_numbers(argv)
|
24
|
-
add_filter(argv, :inclusion, @filter_manager.inclusions)
|
25
|
-
add_filter(argv, :exclusion, @filter_manager.exclusions)
|
26
|
-
add_formatters(argv)
|
27
|
-
add_libs(argv)
|
28
|
-
add_requires(argv)
|
29
|
-
|
30
|
-
argv + @submitted_options[:files_or_directories_to_run]
|
31
|
-
end
|
32
|
-
|
33
|
-
def add_failure_exit_code(argv)
|
34
|
-
if @submitted_options[:failure_exit_code]
|
35
|
-
argv << "--failure-exit-code" << @submitted_options[:failure_exit_code].to_s
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def add_full_description(argv)
|
40
|
-
if @submitted_options[:full_description]
|
41
|
-
# The argument to --example is regexp-escaped before being stuffed
|
42
|
-
# into a regexp when received for the first time (see OptionParser).
|
43
|
-
# Hence, merely grabbing the source of this regexp will retain the
|
44
|
-
# backslashes, so we must remove them.
|
45
|
-
@submitted_options[:full_description].each do |description|
|
46
|
-
argv << "--example" << description.source.delete('\\')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def add_line_numbers(argv)
|
52
|
-
if @submitted_options[:line_numbers]
|
53
|
-
argv.push(*@submitted_options[:line_numbers].inject([]){|a,l| a << "--line_number" << l})
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
CONDITIONAL_FILTERS = [:if, :unless]
|
58
|
-
|
59
|
-
def add_filter(argv, name, hash)
|
60
|
-
hash.each_pair do |k, v|
|
61
|
-
next if CONDITIONAL_FILTERS.include?(k)
|
62
|
-
tag = name == :inclusion ? k.to_s : "~#{k}"
|
63
|
-
tag << ":#{v}" if v.is_a?(String)
|
64
|
-
argv << "--tag" << tag
|
65
|
-
end unless hash.empty?
|
66
|
-
end
|
67
|
-
|
68
|
-
def add_formatters(argv)
|
69
|
-
@submitted_options[:formatters].each do |pair|
|
70
|
-
argv << "--format" << pair[0]
|
71
|
-
argv << "--out" << pair[1] if pair[1]
|
72
|
-
end if @submitted_options[:formatters]
|
73
|
-
end
|
74
|
-
|
75
|
-
def add_libs(argv)
|
76
|
-
@submitted_options[:libs].each do |path|
|
77
|
-
argv << "-I" << path
|
78
|
-
end if @submitted_options[:libs]
|
79
|
-
end
|
80
|
-
|
81
|
-
def add_requires(argv)
|
82
|
-
@submitted_options[:requires].each do |path|
|
83
|
-
argv << "--require" << path
|
84
|
-
end if @submitted_options[:requires]
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,227 +0,0 @@
|
|
1
|
-
require 'rspec/core/formatters/helpers'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
module RSpec
|
5
|
-
module Core
|
6
|
-
module Formatters
|
7
|
-
|
8
|
-
# The `LegacyFormatter` is used to wrap older RSpec 2.x style formatters
|
9
|
-
# for the new 3.x implementation. It takes care of registering all the
|
10
|
-
# old notifications and translating them to the older formatter.
|
11
|
-
#
|
12
|
-
# @see RSpec::Core::Formatters::BaseFormatter
|
13
|
-
class LegacyFormatter
|
14
|
-
NOTIFICATIONS = %W[start message example_group_started example_group_finished example_started
|
15
|
-
example_passed example_failed example_pending start_dump dump_pending
|
16
|
-
dump_failures dump_summary seed close stop deprecation deprecation_summary]
|
17
|
-
|
18
|
-
module LegacyInterface
|
19
|
-
|
20
|
-
def start(count)
|
21
|
-
super Notifications::CountNotification.new(count)
|
22
|
-
end
|
23
|
-
|
24
|
-
def example_group_started(group)
|
25
|
-
super Notifications::GroupNotification.new(group) if defined?(super)
|
26
|
-
end
|
27
|
-
|
28
|
-
def example_group_finished(group)
|
29
|
-
super Notifications::GroupNotification.new(group) if defined?(super)
|
30
|
-
end
|
31
|
-
|
32
|
-
def example_started(example)
|
33
|
-
super Notifications::ExampleNotification.new(example) if defined?(super)
|
34
|
-
end
|
35
|
-
|
36
|
-
def example_passed(example)
|
37
|
-
super Notifications::ExampleNotification.new(example) if defined?(super)
|
38
|
-
end
|
39
|
-
|
40
|
-
def example_pending(example)
|
41
|
-
super Notifications::ExampleNotification.new(example) if defined?(super)
|
42
|
-
end
|
43
|
-
|
44
|
-
def example_failed(example)
|
45
|
-
super Notifications::ExampleNotification.new(example) if defined?(super)
|
46
|
-
end
|
47
|
-
|
48
|
-
def message(message)
|
49
|
-
super Notifications::MessageNotification.new(message) if defined?(super)
|
50
|
-
end
|
51
|
-
|
52
|
-
attr_reader :duration, :example_count, :failure_count, :pending_count
|
53
|
-
def dump_summary(duration, examples, failures, pending)
|
54
|
-
@duration = duration
|
55
|
-
@example_count = examples
|
56
|
-
@failure_count = failures
|
57
|
-
@pending_count = pending
|
58
|
-
super Notifications::SummaryNotification.new(duration, examples, failures, pending) if defined?(super)
|
59
|
-
end
|
60
|
-
|
61
|
-
def seed(seed)
|
62
|
-
super Notifications::SeedNotification.new(seed, true) if defined?(super)
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
def start_dump
|
67
|
-
super(Notifications::NullNotification) if defined?(super)
|
68
|
-
end
|
69
|
-
|
70
|
-
def dump_failures
|
71
|
-
super(Notifications::NullNotification) if defined?(super)
|
72
|
-
end
|
73
|
-
|
74
|
-
def dump_pending
|
75
|
-
super(Notifications::NullNotification) if defined?(super)
|
76
|
-
end
|
77
|
-
|
78
|
-
def dump_profile
|
79
|
-
super(Notifications::NullNotification) if defined?(super)
|
80
|
-
end
|
81
|
-
|
82
|
-
def close
|
83
|
-
super(Notifications::NullNotification) if defined?(super)
|
84
|
-
end
|
85
|
-
|
86
|
-
def stop
|
87
|
-
super(Notifications::NullNotification) if defined?(super)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# @api private
|
92
|
-
attr_reader :formatter
|
93
|
-
|
94
|
-
# @api public
|
95
|
-
#
|
96
|
-
# @param formatter
|
97
|
-
def initialize(formatter_class, *args)
|
98
|
-
if formatter_class.ancestors.include?(BaseFormatter)
|
99
|
-
formatter_class.class_eval do
|
100
|
-
include LegacyInterface
|
101
|
-
end
|
102
|
-
end
|
103
|
-
@formatter = formatter_class.new(*args)
|
104
|
-
end
|
105
|
-
|
106
|
-
# @api public
|
107
|
-
#
|
108
|
-
# This method is invoked during the setup phase to register
|
109
|
-
# a formatters with the reporter
|
110
|
-
#
|
111
|
-
def notifications
|
112
|
-
@notifications ||= NOTIFICATIONS.select { |m| @formatter.respond_to? m }
|
113
|
-
end
|
114
|
-
|
115
|
-
# @api public
|
116
|
-
#
|
117
|
-
# @param example_count
|
118
|
-
def start(notification)
|
119
|
-
@formatter.start notification.count
|
120
|
-
end
|
121
|
-
|
122
|
-
# @api public
|
123
|
-
#
|
124
|
-
# @param example_group
|
125
|
-
def example_group_started(notification)
|
126
|
-
@formatter.example_group_started notification.group
|
127
|
-
end
|
128
|
-
|
129
|
-
# @api public
|
130
|
-
#
|
131
|
-
# @param example_group
|
132
|
-
def example_group_finished(notification)
|
133
|
-
@formatter.example_group_finished notification.group
|
134
|
-
end
|
135
|
-
|
136
|
-
# @api public
|
137
|
-
#
|
138
|
-
# @param example
|
139
|
-
def example_started(notification)
|
140
|
-
@formatter.example_started notification.example
|
141
|
-
end
|
142
|
-
|
143
|
-
# @api public
|
144
|
-
#
|
145
|
-
# @param example
|
146
|
-
def example_passed(notification)
|
147
|
-
@formatter.example_passed notification.example
|
148
|
-
end
|
149
|
-
|
150
|
-
# @api public
|
151
|
-
#
|
152
|
-
# @param example
|
153
|
-
def example_pending(notification)
|
154
|
-
@formatter.example_pending notification.example
|
155
|
-
end
|
156
|
-
|
157
|
-
# @api public
|
158
|
-
#
|
159
|
-
# @param example
|
160
|
-
def example_failed(notification)
|
161
|
-
@formatter.example_failed notification.example
|
162
|
-
end
|
163
|
-
|
164
|
-
# @api public
|
165
|
-
#
|
166
|
-
# @param message
|
167
|
-
def message(notification)
|
168
|
-
@formatter.message notification.message
|
169
|
-
end
|
170
|
-
|
171
|
-
# @api public
|
172
|
-
#
|
173
|
-
def stop(notification)
|
174
|
-
@formatter.stop
|
175
|
-
end
|
176
|
-
|
177
|
-
# @api public
|
178
|
-
#
|
179
|
-
def start_dump(notification)
|
180
|
-
@formatter.start_dump
|
181
|
-
end
|
182
|
-
|
183
|
-
# @api public
|
184
|
-
#
|
185
|
-
def dump_failures(notification)
|
186
|
-
@formatter.dump_failures
|
187
|
-
end
|
188
|
-
|
189
|
-
# @api public
|
190
|
-
#
|
191
|
-
# @param duration
|
192
|
-
# @param example_count
|
193
|
-
# @param failure_count
|
194
|
-
# @param pending_count
|
195
|
-
def dump_summary(summary)
|
196
|
-
@formatter.dump_summary summary.duration, summary.example_count, summary.failure_count, summary.pending_count
|
197
|
-
end
|
198
|
-
|
199
|
-
# @api public
|
200
|
-
#
|
201
|
-
def dump_pending(notification)
|
202
|
-
@formatter.dump_pending
|
203
|
-
end
|
204
|
-
|
205
|
-
# @api public
|
206
|
-
#
|
207
|
-
def dump_profile(notification)
|
208
|
-
@formatter.dump_profile
|
209
|
-
end
|
210
|
-
|
211
|
-
# @api public
|
212
|
-
#
|
213
|
-
# @param seed
|
214
|
-
def seed(notification)
|
215
|
-
@formatter.seed notification.seed
|
216
|
-
end
|
217
|
-
|
218
|
-
# @api public
|
219
|
-
#
|
220
|
-
def close(notification)
|
221
|
-
@formatter.close
|
222
|
-
end
|
223
|
-
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
@@ -1,27 +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)
|
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
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,211 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe 'command line', :ui, :slow do
|
4
|
-
let(:stderr) { StringIO.new }
|
5
|
-
let(:stdout) { StringIO.new }
|
6
|
-
|
7
|
-
before :all do
|
8
|
-
write_file 'spec/simple_spec.rb', """
|
9
|
-
RSpec.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
|
-
RSpec.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
|
-
RSpec.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 7') {}
|
43
|
-
specify('group 1 example 8') {}
|
44
|
-
specify('group 1 example 9') {}
|
45
|
-
specify('group 1 example 10') {}
|
46
|
-
|
47
|
-
describe 'group 1-1' do
|
48
|
-
specify('group 1-1 example 1') {}
|
49
|
-
specify('group 1-1 example 2') {}
|
50
|
-
specify('group 1-1 example 3') {}
|
51
|
-
specify('group 1-1 example 4') {}
|
52
|
-
specify('group 1-1 example 5') {}
|
53
|
-
specify('group 1-1 example 6') {}
|
54
|
-
specify('group 1-1 example 7') {}
|
55
|
-
specify('group 1-1 example 8') {}
|
56
|
-
specify('group 1-1 example 9') {}
|
57
|
-
specify('group 1-1 example 10') {}
|
58
|
-
end
|
59
|
-
|
60
|
-
describe('group 1-2') { specify('example') {} }
|
61
|
-
describe('group 1-3') { specify('example') {} }
|
62
|
-
describe('group 1-4') { specify('example') {} }
|
63
|
-
describe('group 1-5') { specify('example') {} }
|
64
|
-
describe('group 1-6') { specify('example') {} }
|
65
|
-
describe('group 1-7') { specify('example') {} }
|
66
|
-
describe('group 1-8') { specify('example') {} }
|
67
|
-
describe('group 1-9') { specify('example') {} }
|
68
|
-
describe('group 1-10') { specify('example') {} }
|
69
|
-
end
|
70
|
-
|
71
|
-
RSpec.describe('group 2') { specify('example') {} }
|
72
|
-
RSpec.describe('group 3') { specify('example') {} }
|
73
|
-
RSpec.describe('group 4') { specify('example') {} }
|
74
|
-
RSpec.describe('group 5') { specify('example') {} }
|
75
|
-
RSpec.describe('group 6') { specify('example') {} }
|
76
|
-
RSpec.describe('group 7') { specify('example') {} }
|
77
|
-
RSpec.describe('group 8') { specify('example') {} }
|
78
|
-
RSpec.describe('group 9') { specify('example') {} }
|
79
|
-
RSpec.describe('group 10') { specify('example') {} }
|
80
|
-
"""
|
81
|
-
end
|
82
|
-
|
83
|
-
describe '--order rand' do
|
84
|
-
it 'runs the examples and groups in a different order each time' do
|
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
|
90
|
-
|
91
|
-
expect(stdout.string).to match(/Randomized with seed \d+/)
|
92
|
-
|
93
|
-
top_level_groups {|first_run, second_run| expect(first_run).to_not eq(second_run)}
|
94
|
-
nested_groups {|first_run, second_run| expect(first_run).to_not eq(second_run)}
|
95
|
-
examples('group 1') {|first_run, second_run| expect(first_run).to_not eq(second_run)}
|
96
|
-
examples('group 1-1') {|first_run, second_run| expect(first_run).to_not eq(second_run)}
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe '--order rand:SEED' do
|
101
|
-
it 'runs the examples and groups in the same order each time' do
|
102
|
-
2.times { run_command 'spec/order_spec.rb --order rand:123 -f doc' }
|
103
|
-
|
104
|
-
expect(stdout.string).to match(/Randomized with seed 123/)
|
105
|
-
|
106
|
-
top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
107
|
-
nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
108
|
-
examples('group 1') {|first_run, second_run| expect(first_run).to eq(second_run)}
|
109
|
-
examples('group 1-1') {|first_run, second_run| expect(first_run).to eq(second_run)}
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
describe '--seed SEED' do
|
114
|
-
it "forces '--order rand' and runs the examples and groups in the same order each time" do
|
115
|
-
2.times { run_command 'spec/order_spec.rb --seed 123 -f doc' }
|
116
|
-
|
117
|
-
expect(stdout.string).to match(/Randomized with seed 123/)
|
118
|
-
|
119
|
-
top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
120
|
-
nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
121
|
-
examples('group 1') {|first_run, second_run| expect(first_run).to eq(second_run)}
|
122
|
-
examples('group 1-1') {|first_run, second_run| expect(first_run).to eq(second_run)}
|
123
|
-
end
|
124
|
-
|
125
|
-
it "runs examples in the same order, regardless of the order in which files are given" do
|
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'
|
128
|
-
|
129
|
-
top_level_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
130
|
-
nested_groups {|first_run, second_run| expect(first_run).to eq(second_run)}
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe '--order defined on CLI with --order rand in .rspec' do
|
135
|
-
after { remove_file '.rspec' }
|
136
|
-
|
137
|
-
it "overrides --order rand with --order defined" do
|
138
|
-
write_file '.rspec', '--order rand'
|
139
|
-
|
140
|
-
run_command 'spec/order_spec.rb --order defined -f doc'
|
141
|
-
|
142
|
-
expect(stdout.string).not_to match(/Randomized/)
|
143
|
-
|
144
|
-
expect(stdout.string).to match(
|
145
|
-
/group 1.*group 1 example 1.*group 1 example 2.*group 1-1.*group 1-2.*group 2.*/m
|
146
|
-
)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context 'when a custom order is configured' do
|
151
|
-
after { remove_file 'spec/custom_order_spec.rb' }
|
152
|
-
|
153
|
-
before do
|
154
|
-
write_file 'spec/custom_order_spec.rb', """
|
155
|
-
RSpec.configure do |config|
|
156
|
-
config.register_ordering :global do |list|
|
157
|
-
list.sort_by { |item| item.description }
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
RSpec.describe 'group B' do
|
162
|
-
specify('group B example D') {}
|
163
|
-
specify('group B example B') {}
|
164
|
-
specify('group B example A') {}
|
165
|
-
specify('group B example C') {}
|
166
|
-
end
|
167
|
-
|
168
|
-
RSpec.describe 'group A' do
|
169
|
-
specify('group A example 1') {}
|
170
|
-
end
|
171
|
-
"""
|
172
|
-
end
|
173
|
-
|
174
|
-
it 'orders the groups and examples by the provided strategy' do
|
175
|
-
run_command 'spec/custom_order_spec.rb -f doc'
|
176
|
-
|
177
|
-
top_level_groups { |groups| expect(groups.flatten).to eq(['group A', 'group B']) }
|
178
|
-
examples('group B') do |examples|
|
179
|
-
letters = examples.flatten.map { |e| e[/(.)\z/, 1] }
|
180
|
-
expect(letters).to eq(['A', 'B', 'C', 'D'])
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
def examples(group)
|
186
|
-
yield split_in_half(stdout.string.scan(/^\s+#{group} example.*$/))
|
187
|
-
end
|
188
|
-
|
189
|
-
def top_level_groups
|
190
|
-
yield example_groups_at_level(0)
|
191
|
-
end
|
192
|
-
|
193
|
-
def nested_groups
|
194
|
-
yield example_groups_at_level(2)
|
195
|
-
end
|
196
|
-
|
197
|
-
def example_groups_at_level(level)
|
198
|
-
split_in_half(stdout.string.scan(/^\s{#{level*2}}group.*$/))
|
199
|
-
end
|
200
|
-
|
201
|
-
def split_in_half(array)
|
202
|
-
length, midpoint = array.length, array.length / 2
|
203
|
-
return array.slice(0, midpoint), array.slice(midpoint, length)
|
204
|
-
end
|
205
|
-
|
206
|
-
def run_command(cmd)
|
207
|
-
in_current_dir do
|
208
|
-
RSpec::Core::Runner.run(cmd.split, stderr, stdout)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|