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,73 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require 'rspec/core/project_initializer'
|
3
|
-
|
4
|
-
module RSpec::Core
|
5
|
-
RSpec.describe ProjectInitializer, :isolated_directory => true do
|
6
|
-
|
7
|
-
describe "#run" do
|
8
|
-
context "with no args" do
|
9
|
-
let(:command_line_config) { ProjectInitializer.new }
|
10
|
-
|
11
|
-
before do
|
12
|
-
allow(command_line_config).to receive(:puts)
|
13
|
-
allow(command_line_config).to receive_messages(:gets => 'no')
|
14
|
-
end
|
15
|
-
|
16
|
-
context "with no .rspec file" do
|
17
|
-
it "says it's creating .rspec " do
|
18
|
-
expect(command_line_config).to receive(:puts).with(/create\s+\.rspec/)
|
19
|
-
command_line_config.run
|
20
|
-
end
|
21
|
-
|
22
|
-
it "generates a .rspec" do
|
23
|
-
command_line_config.run
|
24
|
-
expect(File.read('.rspec')).to match(/--color/m)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "with a .rspec file" do
|
29
|
-
it "says .rspec exists" do
|
30
|
-
FileUtils.touch('.rspec')
|
31
|
-
expect(command_line_config).to receive(:puts).with(/exist\s+\.rspec/)
|
32
|
-
command_line_config.run
|
33
|
-
end
|
34
|
-
|
35
|
-
it "doesn't create a new one" do
|
36
|
-
File.open('.rspec', 'w') {|f| f << '--color'}
|
37
|
-
command_line_config.run
|
38
|
-
expect(File.read('.rspec')).to eq('--color')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "with no spec/spec_helper.rb file" do
|
43
|
-
it "says it's creating spec/spec_helper.rb " do
|
44
|
-
expect(command_line_config).to receive(:puts).with(/create\s+spec\/spec_helper.rb/)
|
45
|
-
command_line_config.run
|
46
|
-
end
|
47
|
-
|
48
|
-
it "generates a spec/spec_helper.rb" do
|
49
|
-
command_line_config.run
|
50
|
-
expect(File.read('spec/spec_helper.rb')).to match(/RSpec\.configure do \|config\|/m)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "with a spec/spec_helper.rb file" do
|
55
|
-
before { FileUtils.mkdir('spec') }
|
56
|
-
|
57
|
-
it "says spec/spec_helper.rb exists" do
|
58
|
-
FileUtils.touch('spec/spec_helper.rb')
|
59
|
-
expect(command_line_config).to receive(:puts).with(/exist\s+spec\/spec_helper.rb/)
|
60
|
-
command_line_config.run
|
61
|
-
end
|
62
|
-
|
63
|
-
it "doesn't create a new one" do
|
64
|
-
random_content = "content #{rand}"
|
65
|
-
File.open('spec/spec_helper.rb', 'w') {|f| f << random_content}
|
66
|
-
command_line_config.run
|
67
|
-
expect(File.read('spec/spec_helper.rb')).to eq(random_content)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,146 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
require 'tempfile'
|
4
|
-
|
5
|
-
module RSpec::Core
|
6
|
-
RSpec.describe RakeTask do
|
7
|
-
let(:task) { RakeTask.new }
|
8
|
-
|
9
|
-
def ruby
|
10
|
-
FileUtils::RUBY
|
11
|
-
end
|
12
|
-
|
13
|
-
def spec_command
|
14
|
-
task.__send__(:spec_command)
|
15
|
-
end
|
16
|
-
|
17
|
-
context "with a name passed to the constructor" do
|
18
|
-
let(:task) { RakeTask.new(:task_name) }
|
19
|
-
|
20
|
-
it "correctly sets the name" do
|
21
|
-
expect(task.name).to eq :task_name
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context "with args passed to the rake task" do
|
26
|
-
it "correctly passes along task arguments" do
|
27
|
-
task = RakeTask.new(:rake_task_args, :files) do |t, args|
|
28
|
-
expect(args[:files]).to eq "first_spec.rb"
|
29
|
-
end
|
30
|
-
|
31
|
-
expect(task).to receive(:run_task) { true }
|
32
|
-
expect(Rake.application.invoke_task("rake_task_args[first_spec.rb]")).to be_truthy
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "default" do
|
37
|
-
it "renders rspec" do
|
38
|
-
expect(spec_command).to match(/^#{ruby} -S rspec/)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "with ruby options" do
|
43
|
-
it "renders them before -S" do
|
44
|
-
task.ruby_opts = "-w"
|
45
|
-
expect(spec_command).to match(/^#{ruby} -w -S rspec/)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "with rspec_opts" do
|
50
|
-
it "adds the rspec_opts" do
|
51
|
-
task.rspec_opts = "-Ifoo"
|
52
|
-
expect(spec_command).to match(/rspec.*-Ifoo/)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'with custom exit status' do
|
57
|
-
it 'returns the correct status on exit', :slow do
|
58
|
-
with_isolated_stderr do
|
59
|
-
expect($stderr).to receive(:puts) { |cmd| expect(cmd).to match(/-e "exit\(2\);".* failed/) }
|
60
|
-
expect(task).to receive(:exit).with(2)
|
61
|
-
task.ruby_opts = '-e "exit(2);" ;#'
|
62
|
-
task.run_task false
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def specify_consistent_ordering_of_files_to_run(pattern, task)
|
68
|
-
orderings = [
|
69
|
-
%w[ a/1.rb a/2.rb a/3.rb ],
|
70
|
-
%w[ a/2.rb a/1.rb a/3.rb ],
|
71
|
-
%w[ a/3.rb a/2.rb a/1.rb ]
|
72
|
-
].map do |files|
|
73
|
-
expect(FileList).to receive(:[]).with(pattern) { files }
|
74
|
-
task.__send__(:files_to_run)
|
75
|
-
end
|
76
|
-
|
77
|
-
expect(orderings.uniq.size).to eq(1)
|
78
|
-
end
|
79
|
-
|
80
|
-
context "with SPEC env var set" do
|
81
|
-
it "sets files to run" do
|
82
|
-
with_env_vars 'SPEC' => 'path/to/file' do
|
83
|
-
expect(task.__send__(:files_to_run)).to eq(["path/to/file"])
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
it "sets the files to run in a consistent order, regardless of the underlying FileList ordering" do
|
88
|
-
with_env_vars 'SPEC' => 'a/*.rb' do
|
89
|
-
specify_consistent_ordering_of_files_to_run('a/*.rb', task)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
it "sets the files to run in a consistent order, regardless of the underlying FileList ordering" do
|
95
|
-
task = RakeTask.new(:consistent_file_order) do |t|
|
96
|
-
t.pattern = 'a/*.rb'
|
97
|
-
end
|
98
|
-
|
99
|
-
# since the config block is deferred til task invocation, must fake
|
100
|
-
# calling the task so the expected pattern is picked up
|
101
|
-
expect(task).to receive(:run_task) { true }
|
102
|
-
expect(Rake.application.invoke_task(task.name)).to be_truthy
|
103
|
-
|
104
|
-
specify_consistent_ordering_of_files_to_run('a/*.rb', task)
|
105
|
-
end
|
106
|
-
|
107
|
-
context "with paths with quotes or spaces" do
|
108
|
-
it "escapes the quotes and spaces" do
|
109
|
-
task.pattern = File.join(Dir.tmpdir, "*spec.rb")
|
110
|
-
["first_spec.rb", "second_\"spec.rb", "third_\'spec.rb", "fourth spec.rb"].each do |file_name|
|
111
|
-
FileUtils.touch(File.join(Dir.tmpdir, file_name))
|
112
|
-
end
|
113
|
-
expect(task.__send__(:files_to_run).sort).to eq([
|
114
|
-
File.join(Dir.tmpdir, "first_spec.rb"),
|
115
|
-
File.join(Dir.tmpdir, "fourth\\ spec.rb"),
|
116
|
-
File.join(Dir.tmpdir, "second_\\\"spec.rb"),
|
117
|
-
File.join(Dir.tmpdir, "third_\\\'spec.rb")
|
118
|
-
])
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
context "with paths including symlinked directories" do
|
123
|
-
it "finds the files" do
|
124
|
-
project_dir = File.join(Dir.tmpdir, "project")
|
125
|
-
FileUtils.rm_rf project_dir
|
126
|
-
|
127
|
-
foos_dir = File.join(project_dir, "spec/foos")
|
128
|
-
FileUtils.mkdir_p foos_dir
|
129
|
-
FileUtils.touch(File.join(foos_dir, "foo_spec.rb"))
|
130
|
-
|
131
|
-
bars_dir = File.join(Dir.tmpdir, "shared/spec/bars")
|
132
|
-
FileUtils.mkdir_p bars_dir
|
133
|
-
FileUtils.touch(File.join(bars_dir, "bar_spec.rb"))
|
134
|
-
|
135
|
-
FileUtils.ln_s bars_dir, File.join(project_dir, "spec/bars")
|
136
|
-
|
137
|
-
FileUtils.cd(project_dir) do
|
138
|
-
expect(RakeTask.new.__send__(:files_to_run).sort).to eq([
|
139
|
-
"./spec/bars/bar_spec.rb",
|
140
|
-
"./spec/foos/foo_spec.rb"
|
141
|
-
])
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module RSpec
|
4
|
-
module Core
|
5
|
-
RSpec.describe RandomNumberGenerator do
|
6
|
-
it 'is a random number generator' do
|
7
|
-
random = described_class.new
|
8
|
-
|
9
|
-
expect([Fixnum, Bignum]).to include random.seed.class
|
10
|
-
expect(random.rand).to be_a Float
|
11
|
-
|
12
|
-
rands = []
|
13
|
-
100.times do
|
14
|
-
rands << random.rand
|
15
|
-
end
|
16
|
-
|
17
|
-
expect(rands.uniq.count).to be > 90
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'produces the same results given the same seed' do
|
21
|
-
seed = rand(999)
|
22
|
-
|
23
|
-
random = described_class.new(seed)
|
24
|
-
|
25
|
-
expect(random.seed).to eq seed
|
26
|
-
|
27
|
-
expected = []
|
28
|
-
5.times do
|
29
|
-
expected << random.rand(999)
|
30
|
-
end
|
31
|
-
|
32
|
-
10.times do
|
33
|
-
random = described_class.new(seed)
|
34
|
-
|
35
|
-
expect(random.seed).to eq seed
|
36
|
-
|
37
|
-
actual = []
|
38
|
-
5.times do
|
39
|
-
actual << random.rand(999)
|
40
|
-
end
|
41
|
-
|
42
|
-
expect(actual).to eq expected
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,155 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module RSpec::Core
|
4
|
-
RSpec.describe Reporter do
|
5
|
-
let(:config) { Configuration.new }
|
6
|
-
let(:reporter) { Reporter.new config }
|
7
|
-
|
8
|
-
describe "finish" do
|
9
|
-
let(:formatter) { double("formatter") }
|
10
|
-
let(:example) { double("example") }
|
11
|
-
|
12
|
-
%w[start_dump dump_pending dump_failures dump_summary close].map(&:to_sym).each do |message|
|
13
|
-
it "sends #{message} to the formatter(s) that respond to message" do
|
14
|
-
reporter.register_listener formatter, message
|
15
|
-
expect(formatter.as_null_object).to receive(message)
|
16
|
-
reporter.finish
|
17
|
-
end
|
18
|
-
|
19
|
-
it "doesnt notify formatters about messages they dont implement" do
|
20
|
-
expect { reporter.finish }.to_not raise_error
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context "given one formatter" do
|
26
|
-
it "passes messages to that formatter" do
|
27
|
-
formatter = double("formatter", :example_started => nil)
|
28
|
-
example = double("example")
|
29
|
-
reporter.register_listener formatter, :example_started
|
30
|
-
|
31
|
-
expect(formatter).to receive(:example_started) do |notification|
|
32
|
-
expect(notification.example).to eq example
|
33
|
-
end
|
34
|
-
|
35
|
-
reporter.example_started(example)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "passes example_group_started and example_group_finished messages to that formatter in that order" do
|
39
|
-
order = []
|
40
|
-
|
41
|
-
formatter = double("formatter")
|
42
|
-
allow(formatter).to receive(:example_group_started) { |n| order << "Started: #{n.group.description}" }
|
43
|
-
allow(formatter).to receive(:example_group_finished) { |n| order << "Finished: #{n.group.description}" }
|
44
|
-
|
45
|
-
reporter.register_listener formatter, :example_group_started, :example_group_finished
|
46
|
-
|
47
|
-
group = ExampleGroup.describe("root")
|
48
|
-
group.describe("context 1") do
|
49
|
-
example("ignore") {}
|
50
|
-
end
|
51
|
-
group.describe("context 2") do
|
52
|
-
example("ignore") {}
|
53
|
-
end
|
54
|
-
|
55
|
-
group.run(reporter)
|
56
|
-
|
57
|
-
expect(order).to eq([
|
58
|
-
"Started: root",
|
59
|
-
"Started: context 1",
|
60
|
-
"Finished: context 1",
|
61
|
-
"Started: context 2",
|
62
|
-
"Finished: context 2",
|
63
|
-
"Finished: root"
|
64
|
-
])
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "given an example group with no examples" do
|
69
|
-
it "does not pass example_group_started or example_group_finished to formatter" do
|
70
|
-
formatter = double("formatter")
|
71
|
-
expect(formatter).not_to receive(:example_group_started)
|
72
|
-
expect(formatter).not_to receive(:example_group_finished)
|
73
|
-
|
74
|
-
reporter.register_listener formatter, :example_group_started, :example_group_finished
|
75
|
-
|
76
|
-
group = ExampleGroup.describe("root")
|
77
|
-
|
78
|
-
group.run(reporter)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context "given multiple formatters" do
|
83
|
-
it "passes messages to all formatters" do
|
84
|
-
formatters = (1..2).map { double("formatter", :example_started => nil) }
|
85
|
-
example = double("example")
|
86
|
-
|
87
|
-
formatters.each do |formatter|
|
88
|
-
expect(formatter).to receive(:example_started) do |notification|
|
89
|
-
expect(notification.example).to eq example
|
90
|
-
end
|
91
|
-
reporter.register_listener formatter, :example_started
|
92
|
-
end
|
93
|
-
|
94
|
-
reporter.example_started(example)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "#report" do
|
99
|
-
it "supports one arg (count)" do
|
100
|
-
reporter.report(1) {}
|
101
|
-
end
|
102
|
-
|
103
|
-
it "yields itself" do
|
104
|
-
yielded = nil
|
105
|
-
reporter.report(3) { |r| yielded = r }
|
106
|
-
expect(yielded).to eq(reporter)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "#register_listener" do
|
111
|
-
let(:listener) { double("listener", :start => nil) }
|
112
|
-
|
113
|
-
before { reporter.register_listener listener, :start }
|
114
|
-
|
115
|
-
it 'will register the listener to specified notifications' do
|
116
|
-
expect(reporter.registered_listeners :start).to eq [listener]
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'will match string notification names' do
|
120
|
-
reporter.register_listener listener, "stop"
|
121
|
-
expect(reporter.registered_listeners :stop).to eq [listener]
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'will send notifications when a subscribed event is triggered' do
|
125
|
-
expect(listener).to receive(:start) do |notification|
|
126
|
-
expect(notification.count).to eq 42
|
127
|
-
end
|
128
|
-
reporter.start 42
|
129
|
-
end
|
130
|
-
|
131
|
-
it 'will ignore duplicated listeners' do
|
132
|
-
reporter.register_listener listener, :start
|
133
|
-
expect(listener).to receive(:start).once
|
134
|
-
reporter.start 42
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe "timing" do
|
139
|
-
it "uses RSpec::Core::Time as to not be affected by changes to time in examples" do
|
140
|
-
formatter = double(:formatter)
|
141
|
-
reporter.register_listener formatter, :dump_summary
|
142
|
-
reporter.start 1
|
143
|
-
allow(Time).to receive_messages(:now => ::Time.utc(2012, 10, 1))
|
144
|
-
|
145
|
-
duration = nil
|
146
|
-
allow(formatter).to receive(:dump_summary) do |notification|
|
147
|
-
duration = notification.duration
|
148
|
-
end
|
149
|
-
|
150
|
-
reporter.finish
|
151
|
-
expect(duration).to be < 0.2
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
File without changes
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
# Empty - used by ../options_spec.rb
|