rspec-core 3.0.0.beta2 → 3.0.0.rc1
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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +297 -57
- data/README.md +16 -13
- data/lib/rspec/core.rb +55 -84
- data/lib/rspec/core/backport_random.rb +35 -3
- data/lib/rspec/core/backtrace_formatter.rb +4 -13
- data/lib/rspec/core/configuration.rb +330 -114
- data/lib/rspec/core/configuration_options.rb +38 -22
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +8 -2
- data/lib/rspec/core/example.rb +203 -94
- data/lib/rspec/core/example_group.rb +344 -316
- data/lib/rspec/core/filter_manager.rb +135 -90
- data/lib/rspec/core/flat_map.rb +1 -0
- data/lib/rspec/core/formatters.rb +50 -14
- data/lib/rspec/core/formatters/base_formatter.rb +32 -138
- data/lib/rspec/core/formatters/base_text_formatter.rb +32 -253
- data/lib/rspec/core/formatters/console_codes.rb +65 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +24 -15
- data/lib/rspec/core/formatters/documentation_formatter.rb +7 -10
- data/lib/rspec/core/formatters/helpers.rb +15 -9
- data/lib/rspec/core/formatters/html_formatter.rb +17 -16
- data/lib/rspec/core/formatters/html_printer.rb +1 -0
- data/lib/rspec/core/formatters/json_formatter.rb +18 -20
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +6 -7
- data/lib/rspec/core/formatters/snippet_extractor.rb +8 -6
- data/lib/rspec/core/hooks.rb +131 -125
- data/lib/rspec/core/memoized_helpers.rb +31 -26
- data/lib/rspec/core/metadata.rb +277 -184
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
- data/lib/rspec/core/mocking_adapters/mocha.rb +1 -1
- data/lib/rspec/core/mocking_adapters/null.rb +1 -1
- data/lib/rspec/core/mocking_adapters/rr.rb +2 -1
- data/lib/rspec/core/mocking_adapters/rspec.rb +1 -1
- data/lib/rspec/core/notifications.rb +435 -24
- data/lib/rspec/core/option_parser.rb +16 -25
- data/lib/rspec/core/ordering.rb +3 -1
- data/lib/rspec/core/pending.rb +57 -33
- data/lib/rspec/core/project_initializer.rb +2 -0
- data/lib/rspec/core/project_initializer/spec_helper.rb +5 -4
- data/lib/rspec/core/rake_task.rb +45 -20
- data/lib/rspec/core/reporter.rb +50 -22
- data/lib/rspec/core/ruby_project.rb +1 -0
- data/lib/rspec/core/runner.rb +93 -39
- data/lib/rspec/core/shared_context.rb +7 -5
- data/lib/rspec/core/shared_example_group.rb +85 -77
- data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +35 -17
- data/lib/rspec/core/world.rb +57 -5
- metadata +56 -369
- metadata.gz.sig +3 -3
- data/features/README.md +0 -13
- data/features/Upgrade.md +0 -352
- data/features/command_line/README.md +0 -25
- data/features/command_line/dry_run.feature +0 -29
- data/features/command_line/example_name_option.feature +0 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/fail_fast.feature +0 -26
- data/features/command_line/format_option.feature +0 -75
- data/features/command_line/init.feature +0 -57
- data/features/command_line/line_number_appended_to_path.feature +0 -140
- data/features/command_line/line_number_option.feature +0 -58
- data/features/command_line/order.feature +0 -25
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/randomization.feature +0 -63
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -23
- data/features/command_line/tag.feature +0 -98
- data/features/command_line/warnings_option.feature +0 -29
- data/features/configuration/alias_example_to.feature +0 -39
- data/features/configuration/backtrace_exclusion_patterns.feature +0 -105
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/deprecation_stream.feature +0 -58
- data/features/configuration/enable_global_dsl.feature +0 -54
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/failure_exit_code.feature +0 -36
- data/features/configuration/order_and_seed.feature +0 -3
- data/features/configuration/output_stream.feature +0 -24
- data/features/configuration/overriding_global_ordering.feature +0 -93
- data/features/configuration/pattern.feature +0 -38
- data/features/configuration/profile.feature +0 -220
- data/features/configuration/read_options_from_file.feature +0 -90
- data/features/configuration/run_all_when_everything_filtered.feature +0 -76
- data/features/example_groups/aliasing.feature +0 -48
- data/features/example_groups/basic_structure.feature +0 -55
- data/features/example_groups/shared_context.feature +0 -74
- data/features/example_groups/shared_examples.feature +0 -286
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
- data/features/filtering/exclusion_filters.feature +0 -135
- data/features/filtering/if_and_unless.feature +0 -138
- data/features/filtering/inclusion_filters.feature +0 -101
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -68
- data/features/formatters/json_formatter.feature +0 -30
- data/features/formatters/regression_tests.feature +0 -95
- data/features/formatters/text_formatter.feature +0 -46
- data/features/helper_methods/arbitrary_methods.feature +0 -40
- data/features/helper_methods/let.feature +0 -50
- data/features/helper_methods/modules.feature +0 -146
- data/features/hooks/around_hooks.feature +0 -344
- data/features/hooks/before_and_after_hooks.feature +0 -427
- data/features/hooks/filtering.feature +0 -232
- data/features/metadata/current_example.feature +0 -56
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -100
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -94
- data/features/mock_framework_integration/use_mocha.feature +0 -95
- data/features/mock_framework_integration/use_rr.feature +0 -96
- data/features/mock_framework_integration/use_rspec.feature +0 -95
- data/features/pending_and_skipped_examples/README.md +0 -3
- data/features/pending_and_skipped_examples/pending_examples.feature +0 -118
- data/features/pending_and_skipped_examples/skipped_examples.feature +0 -106
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -83
- data/features/subject/explicit_subject.feature +0 -101
- data/features/subject/implicit_subject.feature +0 -63
- data/features/subject/one_liner_syntax.feature +0 -71
- data/features/support/env.rb +0 -21
- data/features/support/require_expect_syntax_in_aruba_specs.rb +0 -16
- data/features/support/rubinius.rb +0 -6
- data/lib/rspec/core/command_line.rb +0 -35
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/formatters/legacy_formatter.rb +0 -227
- data/lib/rspec/core/shared_example_group/collection.rb +0 -27
- data/spec/command_line/order_spec.rb +0 -211
- data/spec/rspec/core/backtrace_formatter_spec.rb +0 -230
- data/spec/rspec/core/command_line_spec.rb +0 -112
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -409
- data/spec/rspec/core/configuration_spec.rb +0 -1479
- data/spec/rspec/core/drb_command_line_spec.rb +0 -102
- data/spec/rspec/core/drb_options_spec.rb +0 -193
- data/spec/rspec/core/dsl_spec.rb +0 -88
- data/spec/rspec/core/example_group_spec.rb +0 -1533
- data/spec/rspec/core/example_spec.rb +0 -642
- data/spec/rspec/core/filter_manager_spec.rb +0 -229
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -64
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -303
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -208
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -75
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted-2.1.0.html +0 -392
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -122
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -206
- data/spec/rspec/core/formatters/legacy_formatter_spec.rb +0 -137
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -43
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters_spec.rb +0 -120
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -294
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -495
- data/spec/rspec/core/metadata_spec.rb +0 -491
- data/spec/rspec/core/option_parser_spec.rb +0 -262
- data/spec/rspec/core/ordering_spec.rb +0 -102
- data/spec/rspec/core/pending_example_spec.rb +0 -117
- data/spec/rspec/core/pending_spec.rb +0 -8
- data/spec/rspec/core/project_initializer_spec.rb +0 -73
- data/spec/rspec/core/rake_task_spec.rb +0 -146
- data/spec/rspec/core/random_spec.rb +0 -47
- data/spec/rspec/core/reporter_spec.rb +0 -155
- data/spec/rspec/core/resources/a_bar.rb +0 -0
- data/spec/rspec/core/resources/a_foo.rb +0 -0
- data/spec/rspec/core/resources/a_spec.rb +0 -1
- data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
- data/spec/rspec/core/resources/formatter_specs.rb +0 -58
- data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
- data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
- data/spec/rspec/core/ruby_project_spec.rb +0 -26
- data/spec/rspec/core/runner_spec.rb +0 -151
- data/spec/rspec/core/shared_context_spec.rb +0 -102
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -57
- data/spec/rspec/core/shared_example_group_spec.rb +0 -114
- data/spec/rspec/core/warnings_spec.rb +0 -29
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -91
- data/spec/spec_helper.rb +0 -160
- data/spec/support/config_options_helper.rb +0 -13
- data/spec/support/formatter_support.rb +0 -83
- data/spec/support/helper_methods.rb +0 -26
- data/spec/support/isolate_load_path_mutation.rb +0 -5
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +0 -87
- data/spec/support/matchers.rb +0 -85
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/old_style_formatter_example.rb +0 -69
- data/spec/support/shared_example_groups.rb +0 -13
- data/spec/support/spec_files.rb +0 -44
- data/spec/support/stderr_splitter.rb +0 -36
@@ -1,102 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require 'rspec/core/drb_command_line'
|
3
|
-
|
4
|
-
RSpec.describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' do
|
5
|
-
let(:config) { RSpec::Core::Configuration.new }
|
6
|
-
let(:out) { StringIO.new }
|
7
|
-
let(:err) { StringIO.new }
|
8
|
-
|
9
|
-
include_context "spec files"
|
10
|
-
|
11
|
-
def command_line(*args)
|
12
|
-
RSpec::Core::DRbCommandLine.new(config_options(*args))
|
13
|
-
end
|
14
|
-
|
15
|
-
def config_options(*args)
|
16
|
-
RSpec::Core::ConfigurationOptions.new(args)
|
17
|
-
end
|
18
|
-
|
19
|
-
context "without server running" do
|
20
|
-
it "raises an error" do
|
21
|
-
expect { command_line.run(err, out) }.to raise_error(DRb::DRbConnError)
|
22
|
-
end
|
23
|
-
|
24
|
-
after { DRb.stop_service }
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "--drb-port" do
|
28
|
-
def with_RSPEC_DRB_set_to(val)
|
29
|
-
with_env_vars('RSPEC_DRB' => val) { yield }
|
30
|
-
end
|
31
|
-
|
32
|
-
context "without RSPEC_DRB environment variable set" do
|
33
|
-
it "defaults to 8989" do
|
34
|
-
with_RSPEC_DRB_set_to(nil) do
|
35
|
-
expect(command_line.drb_port).to eq(8989)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it "sets the DRb port" do
|
40
|
-
with_RSPEC_DRB_set_to(nil) do
|
41
|
-
expect(command_line("--drb-port", "1234").drb_port).to eq(1234)
|
42
|
-
expect(command_line("--drb-port", "5678").drb_port).to eq(5678)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context "with RSPEC_DRB environment variable set" do
|
48
|
-
context "without config variable set" do
|
49
|
-
it "uses RSPEC_DRB value" do
|
50
|
-
with_RSPEC_DRB_set_to('9000') do
|
51
|
-
expect(command_line.drb_port).to eq("9000")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "and config variable set" do
|
57
|
-
it "uses configured value" do
|
58
|
-
with_RSPEC_DRB_set_to('9000') do
|
59
|
-
expect(command_line(*%w[--drb-port 5678]).drb_port).to eq(5678)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context "with server running", :slow do
|
67
|
-
class SimpleDRbSpecServer
|
68
|
-
def self.run(argv, err, out)
|
69
|
-
options = RSpec::Core::ConfigurationOptions.new(argv)
|
70
|
-
config = RSpec::Core::Configuration.new
|
71
|
-
RSpec::Core::CommandLine.new(options, config).run(err, out)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
before(:all) do
|
76
|
-
@drb_port = '8990'
|
77
|
-
@drb_example_file_counter = 0
|
78
|
-
DRb::start_service("druby://127.0.0.1:#{@drb_port}", SimpleDRbSpecServer)
|
79
|
-
end
|
80
|
-
|
81
|
-
after(:all) do
|
82
|
-
DRb::stop_service
|
83
|
-
end
|
84
|
-
|
85
|
-
it "returns 0 if spec passes" do
|
86
|
-
result = command_line("--drb-port", @drb_port, passing_spec_filename).run(err, out)
|
87
|
-
expect(result).to be(0)
|
88
|
-
end
|
89
|
-
|
90
|
-
it "returns 1 if spec fails" do
|
91
|
-
result = command_line("--drb-port", @drb_port, failing_spec_filename).run(err, out)
|
92
|
-
expect(result).to be(1)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "outputs colorized text when running with --colour option" do
|
96
|
-
pending "figure out a way to tell the output to say it's tty"
|
97
|
-
command_line(failing_spec_filename, "--color", "--drb-port", @drb_port).run(err, out)
|
98
|
-
out.rewind
|
99
|
-
expect(out.read).to match(/\e\[31m/m)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
@@ -1,193 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require 'rspec/core/drb_options'
|
3
|
-
|
4
|
-
RSpec.describe RSpec::Core::DrbOptions, :isolated_directory => true, :isolated_home => true do
|
5
|
-
include ConfigOptionsHelper
|
6
|
-
|
7
|
-
describe "#drb_argv" do
|
8
|
-
it "preserves extra arguments" do
|
9
|
-
allow(File).to receive(:exist?) { false }
|
10
|
-
expect(config_options_object(*%w[ a --drb b --color c ]).drb_argv).to match_array %w[ --color a b c ]
|
11
|
-
end
|
12
|
-
|
13
|
-
%w(--color --fail-fast --profile --backtrace --tty).each do |option|
|
14
|
-
it "includes #{option}" do
|
15
|
-
expect(config_options_object("#{option}").drb_argv).to include("#{option}")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
it "includes --failure-exit-code" do
|
20
|
-
expect(config_options_object(*%w[--failure-exit-code 2]).drb_argv).to include("--failure-exit-code", "2")
|
21
|
-
end
|
22
|
-
|
23
|
-
it "includes --options" do
|
24
|
-
expect(config_options_object(*%w[--options custom.opts]).drb_argv).to include("--options", "custom.opts")
|
25
|
-
end
|
26
|
-
|
27
|
-
it "includes --order" do
|
28
|
-
expect(config_options_object(*%w[--order random]).drb_argv).to include('--order', 'random')
|
29
|
-
end
|
30
|
-
|
31
|
-
context "with --example" do
|
32
|
-
it "includes --example" do
|
33
|
-
expect(config_options_object(*%w[--example foo]).drb_argv).to include("--example", "foo")
|
34
|
-
end
|
35
|
-
|
36
|
-
it "unescapes characters which were escaped upon storing --example originally" do
|
37
|
-
expect(config_options_object("--example", "foo\\ bar").drb_argv).to include("--example", "foo bar")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "with tags" do
|
42
|
-
it "includes the inclusion tags" do
|
43
|
-
coo = config_options_object("--tag", "tag")
|
44
|
-
expect(coo.drb_argv).to eq(["--tag", "tag"])
|
45
|
-
end
|
46
|
-
|
47
|
-
it "includes the inclusion tags with values" do
|
48
|
-
coo = config_options_object("--tag", "tag:foo")
|
49
|
-
expect(coo.drb_argv).to eq(["--tag", "tag:foo"])
|
50
|
-
end
|
51
|
-
|
52
|
-
it "leaves inclusion tags intact" do
|
53
|
-
coo = config_options_object("--tag", "tag")
|
54
|
-
coo.drb_argv
|
55
|
-
expect(coo.filter_manager.inclusions).to eq( {:tag=>true} )
|
56
|
-
end
|
57
|
-
|
58
|
-
it "leaves inclusion tags with values intact" do
|
59
|
-
coo = config_options_object("--tag", "tag:foo")
|
60
|
-
coo.drb_argv
|
61
|
-
expect(coo.filter_manager.inclusions).to eq( {:tag=>'foo'} )
|
62
|
-
end
|
63
|
-
|
64
|
-
it "includes the exclusion tags" do
|
65
|
-
coo = config_options_object("--tag", "~tag")
|
66
|
-
expect(coo.drb_argv).to eq(["--tag", "~tag"])
|
67
|
-
end
|
68
|
-
|
69
|
-
it "includes the exclusion tags with values" do
|
70
|
-
coo = config_options_object("--tag", "~tag:foo")
|
71
|
-
expect(coo.drb_argv).to eq(["--tag", "~tag:foo"])
|
72
|
-
end
|
73
|
-
|
74
|
-
it "leaves exclusion tags intact" do
|
75
|
-
coo = config_options_object("--tag", "~tag")
|
76
|
-
coo.drb_argv
|
77
|
-
expect(coo.filter_manager.exclusions).to include(:tag=>true)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "leaves exclusion tags with values intact" do
|
81
|
-
coo = config_options_object("--tag", "~tag:foo")
|
82
|
-
coo.drb_argv
|
83
|
-
expect(coo.filter_manager.exclusions).to include(:tag=>'foo')
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
context "with formatters" do
|
88
|
-
it "includes the formatters" do
|
89
|
-
coo = config_options_object("--format", "d")
|
90
|
-
expect(coo.drb_argv).to eq(["--format", "d"])
|
91
|
-
end
|
92
|
-
|
93
|
-
it "leaves formatters intact" do
|
94
|
-
coo = config_options_object("--format", "d")
|
95
|
-
coo.drb_argv
|
96
|
-
expect(coo.options[:formatters]).to eq([["d"]])
|
97
|
-
end
|
98
|
-
|
99
|
-
it "leaves output intact" do
|
100
|
-
coo = config_options_object("--format", "p", "--out", "foo.txt", "--format", "d")
|
101
|
-
coo.drb_argv
|
102
|
-
expect(coo.options[:formatters]).to eq([["p","foo.txt"],["d"]])
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context "with --out" do
|
107
|
-
it "combines with formatters" do
|
108
|
-
coo = config_options_object(*%w[--format h --out report.html])
|
109
|
-
expect(coo.drb_argv).to eq(%w[--format h --out report.html])
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context "with --line_number" do
|
114
|
-
it "includes --line_number" do
|
115
|
-
expect(config_options_object(*%w[--line_number 35]).drb_argv).to eq(%w[--line_number 35])
|
116
|
-
end
|
117
|
-
|
118
|
-
it "includes multiple lines" do
|
119
|
-
expect(config_options_object(*%w[-l 90 -l 4 -l 55]).drb_argv).to eq(
|
120
|
-
%w[--line_number 90 --line_number 4 --line_number 55]
|
121
|
-
)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
context "with -I libs" do
|
126
|
-
it "includes -I" do
|
127
|
-
expect(config_options_object(*%w[-I a_dir]).drb_argv).to eq(%w[-I a_dir])
|
128
|
-
end
|
129
|
-
|
130
|
-
it "includes multiple paths" do
|
131
|
-
expect(config_options_object(*%w[-I dir_1 -I dir_2 -I dir_3]).drb_argv).to eq(
|
132
|
-
%w[-I dir_1 -I dir_2 -I dir_3]
|
133
|
-
)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context "with --require" do
|
138
|
-
it "includes --require" do
|
139
|
-
expect(config_options_object(*%w[--require a_path]).drb_argv).to eq(%w[--require a_path])
|
140
|
-
end
|
141
|
-
|
142
|
-
it "includes multiple paths" do
|
143
|
-
expect(config_options_object(*%w[--require dir/ --require file.rb]).drb_argv).to eq(
|
144
|
-
%w[--require dir/ --require file.rb]
|
145
|
-
)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
context "--drb specified in ARGV" do
|
150
|
-
it "renders all the original arguments except --drb" do
|
151
|
-
drb_argv = config_options_object(*%w[ --drb --color --format s --example pattern
|
152
|
-
--line_number 1 --profile --backtrace -I
|
153
|
-
path/a -I path/b --require path/c --require
|
154
|
-
path/d]).drb_argv
|
155
|
-
expect(drb_argv).to eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s -I path/a -I path/b --require path/c --require path/d])
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
context "--drb specified in the options file" do
|
160
|
-
it "renders all the original arguments except --drb" do
|
161
|
-
File.open("./.rspec", "w") {|f| f << "--drb --color"}
|
162
|
-
drb_argv = config_options_object(*%w[ --tty --format s --example
|
163
|
-
pattern --line_number 1 --profile
|
164
|
-
--backtrace ]).drb_argv
|
165
|
-
|
166
|
-
expect(drb_argv).to eq(%w[ --color --profile --backtrace --tty
|
167
|
-
--example pattern --line_number 1 --format s])
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context "--drb specified in ARGV and the options file" do
|
172
|
-
it "renders all the original arguments except --drb" do
|
173
|
-
File.open("./.rspec", "w") {|f| f << "--drb --color"}
|
174
|
-
drb_argv = config_options_object(*%w[ --drb --format s --example
|
175
|
-
pattern --line_number 1 --profile
|
176
|
-
--backtrace]).drb_argv
|
177
|
-
|
178
|
-
expect(drb_argv).to eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s])
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
context "--drb specified in ARGV and in as ARGV-specified --options file" do
|
183
|
-
it "renders all the original arguments except --drb and --options" do
|
184
|
-
File.open("./.rspec", "w") {|f| f << "--drb --color"}
|
185
|
-
drb_argv = config_options_object(*%w[ --drb --format s --example
|
186
|
-
pattern --line_number 1 --profile
|
187
|
-
--backtrace]).drb_argv
|
188
|
-
|
189
|
-
expect(drb_argv).to eq(%w[ --color --profile --backtrace --example pattern --line_number 1 --format s ])
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
data/spec/rspec/core/dsl_spec.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rspec/support/spec/in_sub_process'
|
3
|
-
|
4
|
-
main = self
|
5
|
-
|
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
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
@@ -1,1533 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
class SelfObserver
|
5
|
-
def self.cache
|
6
|
-
@cache ||= []
|
7
|
-
end
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
self.class.cache << self
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module RSpec::Core
|
15
|
-
RSpec.describe ExampleGroup do
|
16
|
-
it_behaves_like "metadata hash builder" do
|
17
|
-
def metadata_hash(*args)
|
18
|
-
group = ExampleGroup.describe('example description', *args)
|
19
|
-
group.metadata
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "when RSpec.configuration.format_docstrings is set to a block" do
|
24
|
-
it "formats the description with that block" do
|
25
|
-
RSpec.configuration.format_docstrings { |s| s.upcase }
|
26
|
-
group = ExampleGroup.describe(' an example ')
|
27
|
-
expect(group.description).to eq(' AN EXAMPLE ')
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'does not treat the first argument as a metadata key even if it is a symbol' do
|
32
|
-
group = ExampleGroup.describe(:symbol)
|
33
|
-
expect(group.metadata).not_to include(:symbol)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'treats the first argument as part of the description when it is a symbol' do
|
37
|
-
group = ExampleGroup.describe(:symbol)
|
38
|
-
expect(group.description).to eq("symbol")
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "constant naming" do
|
42
|
-
RSpec::Matchers.define :have_class_const do |class_name|
|
43
|
-
match do |group|
|
44
|
-
group.name == "RSpec::ExampleGroups::#{class_name}" &&
|
45
|
-
group == class_name.split('::').inject(RSpec::ExampleGroups) do |mod, name|
|
46
|
-
mod.const_get(name)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'gives groups friendly human readable class names' do
|
52
|
-
stub_const("MyGem::Klass", Class.new)
|
53
|
-
parent = ExampleGroup.describe(MyGem::Klass)
|
54
|
-
expect(parent).to have_class_const("MyGemKlass")
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'nests constants to match the group nesting' do
|
58
|
-
grandparent = ExampleGroup.describe("The grandparent")
|
59
|
-
parent = grandparent.describe("the parent")
|
60
|
-
child = parent.describe("the child")
|
61
|
-
|
62
|
-
expect(parent).to have_class_const("TheGrandparent::TheParent")
|
63
|
-
expect(child).to have_class_const("TheGrandparent::TheParent::TheChild")
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'removes non-ascii characters from the const name since some rubies barf on that' do
|
67
|
-
group = ExampleGroup.describe("A chinese character: 们")
|
68
|
-
expect(group).to have_class_const("AChineseCharacter")
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'prefixes the const name with "Nested" if needed to make a valid const' do
|
72
|
-
expect {
|
73
|
-
ExampleGroup.const_set("1B", Object.new)
|
74
|
-
}.to raise_error(NameError)
|
75
|
-
|
76
|
-
group = ExampleGroup.describe("1B")
|
77
|
-
expect(group).to have_class_const("Nested1B")
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'disambiguates name collisions by appending a number' do
|
81
|
-
groups = 10.times.map { ExampleGroup.describe("Collision") }
|
82
|
-
expect(groups[0]).to have_class_const("Collision")
|
83
|
-
expect(groups[1]).to have_class_const("Collision_2")
|
84
|
-
expect(groups[8]).to have_class_const("Collision_9")
|
85
|
-
|
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
|
-
expect(groups[9]).to have_class_const("Collision_10")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'identifies unnamed groups as "Anonymous"' do
|
93
|
-
# Wrap the anonymous group is a uniquely named one,
|
94
|
-
# so the presence of another anonymous group in our
|
95
|
-
# test suite doesn't cause an unexpected number
|
96
|
-
# to be appended.
|
97
|
-
group = ExampleGroup.describe("name of unnamed group")
|
98
|
-
subgroup = group.describe
|
99
|
-
expect(subgroup).to have_class_const("NameOfUnnamedGroup::Anonymous")
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'assigns the const before evaling the group so error messages include the name' do
|
103
|
-
expect {
|
104
|
-
ExampleGroup.describe("Calling an undefined method") { foo }
|
105
|
-
}.to raise_error(/ExampleGroups::CallingAnUndefinedMethod/)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "ordering" do
|
110
|
-
context "when tagged with `:order => :defined`" do
|
111
|
-
it 'orders the subgroups and examples in defined order regardless of global order' do
|
112
|
-
RSpec.configuration.order = :random
|
113
|
-
|
114
|
-
run_order = []
|
115
|
-
group = ExampleGroup.describe "outer", :order => :defined do
|
116
|
-
context "subgroup 1" do
|
117
|
-
example { run_order << :g1_e1 }
|
118
|
-
example { run_order << :g1_e2 }
|
119
|
-
end
|
120
|
-
|
121
|
-
context "subgroup 2" do
|
122
|
-
example { run_order << :g2_e1 }
|
123
|
-
example { run_order << :g2_e2 }
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
group.run
|
128
|
-
expect(run_order).to eq([:g1_e1, :g1_e2, :g2_e1, :g2_e2])
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
context "when tagged with an unrecognized ordering" do
|
133
|
-
let(:run_order) { [] }
|
134
|
-
let(:definition_line) { __LINE__ + 4 }
|
135
|
-
let(:group) do
|
136
|
-
order = self.run_order
|
137
|
-
|
138
|
-
ExampleGroup.describe "group", :order => :unrecognized do
|
139
|
-
example { order << :ex_1 }
|
140
|
-
example { order << :ex_2 }
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
before do
|
145
|
-
RSpec.configuration.register_ordering(:global, &:reverse)
|
146
|
-
allow(group).to receive(:warn)
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'falls back to the global ordering' do
|
150
|
-
group.run
|
151
|
-
expect(run_order).to eq([:ex_2, :ex_1])
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'prints a warning so users are notified of their mistake' do
|
155
|
-
warning = nil
|
156
|
-
allow(group).to receive(:warn) { |msg| warning = msg }
|
157
|
-
|
158
|
-
group.run
|
159
|
-
|
160
|
-
expect(warning).to match(/unrecognized/)
|
161
|
-
expect(warning).to match(/#{File.basename __FILE__}:#{definition_line}/)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
context "when tagged with a custom ordering" do
|
166
|
-
def ascending_numbers
|
167
|
-
lambda { |g| Integer(g.description[/\d+/]) }
|
168
|
-
end
|
169
|
-
|
170
|
-
it 'uses the custom orderings' do
|
171
|
-
RSpec.configure do |c|
|
172
|
-
c.register_ordering :custom do |items|
|
173
|
-
items.sort_by(&ascending_numbers)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
run_order = []
|
178
|
-
group = ExampleGroup.describe "outer", :order => :custom do
|
179
|
-
example("e2") { run_order << :e2 }
|
180
|
-
example("e1") { run_order << :e1 }
|
181
|
-
|
182
|
-
context "subgroup 2" do
|
183
|
-
example("ex 3") { run_order << :g2_e3 }
|
184
|
-
example("ex 1") { run_order << :g2_e1 }
|
185
|
-
example("ex 2") { run_order << :g2_e2 }
|
186
|
-
end
|
187
|
-
|
188
|
-
context "subgroup 1" do
|
189
|
-
example("ex 2") { run_order << :g1_e2 }
|
190
|
-
example("ex 1") { run_order << :g1_e1 }
|
191
|
-
example("ex 3") { run_order << :g1_e3 }
|
192
|
-
end
|
193
|
-
|
194
|
-
context "subgroup 3" do
|
195
|
-
example("ex 2") { run_order << :g3_e2 }
|
196
|
-
example("ex 3") { run_order << :g3_e3 }
|
197
|
-
example("ex 1") { run_order << :g3_e1 }
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
group.run
|
202
|
-
|
203
|
-
expect(run_order).to eq([
|
204
|
-
:e1, :e2,
|
205
|
-
:g1_e1, :g1_e2, :g1_e3,
|
206
|
-
:g2_e1, :g2_e2, :g2_e3,
|
207
|
-
:g3_e1, :g3_e2, :g3_e3
|
208
|
-
])
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
describe "top level group" do
|
214
|
-
it "runs its children" do
|
215
|
-
examples_run = []
|
216
|
-
group = ExampleGroup.describe("parent") do
|
217
|
-
describe("child") do
|
218
|
-
it "does something" do |ex|
|
219
|
-
examples_run << ex
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
group.run
|
225
|
-
expect(examples_run.count).to eq(1)
|
226
|
-
end
|
227
|
-
|
228
|
-
context "with a failure in the top level group" do
|
229
|
-
it "runs its children " do
|
230
|
-
examples_run = []
|
231
|
-
group = ExampleGroup.describe("parent") do
|
232
|
-
it "fails" do |ex|
|
233
|
-
examples_run << ex
|
234
|
-
raise "fail"
|
235
|
-
end
|
236
|
-
describe("child") do
|
237
|
-
it "does something" do |ex|
|
238
|
-
examples_run << ex
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
group.run
|
244
|
-
expect(examples_run.count).to eq(2)
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
describe "descendants" do
|
249
|
-
it "returns self + all descendants" do
|
250
|
-
group = ExampleGroup.describe("parent") do
|
251
|
-
describe("child") do
|
252
|
-
describe("grandchild 1") {}
|
253
|
-
describe("grandchild 2") {}
|
254
|
-
end
|
255
|
-
end
|
256
|
-
expect(group.descendants.size).to eq(4)
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
describe "child" do
|
262
|
-
it "is known by parent" do
|
263
|
-
parent = ExampleGroup.describe
|
264
|
-
child = parent.describe
|
265
|
-
expect(parent.children).to eq([child])
|
266
|
-
end
|
267
|
-
|
268
|
-
it "is not registered in world" do
|
269
|
-
world = RSpec::Core::World.new
|
270
|
-
parent = ExampleGroup.describe
|
271
|
-
world.register(parent)
|
272
|
-
parent.describe
|
273
|
-
expect(world.example_groups).to eq([parent])
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
describe "filtering" do
|
278
|
-
let(:world) { World.new }
|
279
|
-
|
280
|
-
shared_examples "matching filters" do
|
281
|
-
context "inclusion" do
|
282
|
-
before do
|
283
|
-
filter_manager = FilterManager.new
|
284
|
-
filter_manager.include filter_metadata
|
285
|
-
allow(world).to receive_messages(:filter_manager => filter_manager)
|
286
|
-
end
|
287
|
-
|
288
|
-
it "includes examples in groups matching filter" do
|
289
|
-
group = ExampleGroup.describe("does something", spec_metadata)
|
290
|
-
allow(group).to receive(:world) { world }
|
291
|
-
all_examples = [ group.example("first"), group.example("second") ]
|
292
|
-
|
293
|
-
expect(group.filtered_examples).to eq(all_examples)
|
294
|
-
end
|
295
|
-
|
296
|
-
it "includes examples directly matching filter" do
|
297
|
-
group = ExampleGroup.describe("does something")
|
298
|
-
allow(group).to receive(:world) { world }
|
299
|
-
filtered_examples = [
|
300
|
-
group.example("first", spec_metadata),
|
301
|
-
group.example("second", spec_metadata)
|
302
|
-
]
|
303
|
-
group.example("third (not-filtered)")
|
304
|
-
|
305
|
-
expect(group.filtered_examples).to eq(filtered_examples)
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
context "exclusion" do
|
310
|
-
before do
|
311
|
-
filter_manager = FilterManager.new
|
312
|
-
filter_manager.exclude filter_metadata
|
313
|
-
allow(world).to receive_messages(:filter_manager => filter_manager)
|
314
|
-
end
|
315
|
-
|
316
|
-
it "excludes examples in groups matching filter" do
|
317
|
-
group = ExampleGroup.describe("does something", spec_metadata)
|
318
|
-
allow(group).to receive(:world) { world }
|
319
|
-
[ group.example("first"), group.example("second") ]
|
320
|
-
|
321
|
-
expect(group.filtered_examples).to be_empty
|
322
|
-
end
|
323
|
-
|
324
|
-
it "excludes examples directly matching filter" do
|
325
|
-
group = ExampleGroup.describe("does something")
|
326
|
-
allow(group).to receive(:world) { world }
|
327
|
-
[
|
328
|
-
group.example("first", spec_metadata),
|
329
|
-
group.example("second", spec_metadata)
|
330
|
-
]
|
331
|
-
unfiltered_example = group.example("third (not-filtered)")
|
332
|
-
|
333
|
-
expect(group.filtered_examples).to eq([unfiltered_example])
|
334
|
-
end
|
335
|
-
end
|
336
|
-
end
|
337
|
-
|
338
|
-
context "matching false" do
|
339
|
-
let(:spec_metadata) { { :awesome => false }}
|
340
|
-
|
341
|
-
context "against false" do
|
342
|
-
let(:filter_metadata) { { :awesome => false }}
|
343
|
-
include_examples "matching filters"
|
344
|
-
end
|
345
|
-
|
346
|
-
context "against 'false'" do
|
347
|
-
let(:filter_metadata) { { :awesome => 'false' }}
|
348
|
-
include_examples "matching filters"
|
349
|
-
end
|
350
|
-
|
351
|
-
context "against :false" do
|
352
|
-
let(:filter_metadata) { { :awesome => :false }}
|
353
|
-
include_examples "matching filters"
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
context "matching true" do
|
358
|
-
let(:spec_metadata) { { :awesome => true }}
|
359
|
-
|
360
|
-
context "against true" do
|
361
|
-
let(:filter_metadata) { { :awesome => true }}
|
362
|
-
include_examples "matching filters"
|
363
|
-
end
|
364
|
-
|
365
|
-
context "against 'true'" do
|
366
|
-
let(:filter_metadata) { { :awesome => 'true' }}
|
367
|
-
include_examples "matching filters"
|
368
|
-
end
|
369
|
-
|
370
|
-
context "against :true" do
|
371
|
-
let(:filter_metadata) { { :awesome => :true }}
|
372
|
-
include_examples "matching filters"
|
373
|
-
end
|
374
|
-
end
|
375
|
-
|
376
|
-
context "matching a string" do
|
377
|
-
let(:spec_metadata) { { :type => 'special' }}
|
378
|
-
|
379
|
-
context "against a string" do
|
380
|
-
let(:filter_metadata) { { :type => 'special' }}
|
381
|
-
include_examples "matching filters"
|
382
|
-
end
|
383
|
-
|
384
|
-
context "against a symbol" do
|
385
|
-
let(:filter_metadata) { { :type => :special }}
|
386
|
-
include_examples "matching filters"
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
context "matching a symbol" do
|
391
|
-
let(:spec_metadata) { { :type => :special }}
|
392
|
-
|
393
|
-
context "against a string" do
|
394
|
-
let(:filter_metadata) { { :type => 'special' }}
|
395
|
-
include_examples "matching filters"
|
396
|
-
end
|
397
|
-
|
398
|
-
context "against a symbol" do
|
399
|
-
let(:filter_metadata) { { :type => :special }}
|
400
|
-
include_examples "matching filters"
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
context "with no filters" do
|
405
|
-
it "returns all" do
|
406
|
-
group = ExampleGroup.describe
|
407
|
-
allow(group).to receive(:world) { world }
|
408
|
-
example = group.example("does something")
|
409
|
-
expect(group.filtered_examples).to eq([example])
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
413
|
-
context "with no examples or groups that match filters" do
|
414
|
-
it "returns none" do
|
415
|
-
filter_manager = FilterManager.new
|
416
|
-
filter_manager.include :awesome => false
|
417
|
-
allow(world).to receive_messages(:filter_manager => filter_manager)
|
418
|
-
group = ExampleGroup.describe
|
419
|
-
allow(group).to receive(:world) { world }
|
420
|
-
group.example("does something")
|
421
|
-
expect(group.filtered_examples).to eq([])
|
422
|
-
end
|
423
|
-
end
|
424
|
-
end
|
425
|
-
|
426
|
-
describe '#described_class' do
|
427
|
-
|
428
|
-
context "with a constant as the first parameter" do
|
429
|
-
it "is that constant" do
|
430
|
-
expect(ExampleGroup.describe(Object) { }.described_class).to eq(Object)
|
431
|
-
end
|
432
|
-
end
|
433
|
-
|
434
|
-
context "with a string as the first parameter" do
|
435
|
-
it "is nil" do
|
436
|
-
expect(ExampleGroup.describe("i'm a computer") { }.described_class).to be_nil
|
437
|
-
end
|
438
|
-
end
|
439
|
-
|
440
|
-
context "with a constant in an outer group" do
|
441
|
-
context "and a string in an inner group" do
|
442
|
-
it "is the top level constant" do
|
443
|
-
group = ExampleGroup.describe(String) do
|
444
|
-
describe :symbol do
|
445
|
-
example "described_class is String" do
|
446
|
-
expect(described_class).to eq(String)
|
447
|
-
end
|
448
|
-
end
|
449
|
-
end
|
450
|
-
|
451
|
-
expect(group.run).to be_truthy
|
452
|
-
end
|
453
|
-
end
|
454
|
-
|
455
|
-
context "and metadata redefinition after `described_class` call" do
|
456
|
-
it "is the redefined level constant" do
|
457
|
-
group = ExampleGroup.describe(String) do
|
458
|
-
described_class
|
459
|
-
metadata[:example_group][:described_class] = Object
|
460
|
-
describe :symbol do
|
461
|
-
example "described_class is Object" do
|
462
|
-
expect(described_class).to eq(Object)
|
463
|
-
end
|
464
|
-
end
|
465
|
-
end
|
466
|
-
|
467
|
-
expect(group.run).to be_truthy
|
468
|
-
end
|
469
|
-
end
|
470
|
-
end
|
471
|
-
|
472
|
-
context "in a nested group" do
|
473
|
-
it "inherits the described class/module from the outer group" do
|
474
|
-
group = ExampleGroup.describe(String) do
|
475
|
-
describe Array do
|
476
|
-
example "describes is String" do
|
477
|
-
expect(described_class).to eq(String)
|
478
|
-
end
|
479
|
-
end
|
480
|
-
end
|
481
|
-
|
482
|
-
expect(group.run).to be_truthy, "expected examples in group to pass"
|
483
|
-
end
|
484
|
-
end
|
485
|
-
|
486
|
-
context "for `describe(SomeClass)` within a `describe 'some string' group" do
|
487
|
-
def define_and_run_group(define_outer_example = false)
|
488
|
-
outer_described_class = inner_described_class = nil
|
489
|
-
|
490
|
-
ExampleGroup.describe("some string") do
|
491
|
-
example { outer_described_class = described_class } if define_outer_example
|
492
|
-
|
493
|
-
describe Array do
|
494
|
-
example { inner_described_class = described_class }
|
495
|
-
end
|
496
|
-
end.run
|
497
|
-
|
498
|
-
return outer_described_class, inner_described_class
|
499
|
-
end
|
500
|
-
|
501
|
-
it "has a `nil` described_class in the outer group" do
|
502
|
-
outer_described_class, _ = define_and_run_group(:define_outer_example)
|
503
|
-
expect(outer_described_class).to be(nil)
|
504
|
-
end
|
505
|
-
|
506
|
-
it "has the inner described class as the described_class of the inner group" do
|
507
|
-
_, inner_described_class = define_and_run_group
|
508
|
-
expect(inner_described_class).to be(Array)
|
509
|
-
|
510
|
-
# This is weird, but in RSpec 2.12 (and before, presumably),
|
511
|
-
# the `described_class` value would be incorrect if there was an
|
512
|
-
# example in the outer group, and correct if there was not one.
|
513
|
-
_, inner_described_class = define_and_run_group(:define_outer_example)
|
514
|
-
expect(inner_described_class).to be(Array)
|
515
|
-
end
|
516
|
-
end
|
517
|
-
end
|
518
|
-
|
519
|
-
describe '#described_class' do
|
520
|
-
it "is the same as described_class" do
|
521
|
-
expect(self.class.described_class).to eq(self.class.described_class)
|
522
|
-
end
|
523
|
-
end
|
524
|
-
|
525
|
-
describe '#description' do
|
526
|
-
it "grabs the description from the metadata" do
|
527
|
-
group = ExampleGroup.describe(Object, "my desc") { }
|
528
|
-
expect(group.description).to eq(group.metadata[:example_group][:description])
|
529
|
-
end
|
530
|
-
end
|
531
|
-
|
532
|
-
describe '#metadata' do
|
533
|
-
it "adds the third parameter to the metadata" do
|
534
|
-
expect(ExampleGroup.describe(Object, nil, 'foo' => 'bar') { }.metadata).to include({ "foo" => 'bar' })
|
535
|
-
end
|
536
|
-
|
537
|
-
it "adds the the file_path to metadata" do
|
538
|
-
expect(ExampleGroup.describe(Object) { }.metadata[:example_group][:file_path]).to eq(relative_path(__FILE__))
|
539
|
-
end
|
540
|
-
|
541
|
-
it "has a reader for file_path" do
|
542
|
-
expect(ExampleGroup.describe(Object) { }.file_path).to eq(relative_path(__FILE__))
|
543
|
-
end
|
544
|
-
|
545
|
-
it "adds the line_number to metadata" do
|
546
|
-
expect(ExampleGroup.describe(Object) { }.metadata[:example_group][:line_number]).to eq(__LINE__)
|
547
|
-
end
|
548
|
-
end
|
549
|
-
|
550
|
-
[:focus, :focused, :fit].each do |example_alias|
|
551
|
-
describe "##{example_alias}" do
|
552
|
-
let(:focused_example) { ExampleGroup.describe.send example_alias, "a focused example" }
|
553
|
-
|
554
|
-
it 'defines an example that can be filtered with :focused => true' do
|
555
|
-
expect(focused_example.metadata[:focused]).to be_truthy
|
556
|
-
end
|
557
|
-
|
558
|
-
it 'defines an example that can be filtered with :focus => true' do
|
559
|
-
expect(focused_example.metadata[:focus]).to be_truthy
|
560
|
-
end
|
561
|
-
end
|
562
|
-
end
|
563
|
-
|
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
|
-
|
611
|
-
it "runs the before alls in order" do
|
612
|
-
group = ExampleGroup.describe
|
613
|
-
order = []
|
614
|
-
group.before(:all) { order << 1 }
|
615
|
-
group.before(:all) { order << 2 }
|
616
|
-
group.before(:all) { order << 3 }
|
617
|
-
group.example("example") {}
|
618
|
-
|
619
|
-
group.run
|
620
|
-
|
621
|
-
expect(order).to eq([1,2,3])
|
622
|
-
end
|
623
|
-
|
624
|
-
it "does not set RSpec.wants_to_quit in case of an error in before all (without fail_fast?)" do
|
625
|
-
group = ExampleGroup.describe
|
626
|
-
group.before(:all) { raise "error in before all" }
|
627
|
-
group.example("example") {}
|
628
|
-
|
629
|
-
group.run
|
630
|
-
expect(RSpec.wants_to_quit).to be_falsey
|
631
|
-
end
|
632
|
-
|
633
|
-
it "runs the before eachs in order" do
|
634
|
-
group = ExampleGroup.describe
|
635
|
-
order = []
|
636
|
-
group.before(:each) { order << 1 }
|
637
|
-
group.before(:each) { order << 2 }
|
638
|
-
group.before(:each) { order << 3 }
|
639
|
-
group.example("example") {}
|
640
|
-
|
641
|
-
group.run
|
642
|
-
|
643
|
-
expect(order).to eq([1,2,3])
|
644
|
-
end
|
645
|
-
|
646
|
-
it "runs the after eachs in reverse order" do
|
647
|
-
group = ExampleGroup.describe
|
648
|
-
order = []
|
649
|
-
group.after(:each) { order << 1 }
|
650
|
-
group.after(:each) { order << 2 }
|
651
|
-
group.after(:each) { order << 3 }
|
652
|
-
group.example("example") {}
|
653
|
-
|
654
|
-
group.run
|
655
|
-
|
656
|
-
expect(order).to eq([3,2,1])
|
657
|
-
end
|
658
|
-
|
659
|
-
it "runs the after alls in reverse order" do
|
660
|
-
group = ExampleGroup.describe
|
661
|
-
order = []
|
662
|
-
group.after(:all) { order << 1 }
|
663
|
-
group.after(:all) { order << 2 }
|
664
|
-
group.after(:all) { order << 3 }
|
665
|
-
group.example("example") {}
|
666
|
-
|
667
|
-
group.run
|
668
|
-
|
669
|
-
expect(order).to eq([3,2,1])
|
670
|
-
end
|
671
|
-
|
672
|
-
it "only runs before/after(:all) hooks from example groups that have specs that run" do
|
673
|
-
hooks_run = []
|
674
|
-
|
675
|
-
RSpec.configure do |c|
|
676
|
-
c.filter_run :focus => true
|
677
|
-
end
|
678
|
-
|
679
|
-
unfiltered_group = ExampleGroup.describe "unfiltered" do
|
680
|
-
before(:all) { hooks_run << :unfiltered_before_all }
|
681
|
-
after(:all) { hooks_run << :unfiltered_after_all }
|
682
|
-
|
683
|
-
context "a subcontext" do
|
684
|
-
it("has an example") { }
|
685
|
-
end
|
686
|
-
end
|
687
|
-
|
688
|
-
filtered_group = ExampleGroup.describe "filtered", :focus => true do
|
689
|
-
before(:all) { hooks_run << :filtered_before_all }
|
690
|
-
after(:all) { hooks_run << :filtered_after_all }
|
691
|
-
|
692
|
-
context "a subcontext" do
|
693
|
-
it("has an example") { }
|
694
|
-
end
|
695
|
-
end
|
696
|
-
|
697
|
-
unfiltered_group.run
|
698
|
-
filtered_group.run
|
699
|
-
|
700
|
-
expect(hooks_run).to eq([:filtered_before_all, :filtered_after_all])
|
701
|
-
end
|
702
|
-
|
703
|
-
it "runs before_all_defined_in_config, before all, before each, example, after each, after all, after_all_defined_in_config in that order" do
|
704
|
-
order = []
|
705
|
-
|
706
|
-
RSpec.configure do |c|
|
707
|
-
c.before(:all) { order << :before_all_defined_in_config }
|
708
|
-
c.after(:all) { order << :after_all_defined_in_config }
|
709
|
-
end
|
710
|
-
|
711
|
-
group = ExampleGroup.describe
|
712
|
-
group.before(:all) { order << :top_level_before_all }
|
713
|
-
group.before(:each) { order << :before_each }
|
714
|
-
group.after(:each) { order << :after_each }
|
715
|
-
group.after(:all) { order << :top_level_after_all }
|
716
|
-
group.example("top level example") { order << :top_level_example }
|
717
|
-
|
718
|
-
context1 = group.describe("context 1")
|
719
|
-
context1.before(:all) { order << :nested_before_all }
|
720
|
-
context1.example("nested example 1") { order << :nested_example_1 }
|
721
|
-
|
722
|
-
context2 = group.describe("context 2")
|
723
|
-
context2.after(:all) { order << :nested_after_all }
|
724
|
-
context2.example("nested example 2") { order << :nested_example_2 }
|
725
|
-
|
726
|
-
group.run
|
727
|
-
|
728
|
-
expect(order).to eq([
|
729
|
-
:before_all_defined_in_config,
|
730
|
-
:top_level_before_all,
|
731
|
-
:before_each,
|
732
|
-
:top_level_example,
|
733
|
-
:after_each,
|
734
|
-
:nested_before_all,
|
735
|
-
:before_each,
|
736
|
-
:nested_example_1,
|
737
|
-
:after_each,
|
738
|
-
:before_each,
|
739
|
-
:nested_example_2,
|
740
|
-
:after_each,
|
741
|
-
:nested_after_all,
|
742
|
-
:top_level_after_all,
|
743
|
-
:after_all_defined_in_config
|
744
|
-
])
|
745
|
-
end
|
746
|
-
|
747
|
-
context "after(:all)" do
|
748
|
-
let(:outer) { ExampleGroup.describe }
|
749
|
-
let(:inner) { outer.describe }
|
750
|
-
|
751
|
-
it "has access to state defined before(:all)" do
|
752
|
-
outer.before(:all) { @outer = "outer" }
|
753
|
-
inner.before(:all) { @inner = "inner" }
|
754
|
-
|
755
|
-
outer.after(:all) do
|
756
|
-
expect(@outer).to eq("outer")
|
757
|
-
expect(@inner).to eq("inner")
|
758
|
-
end
|
759
|
-
inner.after(:all) do
|
760
|
-
expect(@inner).to eq("inner")
|
761
|
-
expect(@outer).to eq("outer")
|
762
|
-
end
|
763
|
-
|
764
|
-
outer.run
|
765
|
-
end
|
766
|
-
|
767
|
-
it "cleans up ivars in after(:all)" do
|
768
|
-
outer.before(:all) { @outer = "outer" }
|
769
|
-
inner.before(:all) { @inner = "inner" }
|
770
|
-
|
771
|
-
outer.run
|
772
|
-
|
773
|
-
expect(inner.before_all_ivars[:@inner]).to be_nil
|
774
|
-
expect(inner.before_all_ivars[:@outer]).to be_nil
|
775
|
-
expect(outer.before_all_ivars[:@inner]).to be_nil
|
776
|
-
expect(outer.before_all_ivars[:@outer]).to be_nil
|
777
|
-
end
|
778
|
-
end
|
779
|
-
|
780
|
-
it "treats an error in before(:each) as a failure" do
|
781
|
-
group = ExampleGroup.describe
|
782
|
-
group.before(:each) { raise "error in before each" }
|
783
|
-
example = group.example("equality") { expect(1).to eq(2) }
|
784
|
-
expect(group.run).to be(false)
|
785
|
-
|
786
|
-
expect(example.metadata[:execution_result][:exception].message).to eq("error in before each")
|
787
|
-
end
|
788
|
-
|
789
|
-
it "treats an error in before(:all) as a failure" do
|
790
|
-
group = ExampleGroup.describe
|
791
|
-
group.before(:all) { raise "error in before all" }
|
792
|
-
example = group.example("equality") { expect(1).to eq(2) }
|
793
|
-
expect(group.run).to be_falsey
|
794
|
-
|
795
|
-
expect(example.metadata).not_to be_nil
|
796
|
-
expect(example.metadata[:execution_result]).not_to be_nil
|
797
|
-
expect(example.metadata[:execution_result][:exception]).not_to be_nil
|
798
|
-
expect(example.metadata[:execution_result][:exception].message).to eq("error in before all")
|
799
|
-
end
|
800
|
-
|
801
|
-
it "exposes instance variables set in before(:all) from after(:all) even if a before(:all) error occurs" do
|
802
|
-
ivar_value_in_after_hook = nil
|
803
|
-
|
804
|
-
group = ExampleGroup.describe do
|
805
|
-
before(:all) do
|
806
|
-
@an_ivar = :set_in_before_all
|
807
|
-
raise "fail"
|
808
|
-
end
|
809
|
-
|
810
|
-
after(:all) { ivar_value_in_after_hook = @an_ivar }
|
811
|
-
|
812
|
-
it("has a spec") { }
|
813
|
-
end
|
814
|
-
|
815
|
-
group.run
|
816
|
-
expect(ivar_value_in_after_hook).to eq(:set_in_before_all)
|
817
|
-
end
|
818
|
-
|
819
|
-
it "treats an error in before(:all) as a failure for a spec in a nested group" do
|
820
|
-
example = nil
|
821
|
-
group = ExampleGroup.describe do
|
822
|
-
before(:all) { raise "error in before all" }
|
823
|
-
|
824
|
-
describe "nested" do
|
825
|
-
example = it("equality") { expect(1).to eq(2) }
|
826
|
-
end
|
827
|
-
end
|
828
|
-
group.run
|
829
|
-
|
830
|
-
expect(example.metadata).not_to be_nil
|
831
|
-
expect(example.metadata[:execution_result]).not_to be_nil
|
832
|
-
expect(example.metadata[:execution_result][:exception]).not_to be_nil
|
833
|
-
expect(example.metadata[:execution_result][:exception].message).to eq("error in before all")
|
834
|
-
end
|
835
|
-
|
836
|
-
context "when an error occurs in an after(:all) hook" do
|
837
|
-
hooks_run = []
|
838
|
-
|
839
|
-
before(:each) do
|
840
|
-
hooks_run = []
|
841
|
-
allow(RSpec.configuration.reporter).to receive(:message)
|
842
|
-
end
|
843
|
-
|
844
|
-
let(:group) do
|
845
|
-
ExampleGroup.describe do
|
846
|
-
after(:all) { hooks_run << :one; raise "An error in an after(:all) hook" }
|
847
|
-
after(:all) { hooks_run << :two; raise "A different hook raising an error" }
|
848
|
-
it("equality") { expect(1).to eq(1) }
|
849
|
-
end
|
850
|
-
end
|
851
|
-
|
852
|
-
it "allows the example to pass" do
|
853
|
-
group.run
|
854
|
-
example = group.examples.first
|
855
|
-
expect(example.metadata).not_to be_nil
|
856
|
-
expect(example.metadata[:execution_result]).not_to be_nil
|
857
|
-
expect(example.metadata[:execution_result][:status]).to eq("passed")
|
858
|
-
end
|
859
|
-
|
860
|
-
it "rescues any error(s) and prints them out" do
|
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/)
|
863
|
-
group.run
|
864
|
-
end
|
865
|
-
|
866
|
-
it "still runs both after blocks" do
|
867
|
-
group.run
|
868
|
-
expect(hooks_run).to eq [:two,:one]
|
869
|
-
end
|
870
|
-
end
|
871
|
-
|
872
|
-
it "has access to example options within before(:each)" do
|
873
|
-
group = ExampleGroup.describe
|
874
|
-
option = nil
|
875
|
-
group.before(:each) {|ex| option = ex.options[:data] }
|
876
|
-
group.example("no-op", :data => :sample) { }
|
877
|
-
group.run
|
878
|
-
expect(option).to eq(:sample)
|
879
|
-
end
|
880
|
-
|
881
|
-
it "has access to example options within after(:each)" do
|
882
|
-
group = ExampleGroup.describe
|
883
|
-
option = nil
|
884
|
-
group.after(:each) {|ex| option = ex.options[:data] }
|
885
|
-
group.example("no-op", :data => :sample) { }
|
886
|
-
group.run
|
887
|
-
expect(option).to eq(:sample)
|
888
|
-
end
|
889
|
-
end
|
890
|
-
|
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
|
992
|
-
end
|
993
|
-
|
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}")
|
997
|
-
end
|
998
|
-
end
|
999
|
-
end
|
1000
|
-
|
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
|
1007
|
-
end
|
1008
|
-
|
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)
|
1022
|
-
end
|
1023
|
-
end
|
1024
|
-
end
|
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
|
-
|
1083
|
-
describe "adding examples" do
|
1084
|
-
|
1085
|
-
it "allows adding an example using 'it'" do
|
1086
|
-
group = ExampleGroup.describe
|
1087
|
-
group.it("should do something") { }
|
1088
|
-
expect(group.examples.size).to eq(1)
|
1089
|
-
end
|
1090
|
-
|
1091
|
-
it "exposes all examples at examples" do
|
1092
|
-
group = ExampleGroup.describe
|
1093
|
-
group.it("should do something 1") { }
|
1094
|
-
group.it("should do something 2") { }
|
1095
|
-
group.it("should do something 3") { }
|
1096
|
-
expect(group.examples.count).to eq(3)
|
1097
|
-
end
|
1098
|
-
|
1099
|
-
it "maintains the example order" do
|
1100
|
-
group = ExampleGroup.describe
|
1101
|
-
group.it("should 1") { }
|
1102
|
-
group.it("should 2") { }
|
1103
|
-
group.it("should 3") { }
|
1104
|
-
expect(group.examples[0].description).to eq('should 1')
|
1105
|
-
expect(group.examples[1].description).to eq('should 2')
|
1106
|
-
expect(group.examples[2].description).to eq('should 3')
|
1107
|
-
end
|
1108
|
-
|
1109
|
-
end
|
1110
|
-
|
1111
|
-
describe Object, "describing nested example_groups", :little_less_nested => 'yep' do
|
1112
|
-
|
1113
|
-
describe "A sample nested group", :nested_describe => "yep" do
|
1114
|
-
it "sets the described class to the described class of the outer most group" do |ex|
|
1115
|
-
expect(ex.example_group.described_class).to eq(ExampleGroup)
|
1116
|
-
end
|
1117
|
-
|
1118
|
-
it "sets the description to 'A sample nested describe'" do |ex|
|
1119
|
-
expect(ex.example_group.description).to eq('A sample nested group')
|
1120
|
-
end
|
1121
|
-
|
1122
|
-
it "has top level metadata from the example_group and its parent groups" do |ex|
|
1123
|
-
expect(ex.example_group.metadata).to include(:little_less_nested => 'yep', :nested_describe => 'yep')
|
1124
|
-
end
|
1125
|
-
|
1126
|
-
it "exposes the parent metadata to the contained examples" do |ex|
|
1127
|
-
expect(ex.metadata).to include(:little_less_nested => 'yep', :nested_describe => 'yep')
|
1128
|
-
end
|
1129
|
-
end
|
1130
|
-
|
1131
|
-
end
|
1132
|
-
|
1133
|
-
describe "#run_examples" do
|
1134
|
-
|
1135
|
-
let(:reporter) { double("reporter").as_null_object }
|
1136
|
-
|
1137
|
-
it "returns true if all examples pass" do
|
1138
|
-
group = ExampleGroup.describe('group') do
|
1139
|
-
example('ex 1') { expect(1).to eq(1) }
|
1140
|
-
example('ex 2') { expect(1).to eq(1) }
|
1141
|
-
end
|
1142
|
-
allow(group).to receive(:filtered_examples) { group.examples }
|
1143
|
-
expect(group.run(reporter)).to be_truthy
|
1144
|
-
end
|
1145
|
-
|
1146
|
-
it "returns false if any of the examples fail" do
|
1147
|
-
group = ExampleGroup.describe('group') do
|
1148
|
-
example('ex 1') { expect(1).to eq(1) }
|
1149
|
-
example('ex 2') { expect(1).to eq(2) }
|
1150
|
-
end
|
1151
|
-
allow(group).to receive(:filtered_examples) { group.examples }
|
1152
|
-
expect(group.run(reporter)).to be_falsey
|
1153
|
-
end
|
1154
|
-
|
1155
|
-
it "runs all examples, regardless of any of them failing" do
|
1156
|
-
group = ExampleGroup.describe('group') do
|
1157
|
-
example('ex 1') { expect(1).to eq(2) }
|
1158
|
-
example('ex 2') { expect(1).to eq(1) }
|
1159
|
-
end
|
1160
|
-
allow(group).to receive(:filtered_examples) { group.examples }
|
1161
|
-
group.filtered_examples.each do |example|
|
1162
|
-
expect(example).to receive(:run)
|
1163
|
-
end
|
1164
|
-
expect(group.run(reporter)).to be_falsey
|
1165
|
-
end
|
1166
|
-
end
|
1167
|
-
|
1168
|
-
describe "how instance variables are inherited" do
|
1169
|
-
before(:all) do
|
1170
|
-
@before_all_top_level = 'before_all_top_level'
|
1171
|
-
end
|
1172
|
-
|
1173
|
-
before(:each) do
|
1174
|
-
@before_each_top_level = 'before_each_top_level'
|
1175
|
-
end
|
1176
|
-
|
1177
|
-
it "can access a before each ivar at the same level" do
|
1178
|
-
expect(@before_each_top_level).to eq('before_each_top_level')
|
1179
|
-
end
|
1180
|
-
|
1181
|
-
it "can access a before all ivar at the same level" do
|
1182
|
-
expect(@before_all_top_level).to eq('before_all_top_level')
|
1183
|
-
end
|
1184
|
-
|
1185
|
-
it "can access the before all ivars in the before_all_ivars hash", :ruby => 1.8 do |ex|
|
1186
|
-
expect(ex.example_group.before_all_ivars).to include('@before_all_top_level' => 'before_all_top_level')
|
1187
|
-
end
|
1188
|
-
|
1189
|
-
it "can access the before all ivars in the before_all_ivars hash", :ruby => 1.9 do |ex|
|
1190
|
-
expect(ex.example_group.before_all_ivars).to include(:@before_all_top_level => 'before_all_top_level')
|
1191
|
-
end
|
1192
|
-
|
1193
|
-
describe "but now I am nested" do
|
1194
|
-
it "can access a parent example groups before each ivar at a nested level" do
|
1195
|
-
expect(@before_each_top_level).to eq('before_each_top_level')
|
1196
|
-
end
|
1197
|
-
|
1198
|
-
it "can access a parent example groups before all ivar at a nested level" do
|
1199
|
-
expect(@before_all_top_level).to eq("before_all_top_level")
|
1200
|
-
end
|
1201
|
-
|
1202
|
-
it "changes to before all ivars from within an example do not persist outside the current describe" do
|
1203
|
-
@before_all_top_level = "ive been changed"
|
1204
|
-
end
|
1205
|
-
|
1206
|
-
describe "accessing a before_all ivar that was changed in a parent example_group" do
|
1207
|
-
it "does not have access to the modified version" do
|
1208
|
-
expect(@before_all_top_level).to eq('before_all_top_level')
|
1209
|
-
end
|
1210
|
-
end
|
1211
|
-
end
|
1212
|
-
|
1213
|
-
end
|
1214
|
-
|
1215
|
-
describe "ivars are not shared across examples" do
|
1216
|
-
it "(first example)" do
|
1217
|
-
@a = 1
|
1218
|
-
expect(defined?(@b)).to be_falsey
|
1219
|
-
end
|
1220
|
-
|
1221
|
-
it "(second example)" do
|
1222
|
-
@b = 2
|
1223
|
-
expect(defined?(@a)).to be_falsey
|
1224
|
-
end
|
1225
|
-
end
|
1226
|
-
|
1227
|
-
|
1228
|
-
describe "#top_level_description" do
|
1229
|
-
it "returns the description from the outermost example group" do
|
1230
|
-
group = nil
|
1231
|
-
ExampleGroup.describe("top") do
|
1232
|
-
context "middle" do
|
1233
|
-
group = describe "bottom" do
|
1234
|
-
end
|
1235
|
-
end
|
1236
|
-
end
|
1237
|
-
|
1238
|
-
expect(group.top_level_description).to eq("top")
|
1239
|
-
end
|
1240
|
-
end
|
1241
|
-
|
1242
|
-
describe "#run" do
|
1243
|
-
let(:reporter) { double("reporter").as_null_object }
|
1244
|
-
|
1245
|
-
context "with fail_fast? => true" do
|
1246
|
-
let(:group) do
|
1247
|
-
group = RSpec::Core::ExampleGroup.describe
|
1248
|
-
allow(group).to receive(:fail_fast?) { true }
|
1249
|
-
group
|
1250
|
-
end
|
1251
|
-
|
1252
|
-
it "does not run examples after the failed example" do
|
1253
|
-
examples_run = []
|
1254
|
-
group.example('example 1') { examples_run << self }
|
1255
|
-
group.example('example 2') { examples_run << self; fail; }
|
1256
|
-
group.example('example 3') { examples_run << self }
|
1257
|
-
|
1258
|
-
group.run
|
1259
|
-
|
1260
|
-
expect(examples_run.length).to eq(2)
|
1261
|
-
end
|
1262
|
-
|
1263
|
-
it "sets RSpec.wants_to_quit flag if encountering an exception in before(:all)" do
|
1264
|
-
group.before(:all) { raise "error in before all" }
|
1265
|
-
group.example("equality") { expect(1).to eq(2) }
|
1266
|
-
expect(group.run).to be_falsey
|
1267
|
-
expect(RSpec.wants_to_quit).to be_truthy
|
1268
|
-
end
|
1269
|
-
end
|
1270
|
-
|
1271
|
-
context "with RSpec.wants_to_quit=true" do
|
1272
|
-
let(:group) { RSpec::Core::ExampleGroup.describe }
|
1273
|
-
|
1274
|
-
before do
|
1275
|
-
allow(RSpec).to receive(:wants_to_quit) { true }
|
1276
|
-
allow(RSpec).to receive(:clear_remaining_example_groups)
|
1277
|
-
end
|
1278
|
-
|
1279
|
-
it "returns without starting the group" do
|
1280
|
-
expect(reporter).not_to receive(:example_group_started)
|
1281
|
-
group.run(reporter)
|
1282
|
-
end
|
1283
|
-
|
1284
|
-
context "at top level" do
|
1285
|
-
it "purges remaining groups" do
|
1286
|
-
expect(RSpec).to receive(:clear_remaining_example_groups)
|
1287
|
-
group.run(reporter)
|
1288
|
-
end
|
1289
|
-
end
|
1290
|
-
|
1291
|
-
context "in a nested group" do
|
1292
|
-
it "does not purge remaining groups" do
|
1293
|
-
nested_group = group.describe
|
1294
|
-
expect(RSpec).not_to receive(:clear_remaining_example_groups)
|
1295
|
-
nested_group.run(reporter)
|
1296
|
-
end
|
1297
|
-
end
|
1298
|
-
end
|
1299
|
-
|
1300
|
-
context "with all examples passing" do
|
1301
|
-
it "returns true" do
|
1302
|
-
group = RSpec::Core::ExampleGroup.describe("something") do
|
1303
|
-
it "does something" do
|
1304
|
-
# pass
|
1305
|
-
end
|
1306
|
-
describe "nested" do
|
1307
|
-
it "does something else" do
|
1308
|
-
# pass
|
1309
|
-
end
|
1310
|
-
end
|
1311
|
-
end
|
1312
|
-
|
1313
|
-
expect(group.run(reporter)).to be_truthy
|
1314
|
-
end
|
1315
|
-
end
|
1316
|
-
|
1317
|
-
context "with top level example failing" do
|
1318
|
-
it "returns false" do
|
1319
|
-
group = RSpec::Core::ExampleGroup.describe("something") do
|
1320
|
-
it "does something (wrong - fail)" do
|
1321
|
-
raise "fail"
|
1322
|
-
end
|
1323
|
-
describe "nested" do
|
1324
|
-
it "does something else" do
|
1325
|
-
# pass
|
1326
|
-
end
|
1327
|
-
end
|
1328
|
-
end
|
1329
|
-
|
1330
|
-
expect(group.run(reporter)).to be_falsey
|
1331
|
-
end
|
1332
|
-
end
|
1333
|
-
|
1334
|
-
context "with nested example failing" do
|
1335
|
-
it "returns true" do
|
1336
|
-
group = RSpec::Core::ExampleGroup.describe("something") do
|
1337
|
-
it "does something" do
|
1338
|
-
# pass
|
1339
|
-
end
|
1340
|
-
describe "nested" do
|
1341
|
-
it "does something else (wrong -fail)" do
|
1342
|
-
raise "fail"
|
1343
|
-
end
|
1344
|
-
end
|
1345
|
-
end
|
1346
|
-
|
1347
|
-
expect(group.run(reporter)).to be_falsey
|
1348
|
-
end
|
1349
|
-
end
|
1350
|
-
end
|
1351
|
-
|
1352
|
-
%w[include_examples include_context].each do |name|
|
1353
|
-
describe "##{name}" do
|
1354
|
-
let(:group) { ExampleGroup.describe }
|
1355
|
-
before do
|
1356
|
-
group.shared_examples "named this" do
|
1357
|
-
example("does something") {}
|
1358
|
-
end
|
1359
|
-
end
|
1360
|
-
|
1361
|
-
it "includes the named examples" do
|
1362
|
-
group.send(name, "named this")
|
1363
|
-
expect(group.examples.first.description).to eq("does something")
|
1364
|
-
end
|
1365
|
-
|
1366
|
-
it "raises a helpful error message when shared content is not found" do
|
1367
|
-
expect do
|
1368
|
-
group.send(name, "shared stuff")
|
1369
|
-
end.to raise_error(ArgumentError, /Could not find .* "shared stuff"/)
|
1370
|
-
end
|
1371
|
-
|
1372
|
-
it "passes parameters to the shared content" do
|
1373
|
-
passed_params = {}
|
1374
|
-
group = ExampleGroup.describe
|
1375
|
-
|
1376
|
-
group.shared_examples "named this with params" do |param1, param2|
|
1377
|
-
it("has access to the given parameters") do
|
1378
|
-
passed_params[:param1] = param1
|
1379
|
-
passed_params[:param2] = param2
|
1380
|
-
end
|
1381
|
-
end
|
1382
|
-
|
1383
|
-
group.send(name, "named this with params", :value1, :value2)
|
1384
|
-
group.run
|
1385
|
-
|
1386
|
-
expect(passed_params).to eq({ :param1 => :value1, :param2 => :value2 })
|
1387
|
-
end
|
1388
|
-
|
1389
|
-
it "adds shared instance methods to the group" do
|
1390
|
-
group = ExampleGroup.describe('fake group')
|
1391
|
-
group.shared_examples "named this with params" do |param1|
|
1392
|
-
def foo; end
|
1393
|
-
end
|
1394
|
-
group.send(name, "named this with params", :a)
|
1395
|
-
expect(group.public_instance_methods.map{|m| m.to_s}).to include("foo")
|
1396
|
-
end
|
1397
|
-
|
1398
|
-
it "evals the shared example group only once" do
|
1399
|
-
eval_count = 0
|
1400
|
-
group = ExampleGroup.describe('fake group')
|
1401
|
-
group.shared_examples("named this with params") { |p| eval_count += 1 }
|
1402
|
-
group.send(name, "named this with params", :a)
|
1403
|
-
expect(eval_count).to eq(1)
|
1404
|
-
end
|
1405
|
-
|
1406
|
-
it "evals the block when given" do
|
1407
|
-
key = "#{__FILE__}:#{__LINE__}"
|
1408
|
-
group = ExampleGroup.describe do
|
1409
|
-
shared_examples(key) do
|
1410
|
-
it("does something") do
|
1411
|
-
expect(foo).to eq("bar")
|
1412
|
-
end
|
1413
|
-
end
|
1414
|
-
|
1415
|
-
send name, key do
|
1416
|
-
def foo; "bar"; end
|
1417
|
-
end
|
1418
|
-
end
|
1419
|
-
expect(group.run).to be_truthy
|
1420
|
-
end
|
1421
|
-
end
|
1422
|
-
end
|
1423
|
-
|
1424
|
-
describe "#it_should_behave_like" do
|
1425
|
-
it "creates a nested group" do
|
1426
|
-
group = ExampleGroup.describe('fake group')
|
1427
|
-
group.shared_examples_for("thing") {}
|
1428
|
-
group.it_should_behave_like("thing")
|
1429
|
-
expect(group.children.count).to eq(1)
|
1430
|
-
end
|
1431
|
-
|
1432
|
-
it "creates a nested group for a class" do
|
1433
|
-
klass = Class.new
|
1434
|
-
group = ExampleGroup.describe('fake group')
|
1435
|
-
group.shared_examples_for(klass) {}
|
1436
|
-
group.it_should_behave_like(klass)
|
1437
|
-
expect(group.children.count).to eq(1)
|
1438
|
-
end
|
1439
|
-
|
1440
|
-
it "adds shared examples to nested group" do
|
1441
|
-
group = ExampleGroup.describe('fake group')
|
1442
|
-
group.shared_examples_for("thing") do
|
1443
|
-
it("does something")
|
1444
|
-
end
|
1445
|
-
shared_group = group.it_should_behave_like("thing")
|
1446
|
-
expect(shared_group.examples.count).to eq(1)
|
1447
|
-
end
|
1448
|
-
|
1449
|
-
it "adds shared instance methods to nested group" do
|
1450
|
-
group = ExampleGroup.describe('fake group')
|
1451
|
-
group.shared_examples_for("thing") do
|
1452
|
-
def foo; end
|
1453
|
-
end
|
1454
|
-
shared_group = group.it_should_behave_like("thing")
|
1455
|
-
expect(shared_group.public_instance_methods.map{|m| m.to_s}).to include("foo")
|
1456
|
-
end
|
1457
|
-
|
1458
|
-
it "adds shared class methods to nested group" do
|
1459
|
-
group = ExampleGroup.describe('fake group')
|
1460
|
-
group.shared_examples_for("thing") do
|
1461
|
-
def self.foo; end
|
1462
|
-
end
|
1463
|
-
shared_group = group.it_should_behave_like("thing")
|
1464
|
-
expect(shared_group.methods.map{|m| m.to_s}).to include("foo")
|
1465
|
-
end
|
1466
|
-
|
1467
|
-
it "passes parameters to the shared example group" do
|
1468
|
-
passed_params = {}
|
1469
|
-
|
1470
|
-
group = ExampleGroup.describe("group") do
|
1471
|
-
shared_examples_for("thing") do |param1, param2|
|
1472
|
-
it("has access to the given parameters") do
|
1473
|
-
passed_params[:param1] = param1
|
1474
|
-
passed_params[:param2] = param2
|
1475
|
-
end
|
1476
|
-
end
|
1477
|
-
|
1478
|
-
it_should_behave_like "thing", :value1, :value2
|
1479
|
-
end
|
1480
|
-
|
1481
|
-
group.run
|
1482
|
-
|
1483
|
-
expect(passed_params).to eq({ :param1 => :value1, :param2 => :value2 })
|
1484
|
-
end
|
1485
|
-
|
1486
|
-
it "adds shared instance methods to nested group" do
|
1487
|
-
group = ExampleGroup.describe('fake group')
|
1488
|
-
group.shared_examples_for("thing") do |param1|
|
1489
|
-
def foo; end
|
1490
|
-
end
|
1491
|
-
shared_group = group.it_should_behave_like("thing", :a)
|
1492
|
-
expect(shared_group.public_instance_methods.map{|m| m.to_s}).to include("foo")
|
1493
|
-
end
|
1494
|
-
|
1495
|
-
it "evals the shared example group only once" do
|
1496
|
-
eval_count = 0
|
1497
|
-
group = ExampleGroup.describe('fake group')
|
1498
|
-
group.shared_examples_for("thing") { |p| eval_count += 1 }
|
1499
|
-
group.it_should_behave_like("thing", :a)
|
1500
|
-
expect(eval_count).to eq(1)
|
1501
|
-
end
|
1502
|
-
|
1503
|
-
context "given a block" do
|
1504
|
-
it "evaluates the block in nested group" do
|
1505
|
-
scopes = []
|
1506
|
-
group = ExampleGroup.describe("group") do
|
1507
|
-
shared_examples_for("thing") do
|
1508
|
-
it("gets run in the nested group") do
|
1509
|
-
scopes << self.class
|
1510
|
-
end
|
1511
|
-
end
|
1512
|
-
it_should_behave_like "thing" do
|
1513
|
-
it("gets run in the same nested group") do
|
1514
|
-
scopes << self.class
|
1515
|
-
end
|
1516
|
-
end
|
1517
|
-
end
|
1518
|
-
group.run
|
1519
|
-
|
1520
|
-
expect(scopes[0]).to be(scopes[1])
|
1521
|
-
end
|
1522
|
-
end
|
1523
|
-
|
1524
|
-
it "raises a helpful error message when shared context is not found" do
|
1525
|
-
expect do
|
1526
|
-
ExampleGroup.describe do
|
1527
|
-
it_should_behave_like "shared stuff"
|
1528
|
-
end
|
1529
|
-
end.to raise_error(ArgumentError,%q|Could not find shared examples "shared stuff"|)
|
1530
|
-
end
|
1531
|
-
end
|
1532
|
-
end
|
1533
|
-
end
|