rspec-core 2.99.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- checksums.yaml.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +339 -1
- data/License.txt +1 -0
- data/README.md +19 -37
- data/exe/rspec +2 -23
- data/lib/rspec/core/backport_random.rb +336 -0
- data/lib/rspec/core/backtrace_formatter.rb +70 -0
- data/lib/rspec/core/configuration.rb +479 -577
- data/lib/rspec/core/configuration_options.rb +71 -54
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +86 -18
- data/lib/rspec/core/example.rb +267 -119
- data/lib/rspec/core/example_group.rb +381 -393
- data/lib/rspec/core/filter_manager.rb +133 -114
- data/lib/rspec/core/flat_map.rb +18 -0
- data/lib/rspec/core/formatters/base_formatter.rb +51 -125
- data/lib/rspec/core/formatters/base_text_formatter.rb +34 -286
- data/lib/rspec/core/formatters/console_codes.rb +24 -1
- data/lib/rspec/core/formatters/deprecation_formatter.rb +25 -26
- data/lib/rspec/core/formatters/documentation_formatter.rb +27 -25
- data/lib/rspec/core/formatters/helpers.rb +14 -36
- data/lib/rspec/core/formatters/html_formatter.rb +58 -65
- data/lib/rspec/core/formatters/html_printer.rb +12 -18
- data/lib/rspec/core/formatters/json_formatter.rb +54 -31
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +11 -15
- data/lib/rspec/core/formatters/snippet_extractor.rb +22 -11
- data/lib/rspec/core/formatters.rb +90 -43
- data/lib/rspec/core/hooks.rb +325 -270
- data/lib/rspec/core/memoized_helpers.rb +45 -156
- data/lib/rspec/core/metadata.rb +284 -236
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
- data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
- data/lib/rspec/core/mocking_adapters/null.rb +12 -0
- data/lib/rspec/core/mocking_adapters/rr.rb +29 -0
- data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
- data/lib/rspec/core/notifications.rb +511 -0
- data/lib/rspec/core/option_parser.rb +49 -74
- data/lib/rspec/core/ordering.rb +156 -0
- data/lib/rspec/core/pending.rb +94 -96
- data/lib/rspec/core/project_initializer/.rspec +3 -0
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +78 -0
- data/lib/rspec/core/project_initializer.rb +24 -64
- data/lib/rspec/core/rake_task.rb +44 -130
- data/lib/rspec/core/reporter.rb +76 -59
- data/lib/rspec/core/ruby_project.rb +2 -1
- data/lib/rspec/core/runner.rb +117 -52
- data/lib/rspec/core/shared_context.rb +10 -10
- data/lib/rspec/core/shared_example_group.rb +108 -121
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +40 -0
- data/lib/rspec/core/world.rb +66 -10
- data/lib/rspec/core.rb +64 -104
- data.tar.gz.sig +3 -0
- metadata +75 -322
- metadata.gz.sig +1 -0
- data/exe/autospec +0 -13
- data/features/Autotest.md +0 -38
- data/features/README.md +0 -17
- data/features/Upgrade.md +0 -364
- data/features/command_line/README.md +0 -28
- data/features/command_line/example_name_option.feature +0 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/format_option.feature +0 -75
- data/features/command_line/init.feature +0 -18
- data/features/command_line/line_number_appended_to_path.feature +0 -140
- data/features/command_line/line_number_option.feature +0 -53
- data/features/command_line/order.feature +0 -26
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -22
- data/features/command_line/tag.feature +0 -98
- data/features/command_line/warnings_option.feature +0 -29
- data/features/configuration/alias_example_to.feature +0 -48
- data/features/configuration/backtrace_clean_patterns.feature +0 -102
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/deprecation_stream.feature +0 -58
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/failure_exit_code.feature +0 -36
- data/features/configuration/order_and_seed.feature +0 -3
- data/features/configuration/output_stream.feature +0 -24
- data/features/configuration/pattern.feature +0 -38
- data/features/configuration/profile.feature +0 -220
- data/features/configuration/read_options_from_file.feature +0 -90
- data/features/configuration/run_all_when_everything_filtered.feature +0 -76
- data/features/configuration/show_failures_in_pending_blocks.feature +0 -61
- data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
- data/features/example_groups/basic_structure.feature +0 -55
- data/features/example_groups/shared_context.feature +0 -74
- data/features/example_groups/shared_examples.feature +0 -294
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -197
- data/features/filtering/exclusion_filters.feature +0 -138
- data/features/filtering/if_and_unless.feature +0 -168
- data/features/filtering/inclusion_filters.feature +0 -105
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -36
- data/features/formatters/json_formatter.feature +0 -30
- data/features/formatters/text_formatter.feature +0 -46
- data/features/helper_methods/arbitrary_methods.feature +0 -40
- data/features/helper_methods/let.feature +0 -50
- data/features/helper_methods/modules.feature +0 -149
- data/features/hooks/around_hooks.feature +0 -343
- data/features/hooks/before_and_after_hooks.feature +0 -427
- data/features/hooks/filtering.feature +0 -234
- data/features/metadata/current_example.feature +0 -56
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -113
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -96
- data/features/mock_framework_integration/use_mocha.feature +0 -97
- data/features/mock_framework_integration/use_rr.feature +0 -98
- data/features/mock_framework_integration/use_rspec.feature +0 -97
- data/features/pending/pending_examples.feature +0 -229
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -49
- data/features/subject/attribute_of_subject.feature +0 -124
- data/features/subject/explicit_subject.feature +0 -101
- data/features/subject/implicit_subject.feature +0 -63
- data/features/subject/one_liner_syntax.feature +0 -71
- data/features/support/env.rb +0 -14
- data/features/support/rubinius.rb +0 -6
- data/lib/autotest/discover.rb +0 -10
- data/lib/autotest/rspec2.rb +0 -77
- data/lib/rspec/core/backtrace_cleaner.rb +0 -46
- data/lib/rspec/core/backward_compatibility.rb +0 -55
- data/lib/rspec/core/caller_filter.rb +0 -60
- data/lib/rspec/core/command_line.rb +0 -47
- data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
- data/lib/rspec/core/deprecation.rb +0 -26
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
- data/lib/rspec/core/extensions/kernel.rb +0 -9
- data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
- data/lib/rspec/core/extensions/ordered.rb +0 -27
- data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
- data/lib/rspec/core/metadata_hash_builder.rb +0 -97
- data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
- data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
- data/lib/rspec/core/mocking/with_rr.rb +0 -27
- data/lib/rspec/core/mocking/with_rspec.rb +0 -27
- data/lib/rspec/core/shared_example_group/collection.rb +0 -45
- data/spec/autotest/discover_spec.rb +0 -49
- data/spec/autotest/failed_results_re_spec.rb +0 -45
- data/spec/autotest/rspec_spec.rb +0 -133
- data/spec/command_line/order_spec.rb +0 -204
- data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
- data/spec/rspec/core/caller_filter_spec.rb +0 -58
- data/spec/rspec/core/command_line_spec.rb +0 -127
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -417
- data/spec/rspec/core/configuration_spec.rb +0 -2072
- data/spec/rspec/core/deprecation_spec.rb +0 -27
- data/spec/rspec/core/deprecations_spec.rb +0 -59
- data/spec/rspec/core/drb_command_line_spec.rb +0 -102
- data/spec/rspec/core/drb_options_spec.rb +0 -193
- data/spec/rspec/core/dsl_spec.rb +0 -25
- data/spec/rspec/core/example_group_spec.rb +0 -1337
- data/spec/rspec/core/example_spec.rb +0 -502
- data/spec/rspec/core/filter_manager_spec.rb +0 -246
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -108
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -524
- data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -263
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -89
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -131
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -115
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters/text_mate_formatted.html +0 -397
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -269
- data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -776
- data/spec/rspec/core/metadata_spec.rb +0 -514
- data/spec/rspec/core/option_parser_spec.rb +0 -297
- data/spec/rspec/core/pending_example_spec.rb +0 -260
- data/spec/rspec/core/pending_spec.rb +0 -27
- data/spec/rspec/core/project_initializer_spec.rb +0 -130
- data/spec/rspec/core/rake_task_spec.rb +0 -202
- data/spec/rspec/core/reporter_spec.rb +0 -167
- data/spec/rspec/core/resources/a_bar.rb +0 -0
- data/spec/rspec/core/resources/a_foo.rb +0 -0
- data/spec/rspec/core/resources/a_spec.rb +0 -1
- data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
- data/spec/rspec/core/resources/formatter_specs.rb +0 -60
- data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
- data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
- data/spec/rspec/core/ruby_project_spec.rb +0 -26
- data/spec/rspec/core/runner_spec.rb +0 -82
- data/spec/rspec/core/shared_context_spec.rb +0 -114
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -70
- data/spec/rspec/core/shared_example_group_spec.rb +0 -138
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -108
- data/spec/spec_helper.rb +0 -135
- data/spec/support/config_options_helper.rb +0 -15
- data/spec/support/helper_methods.rb +0 -55
- data/spec/support/in_sub_process.rb +0 -37
- data/spec/support/isolate_load_path_mutation.rb +0 -6
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/matchers.rb +0 -65
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/sandboxed_mock_space.rb +0 -116
- data/spec/support/shared_example_groups.rb +0 -42
- data/spec/support/silence_dsl_deprecations.rb +0 -32
- data/spec/support/spec_files.rb +0 -44
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'rspec/core/drb_command_line'
|
|
3
|
-
|
|
4
|
-
module RSpec::Core
|
|
5
|
-
describe Runner do
|
|
6
|
-
describe 'at_exit' do
|
|
7
|
-
it 'sets an at_exit hook if none is already set' do
|
|
8
|
-
RSpec::Core::Runner.stub(:installed_at_exit?).and_return(false)
|
|
9
|
-
RSpec::Core::Runner.stub(:running_in_drb?).and_return(false)
|
|
10
|
-
RSpec::Core::Runner.stub(:at_exit_hook_disabled?).and_return(false)
|
|
11
|
-
RSpec::Core::Runner.stub(:run).and_return(-1)
|
|
12
|
-
RSpec::Core::Runner.should_receive(:at_exit)
|
|
13
|
-
RSpec::Core::Runner.autorun
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'does not set the at_exit hook if it is already set' do
|
|
17
|
-
RSpec::Core::Runner.stub(:installed_at_exit?).and_return(true)
|
|
18
|
-
RSpec::Core::Runner.stub(:running_in_drb?).and_return(false)
|
|
19
|
-
RSpec::Core::Runner.stub(:at_exit_hook_disabled?).and_return(false)
|
|
20
|
-
RSpec::Core::Runner.should_receive(:at_exit).never
|
|
21
|
-
RSpec::Core::Runner.autorun
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe "#run" do
|
|
26
|
-
let(:err) { StringIO.new }
|
|
27
|
-
let(:out) { StringIO.new }
|
|
28
|
-
|
|
29
|
-
it "tells RSpec to reset" do
|
|
30
|
-
RSpec.configuration.stub(:files_to_run => [])
|
|
31
|
-
RSpec.should_receive(:reset)
|
|
32
|
-
RSpec::Core::Runner.run([], err, out)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
context "with --drb or -X" do
|
|
36
|
-
|
|
37
|
-
before(:each) do
|
|
38
|
-
@options = RSpec::Core::ConfigurationOptions.new(%w[--drb --drb-port 8181 --color])
|
|
39
|
-
RSpec::Core::ConfigurationOptions.stub(:new) { @options }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def run_specs
|
|
43
|
-
RSpec::Core::Runner.run(%w[ --drb ], err, out)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
context 'and a DRb server is running' do
|
|
47
|
-
it "builds a DRbCommandLine and runs the specs" do
|
|
48
|
-
drb_proxy = double(RSpec::Core::DRbCommandLine, :run => true)
|
|
49
|
-
drb_proxy.should_receive(:run).with(err, out)
|
|
50
|
-
|
|
51
|
-
RSpec::Core::DRbCommandLine.should_receive(:new).and_return(drb_proxy)
|
|
52
|
-
|
|
53
|
-
run_specs
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context 'and a DRb server is not running' do
|
|
58
|
-
before(:each) do
|
|
59
|
-
RSpec::Core::DRbCommandLine.should_receive(:new).and_raise(DRb::DRbConnError)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "outputs a message" do
|
|
63
|
-
RSpec.configuration.stub(:files_to_run) { [] }
|
|
64
|
-
err.should_receive(:puts).with(
|
|
65
|
-
"No DRb server is running. Running in local process instead ..."
|
|
66
|
-
)
|
|
67
|
-
run_specs
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "builds a Runner and runs the specs" do
|
|
71
|
-
process_proxy = double(RSpec::Core::Runner, :run => 0)
|
|
72
|
-
process_proxy.should_receive(:run).with(err, out)
|
|
73
|
-
|
|
74
|
-
RSpec::Core::Runner.should_receive(:new).and_return(process_proxy)
|
|
75
|
-
|
|
76
|
-
run_specs
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe RSpec::SharedContext do
|
|
4
|
-
it "is accessible as RSpec::Core::SharedContext" do
|
|
5
|
-
RSpec::Core::SharedContext
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it "is accessible as RSpec::SharedContext" do
|
|
9
|
-
RSpec::SharedContext
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "supports before and after hooks" do
|
|
13
|
-
before_all_hook = false
|
|
14
|
-
before_each_hook = false
|
|
15
|
-
after_each_hook = false
|
|
16
|
-
after_all_hook = false
|
|
17
|
-
shared = Module.new do
|
|
18
|
-
extend RSpec::SharedContext
|
|
19
|
-
before(:all) { before_all_hook = true }
|
|
20
|
-
before(:each) { before_each_hook = true }
|
|
21
|
-
after(:each) { after_each_hook = true }
|
|
22
|
-
after(:all) { after_all_hook = true }
|
|
23
|
-
end
|
|
24
|
-
group = RSpec::Core::ExampleGroup.describe do
|
|
25
|
-
include shared
|
|
26
|
-
example { }
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
group.run
|
|
30
|
-
|
|
31
|
-
expect(before_all_hook).to be_truthy
|
|
32
|
-
expect(before_each_hook).to be_truthy
|
|
33
|
-
expect(after_each_hook).to be_truthy
|
|
34
|
-
expect(after_all_hook).to be_truthy
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "runs the before each hooks in configuration before those of the shared context" do
|
|
38
|
-
ordered_hooks = []
|
|
39
|
-
RSpec.configure do |c|
|
|
40
|
-
c.before(:each) { ordered_hooks << "config" }
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
shared_context("before each stuff", :example => :before_each_hook_order) do
|
|
44
|
-
before(:each) { ordered_hooks << "shared_context"}
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
group = RSpec::Core::ExampleGroup.describe "group", :example => :before_each_hook_order do
|
|
48
|
-
before(:each) { ordered_hooks << "example_group" }
|
|
49
|
-
example {}
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
group.run
|
|
53
|
-
|
|
54
|
-
expect(ordered_hooks).to be == ["config", "shared_context", "example_group"]
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it "supports let" do
|
|
58
|
-
shared = Module.new do
|
|
59
|
-
extend RSpec::SharedContext
|
|
60
|
-
let(:foo) { 'foo' }
|
|
61
|
-
end
|
|
62
|
-
group = RSpec::Core::ExampleGroup.describe do
|
|
63
|
-
include shared
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
expect(group.new.foo).to eq('foo')
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it 'supports explicit subjects' do
|
|
70
|
-
shared = Module.new do
|
|
71
|
-
extend RSpec::SharedContext
|
|
72
|
-
subject { 17 }
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
group = RSpec::Core::ExampleGroup.describe do
|
|
76
|
-
include shared
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
expect(group.new.subject).to eq(17)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
it 'supports `its` with an implicit subject' do
|
|
83
|
-
shared = Module.new do
|
|
84
|
-
extend RSpec::SharedContext
|
|
85
|
-
its(:size) { should eq 0 }
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
group = RSpec::Core::ExampleGroup.describe(Array) do
|
|
89
|
-
include shared
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
group.run
|
|
93
|
-
expect(group.children.first.examples.first.execution_result).to include(:status => "passed")
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
%w[describe context].each do |method_name|
|
|
97
|
-
it "supports nested example groups using #{method_name}" do
|
|
98
|
-
shared = Module.new do
|
|
99
|
-
extend RSpec::SharedContext
|
|
100
|
-
send(method_name, "nested using describe") do
|
|
101
|
-
example {}
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
group = RSpec::Core::ExampleGroup.describe do
|
|
105
|
-
include shared
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
group.run
|
|
109
|
-
|
|
110
|
-
expect(group.children.length).to eq(1)
|
|
111
|
-
expect(group.children.first.examples.length).to eq(1)
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module RSpec::Core::SharedExampleGroup
|
|
4
|
-
describe Collection do
|
|
5
|
-
|
|
6
|
-
# this represents:
|
|
7
|
-
#
|
|
8
|
-
# shared_examples "top level group"
|
|
9
|
-
#
|
|
10
|
-
# context do
|
|
11
|
-
# shared_examples "nested level one"
|
|
12
|
-
# end
|
|
13
|
-
#
|
|
14
|
-
# context do
|
|
15
|
-
# shared_examples "nested level two"
|
|
16
|
-
# end
|
|
17
|
-
#
|
|
18
|
-
let(:examples) do
|
|
19
|
-
Hash.new { |hash,k| hash[k] = Hash.new }.tap do |hash|
|
|
20
|
-
hash["main"] = { "top level group" => example_1 }
|
|
21
|
-
hash["nested 1"] = { "nested level one" => example_2 }
|
|
22
|
-
hash["nested 2"] = { "nested level two" => example_3 }
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
(1..3).each { |num| let("example_#{num}") { double "example #{num}" } }
|
|
26
|
-
|
|
27
|
-
context 'setup with one source, which is the top level' do
|
|
28
|
-
|
|
29
|
-
let(:collection) { Collection.new ['main'], examples }
|
|
30
|
-
|
|
31
|
-
it 'fetches examples from the top level' do
|
|
32
|
-
expect(collection['top level group']).to eq example_1
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'fetches examples across the nested context' do
|
|
36
|
-
RSpec.stub(:warn_deprecation)
|
|
37
|
-
expect(collection['nested level two']).to eq example_3
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'warns about deprecation when you fetch across nested contexts' do
|
|
41
|
-
RSpec.should_receive(:warn_deprecation)
|
|
42
|
-
collection['nested level two']
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
context 'setup with multiple sources' do
|
|
47
|
-
|
|
48
|
-
let(:collection) { Collection.new ['main','nested 1'], examples }
|
|
49
|
-
|
|
50
|
-
it 'fetches examples from the context' do
|
|
51
|
-
expect(collection['nested level one']).to eq example_2
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it 'fetches examples from main' do
|
|
55
|
-
expect(collection['top level group']).to eq example_1
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it 'fetches examples across the nested context' do
|
|
59
|
-
RSpec.stub(:warn_deprecation)
|
|
60
|
-
expect(collection['nested level two']).to eq example_3
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it 'warns about deprecation when you fetch across nested contexts' do
|
|
64
|
-
RSpec.should_receive(:warn_deprecation)
|
|
65
|
-
collection['nested level two']
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module RandomTopLevelModule
|
|
4
|
-
def self.setup!
|
|
5
|
-
shared_examples_for("top level in module") {}
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
module RSpec::Core
|
|
10
|
-
describe SharedExampleGroup do
|
|
11
|
-
|
|
12
|
-
ExampleModule = Module.new
|
|
13
|
-
ExampleClass = Class.new
|
|
14
|
-
|
|
15
|
-
it 'does not add a bunch of private methods to Module' do
|
|
16
|
-
seg_methods = RSpec::Core::SharedExampleGroup.private_instance_methods
|
|
17
|
-
expect(Module.private_methods & seg_methods).to eq([])
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
module SharedExampleGroup
|
|
21
|
-
describe Registry do
|
|
22
|
-
it "can safely be reset when there aren't any shared groups" do
|
|
23
|
-
expect { Registry.new.clear }.to_not raise_error
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
before(:all) do
|
|
29
|
-
# this is a work around as SharedExampleGroup is not world safe
|
|
30
|
-
RandomTopLevelModule.setup!
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
%w[share_examples_for shared_examples_for shared_examples shared_context].each do |shared_method_name|
|
|
34
|
-
describe shared_method_name do
|
|
35
|
-
if shared_method_name == "share_examples_for"
|
|
36
|
-
before { allow_deprecation }
|
|
37
|
-
|
|
38
|
-
it 'is deprecated when called from within an example group' do
|
|
39
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 2, /share_examples_for/)
|
|
40
|
-
ExampleGroup.describe("example group") do
|
|
41
|
-
send(shared_method_name, "group") { }
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it 'is deprecated when called from the top level' do
|
|
46
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 2, /share_examples_for/)
|
|
47
|
-
Module.new do
|
|
48
|
-
send(shared_method_name, "group") { }
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "is exposed to the global namespace" do
|
|
54
|
-
expect(Kernel).to respond_to(shared_method_name)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it "displays a warning when adding a second shared example group with the same name" do
|
|
58
|
-
group = ExampleGroup.describe('example group')
|
|
59
|
-
group.send(shared_method_name, 'some shared group') {}
|
|
60
|
-
original_declaration = [__FILE__, __LINE__ - 1].join(':')
|
|
61
|
-
|
|
62
|
-
warning = nil
|
|
63
|
-
Kernel.stub(:warn) { |msg| warning = msg }
|
|
64
|
-
|
|
65
|
-
group.send(shared_method_name, 'some shared group') {}
|
|
66
|
-
second_declaration = [__FILE__, __LINE__ - 1].join(':')
|
|
67
|
-
expect(warning).to include('some shared group', original_declaration, second_declaration)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it 'works with top level defined examples in modules' do
|
|
71
|
-
expect(RSpec::configuration.reporter).to_not receive(:deprecation)
|
|
72
|
-
ExampleGroup.describe('example group') { include_context 'top level in module' }
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
["name", :name, ExampleModule, ExampleClass].each do |object|
|
|
76
|
-
type = object.class.name.downcase
|
|
77
|
-
context "given a #{type}" do
|
|
78
|
-
it "captures the given #{type} and block in the collection of shared example groups" do
|
|
79
|
-
implementation = lambda {}
|
|
80
|
-
send(shared_method_name, object, &implementation)
|
|
81
|
-
expect(SharedExampleGroup.registry.shared_example_groups[self][object]).to eq implementation
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
context "given a hash" do
|
|
87
|
-
it "delegates extend on configuration" do
|
|
88
|
-
implementation = Proc.new { def bar; 'bar'; end }
|
|
89
|
-
send(shared_method_name, :foo => :bar, &implementation)
|
|
90
|
-
a = RSpec.configuration.include_or_extend_modules.first
|
|
91
|
-
expect(a[0]).to eq(:extend)
|
|
92
|
-
expect(Class.new.extend(a[1]).new.bar).to eq('bar')
|
|
93
|
-
expect(a[2]).to eq(:foo => :bar)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
context "given a string and a hash" do
|
|
98
|
-
it "captures the given string and block in the World's collection of shared example groups" do
|
|
99
|
-
implementation = lambda {}
|
|
100
|
-
send(shared_method_name, "name", :foo => :bar, &implementation)
|
|
101
|
-
expect(SharedExampleGroup.registry.shared_example_groups[self]["name"]).to eq implementation
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "delegates extend on configuration" do
|
|
105
|
-
implementation = Proc.new { def bar; 'bar'; end }
|
|
106
|
-
send(shared_method_name, "name", :foo => :bar, &implementation)
|
|
107
|
-
a = RSpec.configuration.include_or_extend_modules.first
|
|
108
|
-
expect(a[0]).to eq(:extend)
|
|
109
|
-
expect(Class.new.extend(a[1]).new.bar).to eq('bar')
|
|
110
|
-
expect(a[2]).to eq(:foo => :bar)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
describe "#share_as" do
|
|
117
|
-
before { allow(RSpec).to receive(:deprecate) }
|
|
118
|
-
|
|
119
|
-
it "is exposed to the global namespace" do
|
|
120
|
-
expect(Kernel).to respond_to("share_as")
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it "adds examples to current example_group using include", :compat => 'rspec-1.2' do
|
|
124
|
-
share_as('Cornucopia') do
|
|
125
|
-
it "is plentiful" do
|
|
126
|
-
expect(5).to eq(4)
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
group = ExampleGroup.describe('group') { include Cornucopia }
|
|
130
|
-
phantom_group = group.children.first
|
|
131
|
-
expect(phantom_group.description).to eql("")
|
|
132
|
-
expect(phantom_group.metadata[:shared_group_name]).to eql('Cornucopia')
|
|
133
|
-
expect(phantom_group.examples.length).to eq(1)
|
|
134
|
-
expect(phantom_group.examples.first.metadata[:description]).to eq("is plentiful")
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
class Bar; end
|
|
4
|
-
class Foo; end
|
|
5
|
-
|
|
6
|
-
module RSpec::Core
|
|
7
|
-
|
|
8
|
-
describe RSpec::Core::World do
|
|
9
|
-
let(:configuration) { RSpec::Core::Configuration.new }
|
|
10
|
-
let(:world) { RSpec::Core::World.new(configuration) }
|
|
11
|
-
|
|
12
|
-
describe '#reset' do
|
|
13
|
-
it 'clears #example_groups' do
|
|
14
|
-
world.example_groups << :example_group
|
|
15
|
-
world.reset
|
|
16
|
-
expect(world.example_groups).to be_empty
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe "#example_groups" do
|
|
21
|
-
it "contains all registered example groups" do
|
|
22
|
-
group = RSpec::Core::ExampleGroup.describe("group"){}
|
|
23
|
-
world.register(group)
|
|
24
|
-
expect(world.example_groups).to include(group)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe "#preceding_declaration_line (again)" do
|
|
29
|
-
let(:group) do
|
|
30
|
-
RSpec::Core::ExampleGroup.describe("group") do
|
|
31
|
-
|
|
32
|
-
example("example") {}
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
let(:second_group) do
|
|
38
|
-
RSpec::Core::ExampleGroup.describe("second_group") do
|
|
39
|
-
|
|
40
|
-
example("second_example") {}
|
|
41
|
-
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
let(:group_declaration_line) { group.metadata[:example_group][:line_number] }
|
|
46
|
-
let(:example_declaration_line) { group_declaration_line + 2 }
|
|
47
|
-
|
|
48
|
-
context "with one example" do
|
|
49
|
-
before { world.register(group) }
|
|
50
|
-
|
|
51
|
-
it "returns nil if no example or group precedes the line" do
|
|
52
|
-
expect(world.preceding_declaration_line(group_declaration_line - 1)).to be_nil
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "returns the argument line number if a group starts on that line" do
|
|
56
|
-
expect(world.preceding_declaration_line(group_declaration_line)).to eq(group_declaration_line)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "returns the argument line number if an example starts on that line" do
|
|
60
|
-
expect(world.preceding_declaration_line(example_declaration_line)).to eq(example_declaration_line)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "returns line number of a group that immediately precedes the argument line" do
|
|
64
|
-
expect(world.preceding_declaration_line(group_declaration_line + 1)).to eq(group_declaration_line)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "returns line number of an example that immediately precedes the argument line" do
|
|
68
|
-
expect(world.preceding_declaration_line(example_declaration_line + 1)).to eq(example_declaration_line)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
context "with two exaples and the second example is registre first" do
|
|
73
|
-
let(:second_group_declaration_line) { second_group.metadata[:example_group][:line_number] }
|
|
74
|
-
|
|
75
|
-
before do
|
|
76
|
-
world.register(second_group)
|
|
77
|
-
world.register(group)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it 'return line number of group if a group start on that line' do
|
|
81
|
-
expect(world.preceding_declaration_line(second_group_declaration_line)).to eq(second_group_declaration_line)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
describe "#announce_filters" do
|
|
87
|
-
let(:reporter) { double('reporter').as_null_object }
|
|
88
|
-
before { world.stub(:reporter) { reporter } }
|
|
89
|
-
|
|
90
|
-
context "with no examples" do
|
|
91
|
-
before { world.stub(:example_count) { 0 } }
|
|
92
|
-
|
|
93
|
-
context "with no filters" do
|
|
94
|
-
it "announces" do
|
|
95
|
-
reporter.should_receive(:message).
|
|
96
|
-
with("No examples found.")
|
|
97
|
-
world.announce_filters
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
context "with an inclusion filter" do
|
|
102
|
-
it "announces" do
|
|
103
|
-
configuration.filter_run_including :foo => 'bar'
|
|
104
|
-
reporter.should_receive(:message).
|
|
105
|
-
with(/All examples were filtered out/)
|
|
106
|
-
world.announce_filters
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
context "with an inclusion filter and run_all_when_everything_filtered" do
|
|
111
|
-
it "announces" do
|
|
112
|
-
configuration.stub(:run_all_when_everything_filtered?) { true }
|
|
113
|
-
configuration.filter_run_including :foo => 'bar'
|
|
114
|
-
reporter.should_receive(:message).
|
|
115
|
-
with(/All examples were filtered out/)
|
|
116
|
-
world.announce_filters
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
context "with an exclusion filter" do
|
|
121
|
-
it "announces" do
|
|
122
|
-
configuration.filter_run_excluding :foo => 'bar'
|
|
123
|
-
reporter.should_receive(:message).
|
|
124
|
-
with(/All examples were filtered out/)
|
|
125
|
-
world.announce_filters
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
context "with examples" do
|
|
131
|
-
before { world.stub(:example_count) { 1 } }
|
|
132
|
-
|
|
133
|
-
context "with no filters" do
|
|
134
|
-
it "does not announce" do
|
|
135
|
-
reporter.should_not_receive(:message)
|
|
136
|
-
world.announce_filters
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
data/spec/rspec/core_spec.rb
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe RSpec do
|
|
4
|
-
describe "::configuration" do
|
|
5
|
-
it "returns the same object every time" do
|
|
6
|
-
expect(RSpec.configuration).to equal(RSpec.configuration)
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
describe "::configuration=" do
|
|
11
|
-
it "sets the configuration object" do
|
|
12
|
-
configuration = RSpec::Core::Configuration.new
|
|
13
|
-
|
|
14
|
-
RSpec.configuration = configuration
|
|
15
|
-
|
|
16
|
-
expect(RSpec.configuration).to equal(configuration)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe "::configure" do
|
|
21
|
-
it "yields the current configuration" do
|
|
22
|
-
RSpec.configure do |config|
|
|
23
|
-
expect(config).to equal(RSpec::configuration)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe "::world" do
|
|
29
|
-
it "returns the same object every time" do
|
|
30
|
-
expect(RSpec.world).to equal(RSpec.world)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe "::world=" do
|
|
35
|
-
it "sets the world object" do
|
|
36
|
-
world = RSpec::Core::World.new
|
|
37
|
-
|
|
38
|
-
RSpec.world = world
|
|
39
|
-
|
|
40
|
-
expect(RSpec.world).to equal(world)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
describe ".current_example" do
|
|
45
|
-
it "sets the example being executed" do
|
|
46
|
-
group = RSpec::Core::ExampleGroup.describe("an example group")
|
|
47
|
-
example = group.example("an example")
|
|
48
|
-
|
|
49
|
-
RSpec.current_example = example
|
|
50
|
-
expect(RSpec.current_example).to be(example)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe "::reset" do
|
|
55
|
-
it "resets the configuration and world objects" do
|
|
56
|
-
config_before_reset = RSpec.configuration
|
|
57
|
-
world_before_reset = RSpec.world
|
|
58
|
-
|
|
59
|
-
RSpec.reset
|
|
60
|
-
|
|
61
|
-
expect(RSpec.configuration).not_to equal(config_before_reset)
|
|
62
|
-
expect(RSpec.world).not_to equal(world_before_reset)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
describe "::Core.path_to_executable" do
|
|
67
|
-
it 'returns the absolute location of the exe/rspec file' do
|
|
68
|
-
expect(RSpec::Core.path_to_executable).to eq File.expand_path('../../../exe/rspec',__FILE__)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# This is hard to test :(. Best way I could come up with was starting
|
|
73
|
-
# fresh ruby process w/o this stuff already loaded.
|
|
74
|
-
it "loads mocks and expectations when the constants are referenced" do
|
|
75
|
-
code = "$LOAD_PATH.replace(#{$LOAD_PATH.inspect}); " +
|
|
76
|
-
'require "rspec"; ' +
|
|
77
|
-
"puts RSpec::Mocks.name; " +
|
|
78
|
-
"puts RSpec::Expectations.name"
|
|
79
|
-
|
|
80
|
-
result = `ruby -e '#{code}'`.chomp
|
|
81
|
-
expect(result.split("\n")).to eq(%w[ RSpec::Mocks RSpec::Expectations ])
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it 'correctly raises an error when an invalid const is referenced' do
|
|
85
|
-
expect {
|
|
86
|
-
RSpec::NotAConst
|
|
87
|
-
}.to raise_error(NameError, /RSpec::NotAConst/)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
describe "::Core::PendingExampleFixedError" do
|
|
91
|
-
before { allow_deprecation }
|
|
92
|
-
|
|
93
|
-
it 'is an alternate reference to RSpec::Core::Pending::PendingExampleFixedError' do
|
|
94
|
-
expect(::RSpec::Core::PendingExampleFixedError).to be(::RSpec::Core::Pending::PendingExampleFixedError)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it 'prints a deprecation warning' do
|
|
98
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /PendingExampleFixedError/)
|
|
99
|
-
::RSpec::Core::PendingExampleFixedError
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
specify 'the const_missing hook allows other undefined consts to raise errors as normal' do
|
|
103
|
-
expect {
|
|
104
|
-
::RSpec::Core::SomeUndefinedConst
|
|
105
|
-
}.to raise_error(NameError, /RSpec::Core::SomeUndefinedConst/)
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
end
|