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,40 +1,38 @@
|
|
|
1
1
|
# Deliberately named _specs.rb to avoid being loaded except when specified
|
|
2
2
|
|
|
3
|
-
describe "pending spec with no implementation" do
|
|
3
|
+
RSpec.describe "pending spec with no implementation" do
|
|
4
4
|
it "is pending"
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
describe "pending command with block format" do
|
|
7
|
+
RSpec.describe "pending command with block format" do
|
|
8
8
|
context "with content that would fail" do
|
|
9
9
|
it "is pending" do
|
|
10
|
-
pending
|
|
11
|
-
|
|
12
|
-
end
|
|
10
|
+
pending
|
|
11
|
+
expect(1).to eq(2)
|
|
13
12
|
end
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
context "with content that would pass" do
|
|
17
16
|
it "fails" do
|
|
18
|
-
pending
|
|
19
|
-
|
|
20
|
-
end
|
|
17
|
+
pending
|
|
18
|
+
expect(1).to eq(1)
|
|
21
19
|
end
|
|
22
20
|
end
|
|
23
21
|
end
|
|
24
22
|
|
|
25
|
-
describe "passing spec" do
|
|
23
|
+
RSpec.describe "passing spec" do
|
|
26
24
|
it "passes" do
|
|
27
25
|
expect(1).to eq(1)
|
|
28
26
|
end
|
|
29
27
|
end
|
|
30
28
|
|
|
31
|
-
describe "failing spec" do
|
|
29
|
+
RSpec.describe "failing spec" do
|
|
32
30
|
it "fails" do
|
|
33
31
|
expect(1).to eq(2)
|
|
34
32
|
end
|
|
35
33
|
end
|
|
36
34
|
|
|
37
|
-
describe "a failing spec with odd backtraces" do
|
|
35
|
+
RSpec.describe "a failing spec with odd backtraces" do
|
|
38
36
|
it "fails with a backtrace that has no file" do
|
|
39
37
|
require 'erb'
|
|
40
38
|
|
|
@@ -14,7 +14,7 @@ module RSpec::Matchers
|
|
|
14
14
|
c.include ModThatIncludesMatchers, :include_mod_that_includes_rspec_matchers => true
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
describe self do
|
|
17
|
+
RSpec.describe self do
|
|
18
18
|
shared_examples_for "a normal module with a method that supers" do
|
|
19
19
|
it "raises the expected error (and not SystemStackError)" do
|
|
20
20
|
expect { __method_with_super }.to raise_error(NoMethodError) # there is no __method_with_super in an ancestor
|
|
@@ -2,20 +2,20 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
module RSpec
|
|
4
4
|
module Core
|
|
5
|
-
describe RubyProject do
|
|
5
|
+
RSpec.describe RubyProject do
|
|
6
6
|
|
|
7
7
|
describe "#determine_root" do
|
|
8
8
|
|
|
9
9
|
context "with ancestor containing spec directory" do
|
|
10
10
|
it "returns ancestor containing the spec directory" do
|
|
11
|
-
RubyProject.
|
|
11
|
+
allow(RubyProject).to receive(:ascend_until).and_return('foodir')
|
|
12
12
|
expect(RubyProject.determine_root).to eq("foodir")
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
context "without ancestor containing spec directory" do
|
|
17
17
|
it "returns current working directory" do
|
|
18
|
-
RubyProject.
|
|
18
|
+
allow(RubyProject).to receive(:find_first_parent_containing).and_return(nil)
|
|
19
19
|
expect(RubyProject.determine_root).to eq(".")
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -2,27 +2,47 @@ require 'spec_helper'
|
|
|
2
2
|
require 'rspec/core/drb_command_line'
|
|
3
3
|
|
|
4
4
|
module RSpec::Core
|
|
5
|
-
describe Runner do
|
|
5
|
+
RSpec.describe Runner do
|
|
6
|
+
describe 'invocation' do
|
|
7
|
+
before do
|
|
8
|
+
# Simulate invoking the suite like exe/rspec does.
|
|
9
|
+
allow(RSpec::Core::Runner).to receive(:run)
|
|
10
|
+
RSpec::Core::Runner.invoke
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'does not autorun after having been invoked' do
|
|
14
|
+
expect(RSpec::Core::Runner).not_to receive(:at_exit)
|
|
15
|
+
RSpec::Core::Runner.autorun
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'prints a warning when autorun is attempted' do
|
|
19
|
+
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
|
|
20
|
+
RSpec::Core::Runner.autorun
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
6
24
|
describe 'at_exit' do
|
|
7
25
|
it 'sets an at_exit hook if none is already set' do
|
|
8
|
-
RSpec::Core::Runner.
|
|
9
|
-
RSpec::Core::Runner.
|
|
10
|
-
RSpec::Core::Runner.
|
|
11
|
-
RSpec::Core::Runner.
|
|
12
|
-
RSpec::Core::Runner.
|
|
26
|
+
allow(RSpec::Core::Runner).to receive(:autorun_disabled?).and_return(false)
|
|
27
|
+
allow(RSpec::Core::Runner).to receive(:installed_at_exit?).and_return(false)
|
|
28
|
+
allow(RSpec::Core::Runner).to receive(:running_in_drb?).and_return(false)
|
|
29
|
+
allow(RSpec::Core::Runner).to receive(:invoke)
|
|
30
|
+
expect(RSpec::Core::Runner).to receive(:at_exit)
|
|
13
31
|
RSpec::Core::Runner.autorun
|
|
14
32
|
end
|
|
15
33
|
|
|
16
34
|
it 'does not set the at_exit hook if it is already set' do
|
|
17
|
-
RSpec::Core::Runner.
|
|
18
|
-
RSpec::Core::Runner.
|
|
19
|
-
RSpec::Core::Runner.
|
|
20
|
-
RSpec::Core::Runner.
|
|
35
|
+
allow(RSpec::Core::Runner).to receive(:autorun_disabled?).and_return(false)
|
|
36
|
+
allow(RSpec::Core::Runner).to receive(:installed_at_exit?).and_return(true)
|
|
37
|
+
allow(RSpec::Core::Runner).to receive(:running_in_drb?).and_return(false)
|
|
38
|
+
expect(RSpec::Core::Runner).to receive(:at_exit).never
|
|
21
39
|
RSpec::Core::Runner.autorun
|
|
22
40
|
end
|
|
23
41
|
end
|
|
24
42
|
|
|
25
|
-
|
|
43
|
+
# This is intermittently slow because this method calls out to the network
|
|
44
|
+
# interface.
|
|
45
|
+
describe "#running_in_drb?", :slow do
|
|
26
46
|
it "returns true if drb server is started with 127.0.0.1" do
|
|
27
47
|
allow(::DRb).to receive(:current_server).and_return(double(:uri => "druby://127.0.0.1:0000/"))
|
|
28
48
|
|
|
@@ -43,27 +63,49 @@ module RSpec::Core
|
|
|
43
63
|
end
|
|
44
64
|
|
|
45
65
|
it "returns false if no drb server is running" do
|
|
46
|
-
::DRb.
|
|
66
|
+
allow(::DRb).to receive(:current_server).and_raise(::DRb::DRbServerNotFound)
|
|
47
67
|
|
|
48
68
|
expect(RSpec::Core::Runner.running_in_drb?).to be_falsey
|
|
49
69
|
end
|
|
50
70
|
end
|
|
51
71
|
|
|
72
|
+
describe "#invoke" do
|
|
73
|
+
let(:runner) { RSpec::Core::Runner }
|
|
74
|
+
|
|
75
|
+
it "runs the specs via #run" do
|
|
76
|
+
allow(runner).to receive(:exit)
|
|
77
|
+
expect(runner).to receive(:run)
|
|
78
|
+
runner.invoke
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "doesn't exit on success" do
|
|
82
|
+
allow(runner).to receive(:run) { 0 }
|
|
83
|
+
expect(runner).to_not receive(:exit)
|
|
84
|
+
runner.invoke
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "exits with #run's status on failure" do
|
|
88
|
+
allow(runner).to receive(:run) { 123 }
|
|
89
|
+
expect(runner).to receive(:exit).with(123)
|
|
90
|
+
runner.invoke
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
52
94
|
describe "#run" do
|
|
53
95
|
let(:err) { StringIO.new }
|
|
54
96
|
let(:out) { StringIO.new }
|
|
55
97
|
|
|
56
98
|
it "tells RSpec to reset" do
|
|
57
|
-
CommandLine.
|
|
58
|
-
RSpec.configuration.
|
|
59
|
-
RSpec.
|
|
99
|
+
allow(CommandLine).to receive_messages(:new => double.as_null_object)
|
|
100
|
+
allow(RSpec.configuration).to receive_messages(:files_to_run => [], :warn => nil)
|
|
101
|
+
expect(RSpec).to receive(:reset)
|
|
60
102
|
RSpec::Core::Runner.run([], err, out)
|
|
61
103
|
end
|
|
62
104
|
|
|
63
105
|
context "with --drb or -X" do
|
|
64
106
|
before(:each) do
|
|
65
107
|
@options = RSpec::Core::ConfigurationOptions.new(%w[--drb --drb-port 8181 --color])
|
|
66
|
-
RSpec::Core::ConfigurationOptions.
|
|
108
|
+
allow(RSpec::Core::ConfigurationOptions).to receive(:new) { @options }
|
|
67
109
|
end
|
|
68
110
|
|
|
69
111
|
def run_specs
|
|
@@ -73,9 +115,9 @@ module RSpec::Core
|
|
|
73
115
|
context 'and a DRb server is running' do
|
|
74
116
|
it "builds a DRbCommandLine and runs the specs" do
|
|
75
117
|
drb_proxy = double(RSpec::Core::DRbCommandLine, :run => true)
|
|
76
|
-
drb_proxy.
|
|
118
|
+
expect(drb_proxy).to receive(:run).with(err, out)
|
|
77
119
|
|
|
78
|
-
RSpec::Core::DRbCommandLine.
|
|
120
|
+
expect(RSpec::Core::DRbCommandLine).to receive(:new).and_return(drb_proxy)
|
|
79
121
|
|
|
80
122
|
run_specs
|
|
81
123
|
end
|
|
@@ -83,12 +125,12 @@ module RSpec::Core
|
|
|
83
125
|
|
|
84
126
|
context 'and a DRb server is not running' do
|
|
85
127
|
before(:each) do
|
|
86
|
-
RSpec::Core::DRbCommandLine.
|
|
128
|
+
expect(RSpec::Core::DRbCommandLine).to receive(:new).and_raise(DRb::DRbConnError)
|
|
87
129
|
end
|
|
88
130
|
|
|
89
131
|
it "outputs a message" do
|
|
90
|
-
RSpec.configuration.
|
|
91
|
-
err.
|
|
132
|
+
allow(RSpec.configuration).to receive(:files_to_run) { [] }
|
|
133
|
+
expect(err).to receive(:puts).with(
|
|
92
134
|
"No DRb server is running. Running in local process instead ..."
|
|
93
135
|
)
|
|
94
136
|
run_specs
|
|
@@ -96,9 +138,9 @@ module RSpec::Core
|
|
|
96
138
|
|
|
97
139
|
it "builds a CommandLine and runs the specs" do
|
|
98
140
|
process_proxy = double(RSpec::Core::CommandLine, :run => 0)
|
|
99
|
-
process_proxy.
|
|
141
|
+
expect(process_proxy).to receive(:run).with(err, out)
|
|
100
142
|
|
|
101
|
-
RSpec::Core::CommandLine.
|
|
143
|
+
expect(RSpec::Core::CommandLine).to receive(:new).and_return(process_proxy)
|
|
102
144
|
|
|
103
145
|
run_specs
|
|
104
146
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
|
-
describe RSpec::SharedContext do
|
|
3
|
+
RSpec.describe RSpec::SharedContext do
|
|
4
4
|
it "is accessible as RSpec::Core::SharedContext" do
|
|
5
5
|
RSpec::Core::SharedContext
|
|
6
6
|
end
|
|
@@ -42,11 +42,11 @@ describe RSpec::SharedContext do
|
|
|
42
42
|
c.before(:each) { ordered_hooks << "config" }
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
shared_context("before each stuff", :example => :before_each_hook_order) do
|
|
45
|
+
RSpec.shared_context("before each stuff", :example => :before_each_hook_order) do
|
|
46
46
|
before(:each) { ordered_hooks << "shared_context"}
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
group = RSpec
|
|
49
|
+
group = RSpec.describe :example => :before_each_hook_order do
|
|
50
50
|
before(:each) { ordered_hooks << "example_group" }
|
|
51
51
|
example {}
|
|
52
52
|
end
|
|
@@ -61,7 +61,7 @@ describe RSpec::SharedContext do
|
|
|
61
61
|
extend RSpec::SharedContext
|
|
62
62
|
let(:foo) { 'foo' }
|
|
63
63
|
end
|
|
64
|
-
group = RSpec
|
|
64
|
+
group = RSpec.describe do
|
|
65
65
|
include shared
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
+
require 'rspec/support/spec/in_sub_process'
|
|
2
3
|
|
|
3
4
|
module RandomTopLevelModule
|
|
4
5
|
def self.setup!
|
|
5
|
-
shared_examples_for("top level in module") {}
|
|
6
|
+
RSpec.shared_examples_for("top level in module") {}
|
|
6
7
|
end
|
|
7
8
|
end
|
|
8
9
|
|
|
9
10
|
module RSpec::Core
|
|
10
|
-
describe SharedExampleGroup do
|
|
11
|
+
RSpec.describe SharedExampleGroup do
|
|
12
|
+
include RSpec::Support::InSubProcess
|
|
11
13
|
|
|
12
14
|
ExampleModule = Module.new
|
|
13
15
|
ExampleClass = Class.new
|
|
@@ -18,7 +20,7 @@ module RSpec::Core
|
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
module SharedExampleGroup
|
|
21
|
-
describe Registry do
|
|
23
|
+
RSpec.describe Registry do
|
|
22
24
|
it "can safely be reset when there aren't any shared groups" do
|
|
23
25
|
expect { Registry.new.clear }.to_not raise_error
|
|
24
26
|
end
|
|
@@ -38,8 +40,15 @@ module RSpec::Core
|
|
|
38
40
|
group.send(shared_method_name, *args, &block)
|
|
39
41
|
end
|
|
40
42
|
|
|
41
|
-
it "is exposed to the global namespace" do
|
|
42
|
-
|
|
43
|
+
it "is exposed to the global namespace when expose_dsl_globally is enabled" do
|
|
44
|
+
in_sub_process do
|
|
45
|
+
RSpec.configuration.expose_dsl_globally = true
|
|
46
|
+
expect(Kernel).to respond_to(shared_method_name)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "is not exposed to the global namespace when monkey patching is disabled" do
|
|
51
|
+
expect(Kernel).to_not respond_to(shared_method_name)
|
|
43
52
|
end
|
|
44
53
|
|
|
45
54
|
it "displays a warning when adding a second shared example group with the same name" do
|
|
@@ -72,12 +81,12 @@ module RSpec::Core
|
|
|
72
81
|
end
|
|
73
82
|
|
|
74
83
|
context "given a hash" do
|
|
75
|
-
it "delegates
|
|
84
|
+
it "delegates include on configuration" do
|
|
76
85
|
implementation = Proc.new { def bar; 'bar'; end }
|
|
77
86
|
define_shared_group(:foo => :bar, &implementation)
|
|
78
87
|
a = RSpec.configuration.include_or_extend_modules.first
|
|
79
|
-
expect(a[0]).to eq(:
|
|
80
|
-
expect(Class.new.
|
|
88
|
+
expect(a[0]).to eq(:include)
|
|
89
|
+
expect(Class.new.send(:include, a[1]).new.bar).to eq('bar')
|
|
81
90
|
expect(a[2]).to eq(:foo => :bar)
|
|
82
91
|
end
|
|
83
92
|
end
|
|
@@ -89,12 +98,12 @@ module RSpec::Core
|
|
|
89
98
|
expect(SharedExampleGroup.registry.shared_example_groups[group]["name"]).to eq implementation
|
|
90
99
|
end
|
|
91
100
|
|
|
92
|
-
it "delegates
|
|
101
|
+
it "delegates include on configuration" do
|
|
93
102
|
implementation = Proc.new { def bar; 'bar'; end }
|
|
94
103
|
define_shared_group("name", :foo => :bar, &implementation)
|
|
95
104
|
a = RSpec.configuration.include_or_extend_modules.first
|
|
96
|
-
expect(a[0]).to eq(:
|
|
97
|
-
expect(Class.new.
|
|
105
|
+
expect(a[0]).to eq(:include)
|
|
106
|
+
expect(Class.new.send(:include, a[1]).new.bar).to eq('bar')
|
|
98
107
|
expect(a[2]).to eq(:foo => :bar)
|
|
99
108
|
end
|
|
100
109
|
end
|
|
@@ -5,7 +5,7 @@ class Foo; end
|
|
|
5
5
|
|
|
6
6
|
module RSpec::Core
|
|
7
7
|
|
|
8
|
-
describe RSpec::Core::World do
|
|
8
|
+
RSpec.describe RSpec::Core::World do
|
|
9
9
|
let(:configuration) { RSpec::Core::Configuration.new }
|
|
10
10
|
let(:world) { RSpec::Core::World.new(configuration) }
|
|
11
11
|
|
|
@@ -85,14 +85,14 @@ module RSpec::Core
|
|
|
85
85
|
|
|
86
86
|
describe "#announce_filters" do
|
|
87
87
|
let(:reporter) { double('reporter').as_null_object }
|
|
88
|
-
before { world.
|
|
88
|
+
before { allow(world).to receive(:reporter) { reporter } }
|
|
89
89
|
|
|
90
90
|
context "with no examples" do
|
|
91
|
-
before { world.
|
|
91
|
+
before { allow(world).to receive(:example_count) { 0 } }
|
|
92
92
|
|
|
93
93
|
context "with no filters" do
|
|
94
94
|
it "announces" do
|
|
95
|
-
reporter.
|
|
95
|
+
expect(reporter).to receive(:message).
|
|
96
96
|
with("No examples found.")
|
|
97
97
|
world.announce_filters
|
|
98
98
|
end
|
|
@@ -101,7 +101,7 @@ module RSpec::Core
|
|
|
101
101
|
context "with an inclusion filter" do
|
|
102
102
|
it "announces" do
|
|
103
103
|
configuration.filter_run_including :foo => 'bar'
|
|
104
|
-
reporter.
|
|
104
|
+
expect(reporter).to receive(:message).
|
|
105
105
|
with(/All examples were filtered out/)
|
|
106
106
|
world.announce_filters
|
|
107
107
|
end
|
|
@@ -109,9 +109,9 @@ module RSpec::Core
|
|
|
109
109
|
|
|
110
110
|
context "with an inclusion filter and run_all_when_everything_filtered" do
|
|
111
111
|
it "announces" do
|
|
112
|
-
configuration.
|
|
112
|
+
allow(configuration).to receive(:run_all_when_everything_filtered?) { true }
|
|
113
113
|
configuration.filter_run_including :foo => 'bar'
|
|
114
|
-
reporter.
|
|
114
|
+
expect(reporter).to receive(:message).
|
|
115
115
|
with(/All examples were filtered out/)
|
|
116
116
|
world.announce_filters
|
|
117
117
|
end
|
|
@@ -120,7 +120,7 @@ module RSpec::Core
|
|
|
120
120
|
context "with an exclusion filter" do
|
|
121
121
|
it "announces" do
|
|
122
122
|
configuration.filter_run_excluding :foo => 'bar'
|
|
123
|
-
reporter.
|
|
123
|
+
expect(reporter).to receive(:message).
|
|
124
124
|
with(/All examples were filtered out/)
|
|
125
125
|
world.announce_filters
|
|
126
126
|
end
|
|
@@ -128,11 +128,11 @@ module RSpec::Core
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
context "with examples" do
|
|
131
|
-
before { world.
|
|
131
|
+
before { allow(world).to receive(:example_count) { 1 } }
|
|
132
132
|
|
|
133
133
|
context "with no filters" do
|
|
134
134
|
it "does not announce" do
|
|
135
|
-
reporter.
|
|
135
|
+
expect(reporter).not_to receive(:message)
|
|
136
136
|
world.announce_filters
|
|
137
137
|
end
|
|
138
138
|
end
|
data/spec/rspec/core_spec.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe RSpec do
|
|
3
|
+
RSpec.describe RSpec do
|
|
4
4
|
describe "::configuration" do
|
|
5
5
|
it "returns the same object every time" do
|
|
6
6
|
expect(RSpec.configuration).to equal(RSpec.configuration)
|
|
@@ -72,7 +72,7 @@ describe RSpec do
|
|
|
72
72
|
|
|
73
73
|
# This is hard to test :(. Best way I could come up with was starting
|
|
74
74
|
# fresh ruby process w/o this stuff already loaded.
|
|
75
|
-
it "loads mocks and expectations when the constants are referenced" do
|
|
75
|
+
it "loads mocks and expectations when the constants are referenced", :slow do
|
|
76
76
|
code = "$LOAD_PATH.replace(#{$LOAD_PATH.inspect}); " +
|
|
77
77
|
'require "rspec"; ' +
|
|
78
78
|
"puts RSpec::Mocks.name; " +
|
data/spec/spec_helper.rb
CHANGED
|
@@ -15,18 +15,14 @@ rescue LoadError
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
Spork.prefork do
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
add_filter '/spec/'
|
|
25
|
-
add_filter '/tmp/'
|
|
18
|
+
require 'rspec/support/spec'
|
|
19
|
+
|
|
20
|
+
module ArubaLoader
|
|
21
|
+
extend RSpec::Support::WithIsolatedStdErr
|
|
22
|
+
with_isolated_stderr do
|
|
23
|
+
require 'aruba/api'
|
|
26
24
|
end
|
|
27
25
|
end
|
|
28
|
-
require 'aruba/api'
|
|
29
|
-
$VERBOSE = old_verbose
|
|
30
26
|
|
|
31
27
|
if RUBY_PLATFORM == 'java'
|
|
32
28
|
# Works around https://jira.codehaus.org/browse/JRUBY-5678
|
|
@@ -49,8 +45,6 @@ Spork.prefork do
|
|
|
49
45
|
|
|
50
46
|
Dir['./spec/support/**/*.rb'].map {|f| require f}
|
|
51
47
|
|
|
52
|
-
$stderr = RSpec::StdErrSplitter.new
|
|
53
|
-
|
|
54
48
|
class NullObject
|
|
55
49
|
private
|
|
56
50
|
def method_missing(method, *args, &block)
|
|
@@ -64,6 +58,7 @@ Spork.prefork do
|
|
|
64
58
|
@orig_world = RSpec.world
|
|
65
59
|
@orig_example = RSpec.current_example
|
|
66
60
|
new_config = RSpec::Core::Configuration.new
|
|
61
|
+
new_config.expose_dsl_globally = false
|
|
67
62
|
new_world = RSpec::Core::World.new(new_config)
|
|
68
63
|
RSpec.configuration = new_config
|
|
69
64
|
RSpec.world = new_world
|
|
@@ -78,7 +73,7 @@ Spork.prefork do
|
|
|
78
73
|
end
|
|
79
74
|
end
|
|
80
75
|
|
|
81
|
-
RSpec::
|
|
76
|
+
RSpec::Mocks.with_temporary_scope do
|
|
82
77
|
object.instance_eval(&block)
|
|
83
78
|
end
|
|
84
79
|
ensure
|
|
@@ -122,8 +117,6 @@ Spork.prefork do
|
|
|
122
117
|
end
|
|
123
118
|
end
|
|
124
119
|
|
|
125
|
-
require 'rspec/support/spec'
|
|
126
|
-
|
|
127
120
|
RSpec.configure do |c|
|
|
128
121
|
# structural
|
|
129
122
|
c.alias_it_behaves_like_to 'it_has_behavior'
|
|
@@ -133,22 +126,17 @@ Spork.prefork do
|
|
|
133
126
|
:file_path => /spec\/command_line/
|
|
134
127
|
}
|
|
135
128
|
|
|
136
|
-
# Use the doc formatter when running individual files.
|
|
137
|
-
# This is too verbose when running all spec files but
|
|
138
|
-
# is nice for a single file.
|
|
139
|
-
if c.files_to_run.one? && c.formatters.none?
|
|
140
|
-
c.formatter = 'doc'
|
|
141
|
-
end
|
|
142
|
-
|
|
143
129
|
c.expect_with :rspec do |expectations|
|
|
144
130
|
expectations.syntax = :expect
|
|
145
131
|
end
|
|
146
132
|
|
|
133
|
+
c.mock_with :rspec do |mocks|
|
|
134
|
+
mocks.syntax = :expect
|
|
135
|
+
end
|
|
136
|
+
|
|
147
137
|
# runtime options
|
|
148
138
|
c.color = !in_editor?
|
|
149
|
-
c.filter_run :focus
|
|
150
139
|
c.include EnvHelpers
|
|
151
|
-
c.run_all_when_everything_filtered = true
|
|
152
140
|
c.filter_run_excluding :ruby => lambda {|version|
|
|
153
141
|
case version.to_s
|
|
154
142
|
when "!jruby"
|