rspec-core 3.0.0.beta1 → 3.0.0.beta2
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.
- data.tar.gz.sig +0 -0
- data/Changelog.md +137 -0
- data/README.md +2 -2
- data/exe/rspec +2 -23
- data/features/README.md +1 -5
- data/features/command_line/README.md +7 -10
- data/features/command_line/exit_status.feature +1 -1
- data/features/command_line/format_option.feature +1 -1
- data/features/command_line/init.feature +40 -1
- data/features/command_line/line_number_option.feature +2 -2
- data/features/command_line/ruby.feature +5 -4
- data/features/configuration/enable_global_dsl.feature +54 -0
- data/features/example_groups/aliasing.feature +48 -0
- data/features/example_groups/basic_structure.feature +1 -1
- data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
- data/features/filtering/if_and_unless.feature +0 -30
- data/features/formatters/custom_formatter.feature +32 -0
- data/features/formatters/regression_tests.feature +95 -0
- data/features/hooks/around_hooks.feature +1 -0
- data/features/hooks/before_and_after_hooks.feature +2 -2
- data/features/mock_framework_integration/use_flexmock.feature +11 -13
- data/features/mock_framework_integration/use_mocha.feature +11 -13
- data/features/mock_framework_integration/use_rr.feature +11 -13
- data/features/mock_framework_integration/use_rspec.feature +11 -13
- data/features/pending_and_skipped_examples/README.md +3 -0
- data/features/pending_and_skipped_examples/pending_examples.feature +118 -0
- data/features/pending_and_skipped_examples/skipped_examples.feature +106 -0
- data/features/step_definitions/additional_cli_steps.rb +34 -0
- data/features/subject/explicit_subject.feature +1 -1
- data/features/subject/one_liner_syntax.feature +71 -0
- data/lib/rspec/core.rb +6 -14
- data/lib/rspec/core/backtrace_formatter.rb +16 -4
- data/lib/rspec/core/command_line.rb +2 -3
- data/lib/rspec/core/configuration.rb +114 -125
- data/lib/rspec/core/configuration_options.rb +32 -18
- data/lib/rspec/core/dsl.rb +80 -18
- data/lib/rspec/core/example.rb +84 -33
- data/lib/rspec/core/example_group.rb +95 -43
- data/lib/rspec/core/filter_manager.rb +31 -40
- data/lib/rspec/core/formatters.rb +137 -0
- data/lib/rspec/core/formatters/base_formatter.rb +28 -41
- data/lib/rspec/core/formatters/base_text_formatter.rb +26 -37
- data/lib/rspec/core/formatters/deprecation_formatter.rb +48 -27
- data/lib/rspec/core/formatters/documentation_formatter.rb +27 -22
- data/lib/rspec/core/formatters/html_formatter.rb +48 -56
- data/lib/rspec/core/formatters/html_printer.rb +11 -18
- data/lib/rspec/core/formatters/json_formatter.rb +18 -22
- data/lib/rspec/core/formatters/legacy_formatter.rb +227 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +7 -10
- data/lib/rspec/core/hooks.rb +250 -217
- data/lib/rspec/core/memoized_helpers.rb +43 -9
- 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 +28 -0
- data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
- data/lib/rspec/core/notifications.rb +100 -0
- data/lib/rspec/core/option_parser.rb +11 -18
- data/lib/rspec/core/pending.rb +78 -47
- data/lib/rspec/core/project_initializer.rb +2 -49
- data/lib/rspec/core/project_initializer/dot_rspec +3 -0
- data/lib/rspec/core/project_initializer/spec_helper.rb +82 -0
- data/lib/rspec/core/rake_task.rb +5 -14
- data/lib/rspec/core/reporter.rb +24 -32
- data/lib/rspec/core/ruby_project.rb +1 -1
- data/lib/rspec/core/runner.rb +14 -4
- data/lib/rspec/core/shared_example_group.rb +40 -13
- data/lib/rspec/core/version.rb +1 -1
- data/spec/command_line/order_spec.rb +15 -15
- data/spec/rspec/core/backtrace_formatter_spec.rb +15 -1
- data/spec/rspec/core/command_line_spec.rb +18 -17
- data/spec/rspec/core/configuration_options_spec.rb +57 -34
- data/spec/rspec/core/configuration_spec.rb +162 -184
- data/spec/rspec/core/drb_command_line_spec.rb +5 -7
- data/spec/rspec/core/drb_options_spec.rb +2 -2
- data/spec/rspec/core/dsl_spec.rb +79 -15
- data/spec/rspec/core/example_group_spec.rb +253 -39
- data/spec/rspec/core/example_spec.rb +149 -33
- data/spec/rspec/core/filter_manager_spec.rb +9 -26
- data/spec/rspec/core/formatters/base_formatter_spec.rb +2 -5
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +42 -145
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +64 -34
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +15 -28
- data/spec/rspec/core/formatters/helpers_spec.rb +2 -2
- data/spec/rspec/core/formatters/{html_formatted-1.8.7.html → html_formatted-2.1.0.html} +22 -44
- data/spec/rspec/core/formatters/{html_formatted-1.8.7-jruby.html → html_formatted.html} +30 -49
- data/spec/rspec/core/formatters/html_formatter_spec.rb +35 -19
- data/spec/rspec/core/formatters/json_formatter_spec.rb +42 -40
- data/spec/rspec/core/formatters/legacy_formatter_spec.rb +137 -0
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +38 -25
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +1 -1
- data/spec/rspec/core/formatters_spec.rb +120 -0
- data/spec/rspec/core/hooks_filtering_spec.rb +1 -1
- data/spec/rspec/core/hooks_spec.rb +13 -2
- data/spec/rspec/core/memoized_helpers_spec.rb +17 -8
- data/spec/rspec/core/metadata_spec.rb +3 -3
- data/spec/rspec/core/option_parser_spec.rb +53 -46
- data/spec/rspec/core/ordering_spec.rb +4 -4
- data/spec/rspec/core/pending_example_spec.rb +23 -126
- data/spec/rspec/core/pending_spec.rb +8 -0
- data/spec/rspec/core/project_initializer_spec.rb +8 -41
- data/spec/rspec/core/rake_task_spec.rb +15 -4
- data/spec/rspec/core/random_spec.rb +1 -1
- data/spec/rspec/core/reporter_spec.rb +50 -37
- data/spec/rspec/core/resources/formatter_specs.rb +9 -11
- data/spec/rspec/core/rspec_matchers_spec.rb +1 -1
- data/spec/rspec/core/ruby_project_spec.rb +3 -3
- data/spec/rspec/core/runner_spec.rb +65 -23
- data/spec/rspec/core/shared_context_spec.rb +4 -4
- data/spec/rspec/core/shared_example_group/collection_spec.rb +1 -1
- data/spec/rspec/core/shared_example_group_spec.rb +20 -11
- data/spec/rspec/core/warnings_spec.rb +1 -1
- data/spec/rspec/core/world_spec.rb +10 -10
- data/spec/rspec/core_spec.rb +2 -2
- data/spec/spec_helper.rb +12 -24
- data/spec/support/config_options_helper.rb +1 -3
- data/spec/support/formatter_support.rb +83 -0
- data/spec/support/isolate_load_path_mutation.rb +1 -2
- data/spec/support/isolated_directory.rb +1 -1
- data/spec/support/isolated_home_directory.rb +1 -1
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +87 -0
- data/spec/support/matchers.rb +20 -0
- data/spec/support/mathn_integration_support.rb +2 -2
- data/spec/support/old_style_formatter_example.rb +69 -0
- data/spec/support/shared_example_groups.rb +1 -1
- data/spec/support/spec_files.rb +3 -3
- metadata +192 -69
- metadata.gz.sig +3 -1
- checksums.yaml +0 -15
- checksums.yaml.gz.sig +0 -2
- data/features/configuration/show_failures_in_pending_blocks.feature +0 -61
- data/features/pending/pending_examples.feature +0 -229
- data/features/subject/implicit_receiver.feature +0 -29
- 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/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +0 -477
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +0 -425
- data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +0 -416
- data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +0 -477
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +0 -419
- data/spec/rspec/core/formatters/html_formatted-2.0.0.html +0 -425
- data/spec/support/in_sub_process.rb +0 -37
- data/spec/support/sandboxed_mock_space.rb +0 -100
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
require 'rspec/core/drb_command_line'
|
|
3
3
|
|
|
4
|
-
describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' do
|
|
4
|
+
RSpec.describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' do
|
|
5
5
|
let(:config) { RSpec::Core::Configuration.new }
|
|
6
6
|
let(:out) { StringIO.new }
|
|
7
7
|
let(:err) { StringIO.new }
|
|
@@ -13,9 +13,7 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def config_options(*args)
|
|
16
|
-
|
|
17
|
-
options.parse_options
|
|
18
|
-
options
|
|
16
|
+
RSpec::Core::ConfigurationOptions.new(args)
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
context "without server running" do
|
|
@@ -65,12 +63,12 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
|
65
63
|
end
|
|
66
64
|
end
|
|
67
65
|
|
|
68
|
-
context "with server running" do
|
|
66
|
+
context "with server running", :slow do
|
|
69
67
|
class SimpleDRbSpecServer
|
|
70
68
|
def self.run(argv, err, out)
|
|
71
69
|
options = RSpec::Core::ConfigurationOptions.new(argv)
|
|
72
|
-
|
|
73
|
-
RSpec::Core::CommandLine.new(options,
|
|
70
|
+
config = RSpec::Core::Configuration.new
|
|
71
|
+
RSpec::Core::CommandLine.new(options, config).run(err, out)
|
|
74
72
|
end
|
|
75
73
|
end
|
|
76
74
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
require 'rspec/core/drb_options'
|
|
3
3
|
|
|
4
|
-
describe RSpec::Core::DrbOptions, :isolated_directory => true, :isolated_home => true do
|
|
4
|
+
RSpec.describe RSpec::Core::DrbOptions, :isolated_directory => true, :isolated_home => true do
|
|
5
5
|
include ConfigOptionsHelper
|
|
6
6
|
|
|
7
7
|
describe "#drb_argv" do
|
|
8
8
|
it "preserves extra arguments" do
|
|
9
|
-
File.
|
|
9
|
+
allow(File).to receive(:exist?) { false }
|
|
10
10
|
expect(config_options_object(*%w[ a --drb b --color c ]).drb_argv).to match_array %w[ --color a b c ]
|
|
11
11
|
end
|
|
12
12
|
|
data/spec/rspec/core/dsl_spec.rb
CHANGED
|
@@ -1,22 +1,86 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
+
require 'rspec/support/spec/in_sub_process'
|
|
2
3
|
|
|
3
4
|
main = self
|
|
4
5
|
|
|
5
|
-
describe "The RSpec DSL" do
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
RSpec.describe "The RSpec DSL" do
|
|
7
|
+
include RSpec::Support::InSubProcess
|
|
8
|
+
|
|
9
|
+
shared_examples_for "dsl methods" do |*method_names|
|
|
10
|
+
context "when expose_dsl_globally is enabled" do
|
|
11
|
+
def enable
|
|
12
|
+
in_sub_process do
|
|
13
|
+
changing_expose_dsl_globally do
|
|
14
|
+
RSpec.configuration.expose_dsl_globally = true
|
|
15
|
+
expect(RSpec.configuration.expose_dsl_globally?).to eq true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
yield
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'makes them only available off of `RSpec`, `main` and modules' do
|
|
23
|
+
enable do
|
|
24
|
+
expect(::RSpec).to respond_to(*method_names)
|
|
25
|
+
expect(main).to respond_to(*method_names)
|
|
26
|
+
expect(Module.new).to respond_to(*method_names)
|
|
27
|
+
|
|
28
|
+
expect(Object.new).not_to respond_to(*method_names)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "when expose_dsl_globally is disabled" do
|
|
34
|
+
def disable
|
|
35
|
+
in_sub_process do
|
|
36
|
+
changing_expose_dsl_globally do
|
|
37
|
+
RSpec.configuration.expose_dsl_globally = false
|
|
38
|
+
expect(RSpec.configuration.expose_dsl_globally?).to eq false
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
yield
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'makes them only available off of `RSpec`' do
|
|
46
|
+
disable do
|
|
47
|
+
expect(::RSpec).to respond_to(*method_names)
|
|
48
|
+
|
|
49
|
+
expect(main).not_to respond_to(*method_names)
|
|
50
|
+
expect(Module.new).not_to respond_to(*method_names)
|
|
51
|
+
expect(Object.new).not_to respond_to(*method_names)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe "built in DSL methods" do
|
|
58
|
+
include_examples "dsl methods",
|
|
59
|
+
:describe, :context,
|
|
60
|
+
:share_examples_for, :shared_examples_for, :shared_examples, :shared_context do
|
|
61
|
+
|
|
62
|
+
def changing_expose_dsl_globally
|
|
63
|
+
yield
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe "custom example group aliases" do
|
|
69
|
+
context "when adding aliases before exposing the DSL globally" do
|
|
70
|
+
include_examples "dsl methods", :detail do
|
|
71
|
+
def changing_expose_dsl_globally
|
|
72
|
+
RSpec.configuration.alias_example_group_to(:detail)
|
|
73
|
+
yield
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context "when adding aliases after exposing the DSL globally" do
|
|
79
|
+
include_examples "dsl methods", :detail do
|
|
80
|
+
def changing_expose_dsl_globally
|
|
81
|
+
yield
|
|
82
|
+
RSpec.configuration.alias_example_group_to(:detail)
|
|
83
|
+
end
|
|
20
84
|
end
|
|
21
85
|
end
|
|
22
86
|
end
|
|
@@ -12,7 +12,7 @@ class SelfObserver
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
module RSpec::Core
|
|
15
|
-
describe ExampleGroup do
|
|
15
|
+
RSpec.describe ExampleGroup do
|
|
16
16
|
it_behaves_like "metadata hash builder" do
|
|
17
17
|
def metadata_hash(*args)
|
|
18
18
|
group = ExampleGroup.describe('example description', *args)
|
|
@@ -83,8 +83,8 @@ module RSpec::Core
|
|
|
83
83
|
expect(groups[1]).to have_class_const("Collision_2")
|
|
84
84
|
expect(groups[8]).to have_class_const("Collision_9")
|
|
85
85
|
|
|
86
|
-
if RUBY_VERSION.to_f > 1.8
|
|
87
|
-
# on 1.8.7, "Collision_9".next => "Collisioo_0"
|
|
86
|
+
if RUBY_VERSION.to_f > 1.8 && !(defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx')
|
|
87
|
+
# on 1.8.7, rbx "Collision_9".next => "Collisioo_0"
|
|
88
88
|
expect(groups[9]).to have_class_const("Collision_10")
|
|
89
89
|
end
|
|
90
90
|
end
|
|
@@ -282,12 +282,12 @@ module RSpec::Core
|
|
|
282
282
|
before do
|
|
283
283
|
filter_manager = FilterManager.new
|
|
284
284
|
filter_manager.include filter_metadata
|
|
285
|
-
world.
|
|
285
|
+
allow(world).to receive_messages(:filter_manager => filter_manager)
|
|
286
286
|
end
|
|
287
287
|
|
|
288
288
|
it "includes examples in groups matching filter" do
|
|
289
289
|
group = ExampleGroup.describe("does something", spec_metadata)
|
|
290
|
-
group.
|
|
290
|
+
allow(group).to receive(:world) { world }
|
|
291
291
|
all_examples = [ group.example("first"), group.example("second") ]
|
|
292
292
|
|
|
293
293
|
expect(group.filtered_examples).to eq(all_examples)
|
|
@@ -295,7 +295,7 @@ module RSpec::Core
|
|
|
295
295
|
|
|
296
296
|
it "includes examples directly matching filter" do
|
|
297
297
|
group = ExampleGroup.describe("does something")
|
|
298
|
-
group.
|
|
298
|
+
allow(group).to receive(:world) { world }
|
|
299
299
|
filtered_examples = [
|
|
300
300
|
group.example("first", spec_metadata),
|
|
301
301
|
group.example("second", spec_metadata)
|
|
@@ -310,12 +310,12 @@ module RSpec::Core
|
|
|
310
310
|
before do
|
|
311
311
|
filter_manager = FilterManager.new
|
|
312
312
|
filter_manager.exclude filter_metadata
|
|
313
|
-
world.
|
|
313
|
+
allow(world).to receive_messages(:filter_manager => filter_manager)
|
|
314
314
|
end
|
|
315
315
|
|
|
316
316
|
it "excludes examples in groups matching filter" do
|
|
317
317
|
group = ExampleGroup.describe("does something", spec_metadata)
|
|
318
|
-
group.
|
|
318
|
+
allow(group).to receive(:world) { world }
|
|
319
319
|
[ group.example("first"), group.example("second") ]
|
|
320
320
|
|
|
321
321
|
expect(group.filtered_examples).to be_empty
|
|
@@ -323,7 +323,7 @@ module RSpec::Core
|
|
|
323
323
|
|
|
324
324
|
it "excludes examples directly matching filter" do
|
|
325
325
|
group = ExampleGroup.describe("does something")
|
|
326
|
-
group.
|
|
326
|
+
allow(group).to receive(:world) { world }
|
|
327
327
|
[
|
|
328
328
|
group.example("first", spec_metadata),
|
|
329
329
|
group.example("second", spec_metadata)
|
|
@@ -404,7 +404,7 @@ module RSpec::Core
|
|
|
404
404
|
context "with no filters" do
|
|
405
405
|
it "returns all" do
|
|
406
406
|
group = ExampleGroup.describe
|
|
407
|
-
group.
|
|
407
|
+
allow(group).to receive(:world) { world }
|
|
408
408
|
example = group.example("does something")
|
|
409
409
|
expect(group.filtered_examples).to eq([example])
|
|
410
410
|
end
|
|
@@ -414,9 +414,9 @@ module RSpec::Core
|
|
|
414
414
|
it "returns none" do
|
|
415
415
|
filter_manager = FilterManager.new
|
|
416
416
|
filter_manager.include :awesome => false
|
|
417
|
-
world.
|
|
417
|
+
allow(world).to receive_messages(:filter_manager => filter_manager)
|
|
418
418
|
group = ExampleGroup.describe
|
|
419
|
-
group.
|
|
419
|
+
allow(group).to receive(:world) { world }
|
|
420
420
|
group.example("does something")
|
|
421
421
|
expect(group.filtered_examples).to eq([])
|
|
422
422
|
end
|
|
@@ -562,6 +562,52 @@ module RSpec::Core
|
|
|
562
562
|
end
|
|
563
563
|
|
|
564
564
|
describe "#before, after, and around hooks" do
|
|
565
|
+
describe "scope aliasing" do
|
|
566
|
+
it "aliases the `:context` hook scope to `:all` for before-hooks" do
|
|
567
|
+
group = ExampleGroup.describe
|
|
568
|
+
order = []
|
|
569
|
+
group.before(:context) { order << :before_context }
|
|
570
|
+
group.example("example") { order << :example }
|
|
571
|
+
group.example("example") { order << :example }
|
|
572
|
+
|
|
573
|
+
group.run
|
|
574
|
+
expect(order).to eq([:before_context, :example, :example])
|
|
575
|
+
end
|
|
576
|
+
|
|
577
|
+
it "aliases the `:example` hook scope to `:each` for before-hooks" do
|
|
578
|
+
group = ExampleGroup.describe
|
|
579
|
+
order = []
|
|
580
|
+
group.before(:example) { order << :before_example }
|
|
581
|
+
group.example("example") { order << :example }
|
|
582
|
+
group.example("example") { order << :example }
|
|
583
|
+
|
|
584
|
+
group.run
|
|
585
|
+
expect(order).to eq([:before_example, :example, :before_example, :example])
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
it "aliases the `:context` hook scope to `:all` for after-hooks" do
|
|
589
|
+
group = ExampleGroup.describe
|
|
590
|
+
order = []
|
|
591
|
+
group.example("example") { order << :example }
|
|
592
|
+
group.example("example") { order << :example }
|
|
593
|
+
group.after(:context) { order << :after_context }
|
|
594
|
+
|
|
595
|
+
group.run
|
|
596
|
+
expect(order).to eq([:example, :example, :after_context])
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
it "aliases the `:example` hook scope to `:each` for after-hooks" do
|
|
600
|
+
group = ExampleGroup.describe
|
|
601
|
+
order = []
|
|
602
|
+
group.example("example") { order << :example }
|
|
603
|
+
group.example("example") { order << :example }
|
|
604
|
+
group.after(:example) { order << :after_example }
|
|
605
|
+
|
|
606
|
+
group.run
|
|
607
|
+
expect(order).to eq([:example, :after_example, :example, :after_example])
|
|
608
|
+
end
|
|
609
|
+
end
|
|
610
|
+
|
|
565
611
|
it "runs the before alls in order" do
|
|
566
612
|
group = ExampleGroup.describe
|
|
567
613
|
order = []
|
|
@@ -792,7 +838,7 @@ module RSpec::Core
|
|
|
792
838
|
|
|
793
839
|
before(:each) do
|
|
794
840
|
hooks_run = []
|
|
795
|
-
RSpec.configuration.reporter.
|
|
841
|
+
allow(RSpec.configuration.reporter).to receive(:message)
|
|
796
842
|
end
|
|
797
843
|
|
|
798
844
|
let(:group) do
|
|
@@ -812,8 +858,8 @@ module RSpec::Core
|
|
|
812
858
|
end
|
|
813
859
|
|
|
814
860
|
it "rescues any error(s) and prints them out" do
|
|
815
|
-
RSpec.configuration.reporter.
|
|
816
|
-
RSpec.configuration.reporter.
|
|
861
|
+
expect(RSpec.configuration.reporter).to receive(:message).with(/An error in an after\(:all\) hook/)
|
|
862
|
+
expect(RSpec.configuration.reporter).to receive(:message).with(/A different hook raising an error/)
|
|
817
863
|
group.run
|
|
818
864
|
end
|
|
819
865
|
|
|
@@ -842,30 +888,198 @@ module RSpec::Core
|
|
|
842
888
|
end
|
|
843
889
|
end
|
|
844
890
|
|
|
845
|
-
|
|
846
|
-
describe
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
891
|
+
describe ".pending" do
|
|
892
|
+
let(:group) { ExampleGroup.describe { pending { fail } } }
|
|
893
|
+
|
|
894
|
+
it "generates a pending example" do
|
|
895
|
+
group.run
|
|
896
|
+
expect(group.examples.first).to be_pending
|
|
897
|
+
end
|
|
898
|
+
|
|
899
|
+
it "sets the pending message" do
|
|
900
|
+
group.run
|
|
901
|
+
expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq(RSpec::Core::Pending::NO_REASON_GIVEN)
|
|
902
|
+
end
|
|
903
|
+
end
|
|
904
|
+
|
|
905
|
+
describe "pending with metadata" do
|
|
906
|
+
let(:group) { ExampleGroup.describe {
|
|
907
|
+
example("unimplemented", :pending => true) { fail }
|
|
908
|
+
} }
|
|
909
|
+
|
|
910
|
+
it "generates a pending example" do
|
|
911
|
+
group.run
|
|
912
|
+
expect(group.examples.first).to be_pending
|
|
913
|
+
end
|
|
914
|
+
|
|
915
|
+
it "sets the pending message" do
|
|
916
|
+
group.run
|
|
917
|
+
expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq(RSpec::Core::Pending::NO_REASON_GIVEN)
|
|
918
|
+
end
|
|
919
|
+
end
|
|
920
|
+
|
|
921
|
+
describe "pending with message in metadata" do
|
|
922
|
+
let(:group) { ExampleGroup.describe {
|
|
923
|
+
example("unimplemented", :pending => 'not done') { fail }
|
|
924
|
+
} }
|
|
925
|
+
|
|
926
|
+
it "generates a pending example" do
|
|
927
|
+
group.run
|
|
928
|
+
expect(group.examples.first).to be_pending
|
|
929
|
+
end
|
|
930
|
+
|
|
931
|
+
it "sets the pending message" do
|
|
932
|
+
group.run
|
|
933
|
+
expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq("not done")
|
|
934
|
+
end
|
|
935
|
+
end
|
|
936
|
+
|
|
937
|
+
describe ".skip" do
|
|
938
|
+
let(:group) { ExampleGroup.describe { skip("skip this") { } } }
|
|
939
|
+
|
|
940
|
+
it "generates a skipped example" do
|
|
941
|
+
group.run
|
|
942
|
+
expect(group.examples.first).to be_skipped
|
|
943
|
+
end
|
|
944
|
+
|
|
945
|
+
it "sets the pending message" do
|
|
946
|
+
group.run
|
|
947
|
+
expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq(RSpec::Core::Pending::NO_REASON_GIVEN)
|
|
948
|
+
end
|
|
949
|
+
end
|
|
950
|
+
|
|
951
|
+
describe "skip with metadata" do
|
|
952
|
+
let(:group) { ExampleGroup.describe {
|
|
953
|
+
example("skip this", :skip => true) { }
|
|
954
|
+
} }
|
|
955
|
+
|
|
956
|
+
it "generates a skipped example" do
|
|
957
|
+
group.run
|
|
958
|
+
expect(group.examples.first).to be_skipped
|
|
959
|
+
end
|
|
960
|
+
|
|
961
|
+
it "sets the pending message" do
|
|
962
|
+
group.run
|
|
963
|
+
expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq(RSpec::Core::Pending::NO_REASON_GIVEN)
|
|
964
|
+
end
|
|
965
|
+
end
|
|
966
|
+
|
|
967
|
+
describe "skip with message in metadata" do
|
|
968
|
+
let(:group) { ExampleGroup.describe {
|
|
969
|
+
example("skip this", :skip => 'not done') { }
|
|
970
|
+
} }
|
|
971
|
+
|
|
972
|
+
it "generates a skipped example" do
|
|
973
|
+
group.run
|
|
974
|
+
expect(group.examples.first).to be_skipped
|
|
975
|
+
end
|
|
976
|
+
|
|
977
|
+
it "sets the pending message" do
|
|
978
|
+
group.run
|
|
979
|
+
expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq('not done')
|
|
980
|
+
end
|
|
981
|
+
end
|
|
982
|
+
|
|
983
|
+
%w[xit xspecify xexample].each do |method_name|
|
|
984
|
+
describe ".#{method_name}" do
|
|
985
|
+
let(:group) { ExampleGroup.describe.tap {|x|
|
|
986
|
+
x.send(method_name, "is pending") { }
|
|
987
|
+
}}
|
|
988
|
+
|
|
989
|
+
it "generates a skipped example" do
|
|
990
|
+
group.run
|
|
991
|
+
expect(group.examples.first).to be_skipped
|
|
850
992
|
end
|
|
851
993
|
|
|
852
|
-
it "
|
|
853
|
-
|
|
854
|
-
expect(
|
|
994
|
+
it "sets the pending message" do
|
|
995
|
+
group.run
|
|
996
|
+
expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq("Temporarily skipped with #{method_name}")
|
|
855
997
|
end
|
|
998
|
+
end
|
|
999
|
+
end
|
|
856
1000
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
1001
|
+
%w[ xdescribe xcontext ].each do |method_name|
|
|
1002
|
+
describe ".#{method_name}" do
|
|
1003
|
+
def extract_execution_results(group)
|
|
1004
|
+
group.examples.map do |ex|
|
|
1005
|
+
ex.metadata.fetch(:execution_result)
|
|
1006
|
+
end
|
|
860
1007
|
end
|
|
861
1008
|
|
|
862
|
-
it
|
|
863
|
-
|
|
864
|
-
|
|
1009
|
+
it 'generates a pending example group' do
|
|
1010
|
+
group = ExampleGroup.send(method_name) do
|
|
1011
|
+
it("passes") { }
|
|
1012
|
+
it("fails") { expect(2).to eq(3) }
|
|
1013
|
+
end
|
|
1014
|
+
group.run
|
|
1015
|
+
|
|
1016
|
+
expect(extract_execution_results(group)).to match([
|
|
1017
|
+
a_hash_including(
|
|
1018
|
+
:status => "pending",
|
|
1019
|
+
:pending_message => "Temporarily skipped with #{method_name}"
|
|
1020
|
+
)
|
|
1021
|
+
] * 2)
|
|
865
1022
|
end
|
|
866
1023
|
end
|
|
867
1024
|
end
|
|
868
1025
|
|
|
1026
|
+
%w[ fdescribe fcontext ].each do |method_name|
|
|
1027
|
+
describe ".#{method_name}" do
|
|
1028
|
+
def executed_examples_of(group)
|
|
1029
|
+
examples = group.examples.select { |ex| ex.metadata[:execution_result][:started_at] }
|
|
1030
|
+
group.children.inject(examples) { |exs, child| exs + executed_examples_of(child) }
|
|
1031
|
+
end
|
|
1032
|
+
|
|
1033
|
+
[:focus, :focused].each do |metadata|
|
|
1034
|
+
it "generates an example group that can be filtered with :#{metadata}" do
|
|
1035
|
+
RSpec.configuration.filter_run metadata
|
|
1036
|
+
|
|
1037
|
+
parent_group = ExampleGroup.describe do
|
|
1038
|
+
describe "not focused" do
|
|
1039
|
+
example("not focused example") { }
|
|
1040
|
+
end
|
|
1041
|
+
|
|
1042
|
+
send(method_name, "focused") do
|
|
1043
|
+
example("focused example") { }
|
|
1044
|
+
end
|
|
1045
|
+
end
|
|
1046
|
+
|
|
1047
|
+
parent_group.run
|
|
1048
|
+
|
|
1049
|
+
executed_descriptions = executed_examples_of(parent_group).map(&:description)
|
|
1050
|
+
expect(executed_descriptions).to eq(["focused example"])
|
|
1051
|
+
end
|
|
1052
|
+
end
|
|
1053
|
+
end
|
|
1054
|
+
end
|
|
1055
|
+
|
|
1056
|
+
describe "setting pending metadata in parent" do
|
|
1057
|
+
def extract_execution_results(group)
|
|
1058
|
+
group.examples.map do |ex|
|
|
1059
|
+
ex.metadata.fetch(:execution_result)
|
|
1060
|
+
end
|
|
1061
|
+
end
|
|
1062
|
+
|
|
1063
|
+
it 'marks every example as pending' do
|
|
1064
|
+
group = ExampleGroup.describe(:pending => true) do
|
|
1065
|
+
it("passes") { }
|
|
1066
|
+
it("fails", :pending => 'unimplemented') { fail }
|
|
1067
|
+
end
|
|
1068
|
+
group.run
|
|
1069
|
+
|
|
1070
|
+
expect(extract_execution_results(group)).to match([
|
|
1071
|
+
a_hash_including(
|
|
1072
|
+
:status => "failed",
|
|
1073
|
+
:pending_message => "No reason given"
|
|
1074
|
+
),
|
|
1075
|
+
a_hash_including(
|
|
1076
|
+
:status => "pending",
|
|
1077
|
+
:pending_message => "unimplemented"
|
|
1078
|
+
)
|
|
1079
|
+
])
|
|
1080
|
+
end
|
|
1081
|
+
end
|
|
1082
|
+
|
|
869
1083
|
describe "adding examples" do
|
|
870
1084
|
|
|
871
1085
|
it "allows adding an example using 'it'" do
|
|
@@ -925,7 +1139,7 @@ module RSpec::Core
|
|
|
925
1139
|
example('ex 1') { expect(1).to eq(1) }
|
|
926
1140
|
example('ex 2') { expect(1).to eq(1) }
|
|
927
1141
|
end
|
|
928
|
-
group.
|
|
1142
|
+
allow(group).to receive(:filtered_examples) { group.examples }
|
|
929
1143
|
expect(group.run(reporter)).to be_truthy
|
|
930
1144
|
end
|
|
931
1145
|
|
|
@@ -934,7 +1148,7 @@ module RSpec::Core
|
|
|
934
1148
|
example('ex 1') { expect(1).to eq(1) }
|
|
935
1149
|
example('ex 2') { expect(1).to eq(2) }
|
|
936
1150
|
end
|
|
937
|
-
group.
|
|
1151
|
+
allow(group).to receive(:filtered_examples) { group.examples }
|
|
938
1152
|
expect(group.run(reporter)).to be_falsey
|
|
939
1153
|
end
|
|
940
1154
|
|
|
@@ -943,9 +1157,9 @@ module RSpec::Core
|
|
|
943
1157
|
example('ex 1') { expect(1).to eq(2) }
|
|
944
1158
|
example('ex 2') { expect(1).to eq(1) }
|
|
945
1159
|
end
|
|
946
|
-
group.
|
|
1160
|
+
allow(group).to receive(:filtered_examples) { group.examples }
|
|
947
1161
|
group.filtered_examples.each do |example|
|
|
948
|
-
example.
|
|
1162
|
+
expect(example).to receive(:run)
|
|
949
1163
|
end
|
|
950
1164
|
expect(group.run(reporter)).to be_falsey
|
|
951
1165
|
end
|
|
@@ -1031,7 +1245,7 @@ module RSpec::Core
|
|
|
1031
1245
|
context "with fail_fast? => true" do
|
|
1032
1246
|
let(:group) do
|
|
1033
1247
|
group = RSpec::Core::ExampleGroup.describe
|
|
1034
|
-
group.
|
|
1248
|
+
allow(group).to receive(:fail_fast?) { true }
|
|
1035
1249
|
group
|
|
1036
1250
|
end
|
|
1037
1251
|
|
|
@@ -1058,18 +1272,18 @@ module RSpec::Core
|
|
|
1058
1272
|
let(:group) { RSpec::Core::ExampleGroup.describe }
|
|
1059
1273
|
|
|
1060
1274
|
before do
|
|
1061
|
-
RSpec.
|
|
1062
|
-
RSpec.
|
|
1275
|
+
allow(RSpec).to receive(:wants_to_quit) { true }
|
|
1276
|
+
allow(RSpec).to receive(:clear_remaining_example_groups)
|
|
1063
1277
|
end
|
|
1064
1278
|
|
|
1065
1279
|
it "returns without starting the group" do
|
|
1066
|
-
reporter.
|
|
1280
|
+
expect(reporter).not_to receive(:example_group_started)
|
|
1067
1281
|
group.run(reporter)
|
|
1068
1282
|
end
|
|
1069
1283
|
|
|
1070
1284
|
context "at top level" do
|
|
1071
1285
|
it "purges remaining groups" do
|
|
1072
|
-
RSpec.
|
|
1286
|
+
expect(RSpec).to receive(:clear_remaining_example_groups)
|
|
1073
1287
|
group.run(reporter)
|
|
1074
1288
|
end
|
|
1075
1289
|
end
|
|
@@ -1077,7 +1291,7 @@ module RSpec::Core
|
|
|
1077
1291
|
context "in a nested group" do
|
|
1078
1292
|
it "does not purge remaining groups" do
|
|
1079
1293
|
nested_group = group.describe
|
|
1080
|
-
RSpec.
|
|
1294
|
+
expect(RSpec).not_to receive(:clear_remaining_example_groups)
|
|
1081
1295
|
nested_group.run(reporter)
|
|
1082
1296
|
end
|
|
1083
1297
|
end
|