rspec-core 2.12.2 → 2.13.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.
- data/Changelog.md +31 -0
- data/README.md +11 -10
- data/features/command_line/example_name_option.feature +6 -10
- data/features/command_line/tag.feature +15 -8
- data/features/configuration/backtrace_clean_patterns.feature +102 -0
- data/features/configuration/failure_exit_code.feature +36 -0
- data/features/configuration/order_and_seed.feature +3 -0
- data/features/configuration/output_stream.feature +24 -0
- data/features/configuration/pattern.feature +30 -0
- data/features/configuration/profile.feature +163 -0
- data/features/configuration/run_all_when_everything_filtered.feature +60 -0
- data/features/configuration/show_failures_in_pending_blocks.feature +61 -0
- data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +52 -0
- data/features/filtering/exclusion_filters.feature +1 -2
- data/features/formatters/configurable_colors.feature +31 -0
- data/features/step_definitions/additional_cli_steps.rb +21 -0
- data/features/subject/explicit_subject.feature +19 -0
- data/lib/autotest/rspec2.rb +1 -1
- data/lib/rspec/core.rb +1 -2
- data/lib/rspec/core/configuration.rb +33 -3
- data/lib/rspec/core/configuration_options.rb +5 -5
- data/lib/rspec/core/deprecation.rb +1 -1
- data/lib/rspec/core/example.rb +2 -2
- data/lib/rspec/core/example_group.rb +1 -3
- data/lib/rspec/core/formatters/base_text_formatter.rb +93 -27
- data/lib/rspec/core/formatters/documentation_formatter.rb +3 -3
- data/lib/rspec/core/formatters/progress_formatter.rb +3 -3
- data/lib/rspec/core/memoized_helpers.rb +425 -0
- data/lib/rspec/core/metadata.rb +6 -2
- data/lib/rspec/core/option_parser.rb +8 -2
- data/lib/rspec/core/pending.rb +7 -0
- data/lib/rspec/core/shared_context.rb +1 -1
- data/lib/rspec/core/version.rb +1 -1
- data/spec/autotest/failed_results_re_spec.rb +4 -4
- data/spec/autotest/rspec_spec.rb +25 -20
- data/spec/command_line/order_spec.rb +21 -21
- data/spec/rspec/core/command_line_spec.rb +6 -6
- data/spec/rspec/core/configuration_options_spec.rb +86 -72
- data/spec/rspec/core/configuration_spec.rb +161 -156
- data/spec/rspec/core/deprecations_spec.rb +4 -4
- data/spec/rspec/core/drb_command_line_spec.rb +9 -9
- data/spec/rspec/core/drb_options_spec.rb +46 -33
- data/spec/rspec/core/dsl_spec.rb +3 -3
- data/spec/rspec/core/example_group_spec.rb +156 -124
- data/spec/rspec/core/example_spec.rb +68 -52
- data/spec/rspec/core/filter_manager_spec.rb +36 -36
- data/spec/rspec/core/formatters/base_formatter_spec.rb +9 -9
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +104 -42
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +4 -4
- data/spec/rspec/core/formatters/helpers_spec.rb +13 -13
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +5 -17
- data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +159 -44
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +14 -14
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +20 -20
- data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +159 -44
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +20 -20
- data/spec/rspec/core/formatters/{html_formatted-1.9.2-jruby.html → html_formatted-2.0.0.html} +24 -18
- data/spec/rspec/core/formatters/html_formatter_spec.rb +9 -5
- data/spec/rspec/core/formatters/json_formatter_spec.rb +9 -9
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +4 -4
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +3 -3
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +5 -17
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-rbx.html +159 -44
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +16 -16
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +23 -23
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-jruby.html +5 -17
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3-rbx.html +159 -44
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +23 -23
- data/spec/rspec/core/formatters/{text_mate_formatted-1.9.2-jruby.html → text_mate_formatted-2.0.0.html} +25 -19
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +8 -4
- data/spec/rspec/core/hooks_filtering_spec.rb +16 -16
- data/spec/rspec/core/hooks_spec.rb +11 -11
- data/spec/rspec/core/kernel_extensions_spec.rb +1 -1
- data/spec/rspec/core/memoized_helpers_spec.rb +458 -0
- data/spec/rspec/core/metadata_spec.rb +74 -74
- data/spec/rspec/core/option_parser_spec.rb +27 -27
- data/spec/rspec/core/pending_example_spec.rb +32 -32
- data/spec/rspec/core/project_initializer_spec.rb +8 -8
- data/spec/rspec/core/rake_task_spec.rb +16 -16
- data/spec/rspec/core/reporter_spec.rb +3 -3
- data/spec/rspec/core/resources/formatter_specs.rb +4 -4
- data/spec/rspec/core/ruby_project_spec.rb +4 -2
- data/spec/rspec/core/shared_context_spec.rb +34 -7
- data/spec/rspec/core/shared_example_group_spec.rb +14 -14
- data/spec/rspec/core/world_spec.rb +9 -9
- data/spec/rspec/core_spec.rb +5 -5
- data/spec/spec_helper.rb +4 -0
- data/spec/support/shared_example_groups.rb +4 -4
- data/spec/support/spec_files.rb +2 -2
- metadata +158 -150
- data/lib/rspec/core/let.rb +0 -110
- data/lib/rspec/core/subject.rb +0 -223
- data/spec/rspec/core/let_spec.rb +0 -55
- data/spec/rspec/core/subject_spec.rb +0 -255
|
@@ -9,7 +9,7 @@ describe "deprecations" do
|
|
|
9
9
|
|
|
10
10
|
it "returns RSpec" do
|
|
11
11
|
RSpec.stub(:warn_deprecation)
|
|
12
|
-
Spec.
|
|
12
|
+
expect(Spec).to eq(RSpec)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "doesn't include backward compatibility in const_missing backtrace" do
|
|
@@ -19,7 +19,7 @@ describe "deprecations" do
|
|
|
19
19
|
ConstantThatDoesNotExist
|
|
20
20
|
rescue Exception => exception
|
|
21
21
|
end
|
|
22
|
-
exception.backtrace.find { |l| l =~ /lib\/rspec\/core\/backward_compatibility/ }.
|
|
22
|
+
expect(exception.backtrace.find { |l| l =~ /lib\/rspec\/core\/backward_compatibility/ }).to be_nil
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -32,7 +32,7 @@ describe "deprecations" do
|
|
|
32
32
|
|
|
33
33
|
it "delegates to example" do
|
|
34
34
|
RSpec.stub(:warn_deprecation)
|
|
35
|
-
running_example.
|
|
35
|
+
expect(running_example).to eq(example)
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
end
|
|
@@ -68,7 +68,7 @@ describe "deprecations" do
|
|
|
68
68
|
Spec::Rake::ConstantThatDoesNotExist
|
|
69
69
|
rescue Exception => exception
|
|
70
70
|
end
|
|
71
|
-
exception.backtrace.find { |l| l =~ /lib\/rspec\/core\/backward_compatibility/ }.
|
|
71
|
+
expect(exception.backtrace.find { |l| l =~ /lib\/rspec\/core\/backward_compatibility/ }).to be_nil
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
|
|
@@ -20,7 +20,7 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
|
20
20
|
|
|
21
21
|
context "without server running" do
|
|
22
22
|
it "raises an error" do
|
|
23
|
-
|
|
23
|
+
expect { command_line.run(err, out) }.to raise_error(DRb::DRbConnError)
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -32,14 +32,14 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
|
32
32
|
context "without RSPEC_DRB environment variable set" do
|
|
33
33
|
it "defaults to 8989" do
|
|
34
34
|
with_RSPEC_DRB_set_to(nil) do
|
|
35
|
-
command_line.drb_port.
|
|
35
|
+
expect(command_line.drb_port).to eq(8989)
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "sets the DRb port" do
|
|
40
40
|
with_RSPEC_DRB_set_to(nil) do
|
|
41
|
-
command_line("--drb-port", "1234").drb_port.
|
|
42
|
-
command_line("--drb-port", "5678").drb_port.
|
|
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
43
|
end
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -48,7 +48,7 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
|
48
48
|
context "without config variable set" do
|
|
49
49
|
it "uses RSPEC_DRB value" do
|
|
50
50
|
with_RSPEC_DRB_set_to('9000') do
|
|
51
|
-
command_line.drb_port.
|
|
51
|
+
expect(command_line.drb_port).to eq("9000")
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
end
|
|
@@ -56,7 +56,7 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
|
56
56
|
context "and config variable set" do
|
|
57
57
|
it "uses configured value" do
|
|
58
58
|
with_RSPEC_DRB_set_to('9000') do
|
|
59
|
-
command_line(*%w[--drb-port 5678]).drb_port.
|
|
59
|
+
expect(command_line(*%w[--drb-port 5678]).drb_port).to eq(5678)
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -84,19 +84,19 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
|
84
84
|
|
|
85
85
|
it "returns 0 if spec passes" do
|
|
86
86
|
result = command_line("--drb-port", @drb_port, passing_spec_filename).run(err, out)
|
|
87
|
-
result.
|
|
87
|
+
expect(result).to be(0)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
it "returns 1 if spec fails" do
|
|
91
91
|
result = command_line("--drb-port", @drb_port, failing_spec_filename).run(err, out)
|
|
92
|
-
result.
|
|
92
|
+
expect(result).to be(1)
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
it "outputs colorized text when running with --colour option" do
|
|
96
96
|
pending "figure out a way to tell the output to say it's tty"
|
|
97
97
|
command_line(failing_spec_filename, "--color", "--drb-port", @drb_port).run(err, out)
|
|
98
98
|
out.rewind
|
|
99
|
-
out.read.
|
|
99
|
+
expect(out.read).to match /\e\[31m/m
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
end
|
|
@@ -7,116 +7,116 @@ describe RSpec::Core::DrbOptions, :isolated_directory => true, :isolated_home =>
|
|
|
7
7
|
describe "#drb_argv" do
|
|
8
8
|
it "preserves extra arguments" do
|
|
9
9
|
File.stub(:exist?) { false }
|
|
10
|
-
config_options_object(*%w[ a --drb b --color c ]).drb_argv.
|
|
10
|
+
expect(config_options_object(*%w[ a --drb b --color c ]).drb_argv).to match_array %w[ --color a b c ]
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
%w(--color --fail-fast --profile --backtrace --tty).each do |option|
|
|
14
14
|
it "includes #{option}" do
|
|
15
|
-
config_options_object("#{option}").drb_argv.
|
|
15
|
+
expect(config_options_object("#{option}").drb_argv).to include("#{option}")
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "includes --failure-exit-code" do
|
|
20
|
-
config_options_object(*%w[--failure-exit-code 2]).drb_argv.
|
|
20
|
+
expect(config_options_object(*%w[--failure-exit-code 2]).drb_argv).to include("--failure-exit-code", "2")
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it "includes --options" do
|
|
24
|
-
config_options_object(*%w[--options custom.opts]).drb_argv.
|
|
24
|
+
expect(config_options_object(*%w[--options custom.opts]).drb_argv).to include("--options", "custom.opts")
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
it "includes --order" do
|
|
28
|
-
config_options_object(*%w[--order random]).drb_argv.
|
|
28
|
+
expect(config_options_object(*%w[--order random]).drb_argv).to include('--order', 'random')
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
context "with --example" do
|
|
32
32
|
it "includes --example" do
|
|
33
|
-
config_options_object(*%w[--example foo]).drb_argv.
|
|
33
|
+
expect(config_options_object(*%w[--example foo]).drb_argv).to include("--example", "foo")
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it "unescapes characters which were escaped upon storing --example originally" do
|
|
37
|
-
config_options_object("--example", "foo\\ bar").drb_argv.
|
|
37
|
+
expect(config_options_object("--example", "foo\\ bar").drb_argv).to include("--example", "foo bar")
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
context "with tags" do
|
|
42
42
|
it "includes the inclusion tags" do
|
|
43
43
|
coo = config_options_object("--tag", "tag")
|
|
44
|
-
coo.drb_argv.
|
|
44
|
+
expect(coo.drb_argv).to eq(["--tag", "tag"])
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "includes the inclusion tags with values" do
|
|
48
48
|
coo = config_options_object("--tag", "tag:foo")
|
|
49
|
-
coo.drb_argv.
|
|
49
|
+
expect(coo.drb_argv).to eq(["--tag", "tag:foo"])
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it "leaves inclusion tags intact" do
|
|
53
53
|
coo = config_options_object("--tag", "tag")
|
|
54
54
|
coo.drb_argv
|
|
55
|
-
coo.filter_manager.inclusions.
|
|
55
|
+
expect(coo.filter_manager.inclusions).to eq( {:tag=>true} )
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it "leaves inclusion tags with values intact" do
|
|
59
59
|
coo = config_options_object("--tag", "tag:foo")
|
|
60
60
|
coo.drb_argv
|
|
61
|
-
coo.filter_manager.inclusions.
|
|
61
|
+
expect(coo.filter_manager.inclusions).to eq( {:tag=>'foo'} )
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
it "includes the exclusion tags" do
|
|
65
65
|
coo = config_options_object("--tag", "~tag")
|
|
66
|
-
coo.drb_argv.
|
|
66
|
+
expect(coo.drb_argv).to eq(["--tag", "~tag"])
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it "includes the exclusion tags with values" do
|
|
70
70
|
coo = config_options_object("--tag", "~tag:foo")
|
|
71
|
-
coo.drb_argv.
|
|
71
|
+
expect(coo.drb_argv).to eq(["--tag", "~tag:foo"])
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "leaves exclusion tags intact" do
|
|
75
75
|
coo = config_options_object("--tag", "~tag")
|
|
76
76
|
coo.drb_argv
|
|
77
|
-
coo.filter_manager.exclusions.
|
|
77
|
+
expect(coo.filter_manager.exclusions).to include(:tag=>true)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
it "leaves exclusion tags with values intact" do
|
|
81
81
|
coo = config_options_object("--tag", "~tag:foo")
|
|
82
82
|
coo.drb_argv
|
|
83
|
-
coo.filter_manager.exclusions.
|
|
83
|
+
expect(coo.filter_manager.exclusions).to include(:tag=>'foo')
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
context "with formatters" do
|
|
88
88
|
it "includes the formatters" do
|
|
89
89
|
coo = config_options_object("--format", "d")
|
|
90
|
-
coo.drb_argv.
|
|
90
|
+
expect(coo.drb_argv).to eq(["--format", "d"])
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
it "leaves formatters intact" do
|
|
94
94
|
coo = config_options_object("--format", "d")
|
|
95
95
|
coo.drb_argv
|
|
96
|
-
coo.options[:formatters].
|
|
96
|
+
expect(coo.options[:formatters]).to eq([["d"]])
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
it "leaves output intact" do
|
|
100
100
|
coo = config_options_object("--format", "p", "--out", "foo.txt", "--format", "d")
|
|
101
101
|
coo.drb_argv
|
|
102
|
-
coo.options[:formatters].
|
|
102
|
+
expect(coo.options[:formatters]).to eq([["p","foo.txt"],["d"]])
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
context "with --out" do
|
|
107
107
|
it "combines with formatters" do
|
|
108
108
|
coo = config_options_object(*%w[--format h --out report.html])
|
|
109
|
-
coo.drb_argv.
|
|
109
|
+
expect(coo.drb_argv).to eq(%w[--format h --out report.html])
|
|
110
110
|
end
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
context "with --line_number" do
|
|
114
114
|
it "includes --line_number" do
|
|
115
|
-
config_options_object(*%w[--line_number 35]).drb_argv.
|
|
115
|
+
expect(config_options_object(*%w[--line_number 35]).drb_argv).to eq(%w[--line_number 35])
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
it "includes multiple lines" do
|
|
119
|
-
config_options_object(*%w[-l 90 -l 4 -l 55]).drb_argv.
|
|
119
|
+
expect(config_options_object(*%w[-l 90 -l 4 -l 55]).drb_argv).to eq(
|
|
120
120
|
%w[--line_number 90 --line_number 4 --line_number 55]
|
|
121
121
|
)
|
|
122
122
|
end
|
|
@@ -124,11 +124,11 @@ describe RSpec::Core::DrbOptions, :isolated_directory => true, :isolated_home =>
|
|
|
124
124
|
|
|
125
125
|
context "with -I libs" do
|
|
126
126
|
it "includes -I" do
|
|
127
|
-
config_options_object(*%w[-I a_dir]).drb_argv.
|
|
127
|
+
expect(config_options_object(*%w[-I a_dir]).drb_argv).to eq(%w[-I a_dir])
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
it "includes multiple paths" do
|
|
131
|
-
config_options_object(*%w[-I dir_1 -I dir_2 -I dir_3]).drb_argv.
|
|
131
|
+
expect(config_options_object(*%w[-I dir_1 -I dir_2 -I dir_3]).drb_argv).to eq(
|
|
132
132
|
%w[-I dir_1 -I dir_2 -I dir_3]
|
|
133
133
|
)
|
|
134
134
|
end
|
|
@@ -136,11 +136,11 @@ describe RSpec::Core::DrbOptions, :isolated_directory => true, :isolated_home =>
|
|
|
136
136
|
|
|
137
137
|
context "with --require" do
|
|
138
138
|
it "includes --require" do
|
|
139
|
-
config_options_object(*%w[--require a_path]).drb_argv.
|
|
139
|
+
expect(config_options_object(*%w[--require a_path]).drb_argv).to eq(%w[--require a_path])
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
it "includes multiple paths" do
|
|
143
|
-
config_options_object(*%w[--require dir/ --require file.rb]).drb_argv.
|
|
143
|
+
expect(config_options_object(*%w[--require dir/ --require file.rb]).drb_argv).to eq(
|
|
144
144
|
%w[--require dir/ --require file.rb]
|
|
145
145
|
)
|
|
146
146
|
end
|
|
@@ -148,32 +148,45 @@ describe RSpec::Core::DrbOptions, :isolated_directory => true, :isolated_home =>
|
|
|
148
148
|
|
|
149
149
|
context "--drb specified in ARGV" do
|
|
150
150
|
it "renders all the original arguments except --drb" do
|
|
151
|
-
config_options_object(*%w[ --drb --color --format s --example pattern
|
|
152
|
-
|
|
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])
|
|
153
156
|
end
|
|
154
157
|
end
|
|
155
158
|
|
|
156
159
|
context "--drb specified in the options file" do
|
|
157
160
|
it "renders all the original arguments except --drb" do
|
|
158
161
|
File.open("./.rspec", "w") {|f| f << "--drb --color"}
|
|
159
|
-
config_options_object(*%w[ --tty --format s --example
|
|
160
|
-
|
|
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])
|
|
161
168
|
end
|
|
162
169
|
end
|
|
163
170
|
|
|
164
171
|
context "--drb specified in ARGV and the options file" do
|
|
165
172
|
it "renders all the original arguments except --drb" do
|
|
166
173
|
File.open("./.rspec", "w") {|f| f << "--drb --color"}
|
|
167
|
-
config_options_object(*%w[ --drb --format s --example
|
|
168
|
-
|
|
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])
|
|
169
179
|
end
|
|
170
180
|
end
|
|
171
181
|
|
|
172
182
|
context "--drb specified in ARGV and in as ARGV-specified --options file" do
|
|
173
183
|
it "renders all the original arguments except --drb and --options" do
|
|
174
184
|
File.open("./.rspec", "w") {|f| f << "--drb --color"}
|
|
175
|
-
config_options_object(*%w[ --drb --format s --example
|
|
176
|
-
|
|
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 ])
|
|
177
190
|
end
|
|
178
191
|
end
|
|
179
192
|
end
|
data/spec/rspec/core/dsl_spec.rb
CHANGED
|
@@ -15,9 +15,9 @@ describe "The RSpec DSL" do
|
|
|
15
15
|
methods.each do |method_name|
|
|
16
16
|
describe "##{method_name}" do
|
|
17
17
|
it "is not added to every object in the system" do
|
|
18
|
-
main.
|
|
19
|
-
Module.new.
|
|
20
|
-
Object.new.
|
|
18
|
+
expect(main).to respond_to(method_name)
|
|
19
|
+
expect(Module.new).to respond_to(method_name)
|
|
20
|
+
expect(Object.new).not_to respond_to(method_name)
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
end
|
|
@@ -23,7 +23,7 @@ module RSpec::Core
|
|
|
23
23
|
it "formats the description with that block" do
|
|
24
24
|
RSpec.configuration.format_docstrings { |s| s.upcase }
|
|
25
25
|
group = ExampleGroup.describe(' an example ')
|
|
26
|
-
group.description.
|
|
26
|
+
expect(group.description).to eq(' AN EXAMPLE ')
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -34,13 +34,13 @@ module RSpec::Core
|
|
|
34
34
|
|
|
35
35
|
it 'processes string args as part of the description' do
|
|
36
36
|
group = ExampleGroup.describe("some", "separate", "strings")
|
|
37
|
-
group.description.
|
|
37
|
+
expect(group.description).to eq("some separate strings")
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it 'processes symbol args as part of the description' do
|
|
41
41
|
Kernel.stub(:warn) # to silence Symbols as args warning
|
|
42
42
|
group = ExampleGroup.describe(:some, :separate, :symbols)
|
|
43
|
-
group.description.
|
|
43
|
+
expect(group.description).to eq("some separate symbols")
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
@@ -52,11 +52,11 @@ module RSpec::Core
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
it 'does not treat the first argument as a metadata key even if it is a symbol' do
|
|
55
|
-
group.metadata.
|
|
55
|
+
expect(group.metadata).not_to include(:symbol)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it 'treats the first argument as part of the description when it is a symbol' do
|
|
59
|
-
group.description.
|
|
59
|
+
expect(group.description).to eq("symbol")
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -72,7 +72,7 @@ module RSpec::Core
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
group.run
|
|
75
|
-
examples_run.
|
|
75
|
+
expect(examples_run).to have(1).example
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
context "with a failure in the top level group" do
|
|
@@ -91,7 +91,7 @@ module RSpec::Core
|
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
group.run
|
|
94
|
-
examples_run.
|
|
94
|
+
expect(examples_run).to have(2).examples
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
|
|
@@ -103,7 +103,7 @@ module RSpec::Core
|
|
|
103
103
|
describe("grandchild 2") {}
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
|
-
group.descendants.size.
|
|
106
|
+
expect(group.descendants.size).to eq(4)
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
end
|
|
@@ -112,7 +112,7 @@ module RSpec::Core
|
|
|
112
112
|
it "is known by parent" do
|
|
113
113
|
parent = ExampleGroup.describe
|
|
114
114
|
child = parent.describe
|
|
115
|
-
parent.children.
|
|
115
|
+
expect(parent.children).to eq([child])
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
it "is not registered in world" do
|
|
@@ -120,7 +120,7 @@ module RSpec::Core
|
|
|
120
120
|
parent = ExampleGroup.describe
|
|
121
121
|
world.register(parent)
|
|
122
122
|
parent.describe
|
|
123
|
-
world.example_groups.
|
|
123
|
+
expect(world.example_groups).to eq([parent])
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
|
|
@@ -140,7 +140,7 @@ module RSpec::Core
|
|
|
140
140
|
group.stub(:world) { world }
|
|
141
141
|
all_examples = [ group.example("first"), group.example("second") ]
|
|
142
142
|
|
|
143
|
-
group.filtered_examples.
|
|
143
|
+
expect(group.filtered_examples).to eq(all_examples)
|
|
144
144
|
end
|
|
145
145
|
|
|
146
146
|
it "includes examples directly matching filter" do
|
|
@@ -152,7 +152,7 @@ module RSpec::Core
|
|
|
152
152
|
]
|
|
153
153
|
group.example("third (not-filtered)")
|
|
154
154
|
|
|
155
|
-
group.filtered_examples.
|
|
155
|
+
expect(group.filtered_examples).to eq(filtered_examples)
|
|
156
156
|
end
|
|
157
157
|
end
|
|
158
158
|
|
|
@@ -168,7 +168,7 @@ module RSpec::Core
|
|
|
168
168
|
group.stub(:world) { world }
|
|
169
169
|
[ group.example("first"), group.example("second") ]
|
|
170
170
|
|
|
171
|
-
group.filtered_examples.
|
|
171
|
+
expect(group.filtered_examples).to be_empty
|
|
172
172
|
end
|
|
173
173
|
|
|
174
174
|
it "excludes examples directly matching filter" do
|
|
@@ -180,7 +180,7 @@ module RSpec::Core
|
|
|
180
180
|
]
|
|
181
181
|
unfiltered_example = group.example("third (not-filtered)")
|
|
182
182
|
|
|
183
|
-
group.filtered_examples.
|
|
183
|
+
expect(group.filtered_examples).to eq([unfiltered_example])
|
|
184
184
|
end
|
|
185
185
|
end
|
|
186
186
|
end
|
|
@@ -256,7 +256,7 @@ module RSpec::Core
|
|
|
256
256
|
group = ExampleGroup.describe
|
|
257
257
|
group.stub(:world) { world }
|
|
258
258
|
example = group.example("does something")
|
|
259
|
-
group.filtered_examples.
|
|
259
|
+
expect(group.filtered_examples).to eq([example])
|
|
260
260
|
end
|
|
261
261
|
end
|
|
262
262
|
|
|
@@ -268,7 +268,7 @@ module RSpec::Core
|
|
|
268
268
|
group = ExampleGroup.describe
|
|
269
269
|
group.stub(:world) { world }
|
|
270
270
|
group.example("does something")
|
|
271
|
-
group.filtered_examples.
|
|
271
|
+
expect(group.filtered_examples).to eq([])
|
|
272
272
|
end
|
|
273
273
|
end
|
|
274
274
|
end
|
|
@@ -277,13 +277,13 @@ module RSpec::Core
|
|
|
277
277
|
|
|
278
278
|
context "with a constant as the first parameter" do
|
|
279
279
|
it "is that constant" do
|
|
280
|
-
ExampleGroup.describe(Object) { }.described_class.
|
|
280
|
+
expect(ExampleGroup.describe(Object) { }.described_class).to eq(Object)
|
|
281
281
|
end
|
|
282
282
|
end
|
|
283
283
|
|
|
284
284
|
context "with a string as the first parameter" do
|
|
285
285
|
it "is nil" do
|
|
286
|
-
ExampleGroup.describe("i'm a computer") { }.described_class.
|
|
286
|
+
expect(ExampleGroup.describe("i'm a computer") { }.described_class).to be_nil
|
|
287
287
|
end
|
|
288
288
|
end
|
|
289
289
|
|
|
@@ -293,12 +293,12 @@ module RSpec::Core
|
|
|
293
293
|
group = ExampleGroup.describe(String) do
|
|
294
294
|
describe :symbol do
|
|
295
295
|
example "described_class is String" do
|
|
296
|
-
described_class.
|
|
296
|
+
expect(described_class).to eq(String)
|
|
297
297
|
end
|
|
298
298
|
end
|
|
299
299
|
end
|
|
300
300
|
|
|
301
|
-
group.run.
|
|
301
|
+
expect(group.run).to be_true
|
|
302
302
|
end
|
|
303
303
|
end
|
|
304
304
|
|
|
@@ -309,12 +309,12 @@ module RSpec::Core
|
|
|
309
309
|
metadata[:example_group][:described_class] = Object
|
|
310
310
|
describe :symbol do
|
|
311
311
|
example "described_class is Object" do
|
|
312
|
-
described_class.
|
|
312
|
+
expect(described_class).to eq(Object)
|
|
313
313
|
end
|
|
314
314
|
end
|
|
315
315
|
end
|
|
316
316
|
|
|
317
|
-
group.run.
|
|
317
|
+
expect(group.run).to be_true
|
|
318
318
|
end
|
|
319
319
|
end
|
|
320
320
|
end
|
|
@@ -323,45 +323,77 @@ module RSpec::Core
|
|
|
323
323
|
it "inherits the described class/module from the outer group" do
|
|
324
324
|
group = ExampleGroup.describe(String) do
|
|
325
325
|
describe Array do
|
|
326
|
-
example "
|
|
327
|
-
described_class.
|
|
326
|
+
example "describes is String" do
|
|
327
|
+
expect(described_class).to eq(String)
|
|
328
328
|
end
|
|
329
329
|
end
|
|
330
330
|
end
|
|
331
331
|
|
|
332
|
-
group.run.
|
|
332
|
+
expect(group.run).to be_true, "expected examples in group to pass"
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
context "for `describe(SomeClass)` within a `describe 'some string' group" do
|
|
337
|
+
def define_and_run_group(define_outer_example = false)
|
|
338
|
+
outer_described_class = inner_described_class = nil
|
|
339
|
+
|
|
340
|
+
ExampleGroup.describe("some string") do
|
|
341
|
+
example { outer_described_class = described_class } if define_outer_example
|
|
342
|
+
|
|
343
|
+
describe Array do
|
|
344
|
+
example { inner_described_class = described_class }
|
|
345
|
+
end
|
|
346
|
+
end.run
|
|
347
|
+
|
|
348
|
+
return outer_described_class, inner_described_class
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
it "has a `nil` described_class in the outer group" do
|
|
352
|
+
outer_described_class, _ = define_and_run_group(:define_outer_example)
|
|
353
|
+
expect(outer_described_class).to be(nil)
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
it "has the inner described class as the described_class of the inner group" do
|
|
357
|
+
_, inner_described_class = define_and_run_group
|
|
358
|
+
expect(inner_described_class).to be(Array)
|
|
359
|
+
|
|
360
|
+
# This is weird, but in RSpec 2.12 (and before, presumably),
|
|
361
|
+
# the `described_class` value would be incorrect if there was an
|
|
362
|
+
# example in the outer group, and correct if there was not one.
|
|
363
|
+
_, inner_described_class = define_and_run_group(:define_outer_example)
|
|
364
|
+
expect(inner_described_class).to be(Array)
|
|
333
365
|
end
|
|
334
366
|
end
|
|
335
367
|
end
|
|
336
368
|
|
|
337
369
|
describe '#described_class' do
|
|
338
370
|
it "is the same as described_class" do
|
|
339
|
-
self.class.described_class.
|
|
371
|
+
expect(self.class.described_class).to eq(self.class.described_class)
|
|
340
372
|
end
|
|
341
373
|
end
|
|
342
374
|
|
|
343
375
|
describe '#description' do
|
|
344
376
|
it "grabs the description from the metadata" do
|
|
345
377
|
group = ExampleGroup.describe(Object, "my desc") { }
|
|
346
|
-
group.description.
|
|
378
|
+
expect(group.description).to eq(group.metadata[:example_group][:description])
|
|
347
379
|
end
|
|
348
380
|
end
|
|
349
381
|
|
|
350
382
|
describe '#metadata' do
|
|
351
383
|
it "adds the third parameter to the metadata" do
|
|
352
|
-
ExampleGroup.describe(Object, nil, 'foo' => 'bar') { }.metadata.
|
|
384
|
+
expect(ExampleGroup.describe(Object, nil, 'foo' => 'bar') { }.metadata).to include({ "foo" => 'bar' })
|
|
353
385
|
end
|
|
354
386
|
|
|
355
387
|
it "adds the the file_path to metadata" do
|
|
356
|
-
ExampleGroup.describe(Object) { }.metadata[:example_group][:file_path].
|
|
388
|
+
expect(ExampleGroup.describe(Object) { }.metadata[:example_group][:file_path]).to eq(relative_path(__FILE__))
|
|
357
389
|
end
|
|
358
390
|
|
|
359
391
|
it "has a reader for file_path" do
|
|
360
|
-
ExampleGroup.describe(Object) { }.file_path.
|
|
392
|
+
expect(ExampleGroup.describe(Object) { }.file_path).to eq(relative_path(__FILE__))
|
|
361
393
|
end
|
|
362
394
|
|
|
363
395
|
it "adds the line_number to metadata" do
|
|
364
|
-
ExampleGroup.describe(Object) { }.metadata[:example_group][:line_number].
|
|
396
|
+
expect(ExampleGroup.describe(Object) { }.metadata[:example_group][:line_number]).to eq(__LINE__)
|
|
365
397
|
end
|
|
366
398
|
end
|
|
367
399
|
|
|
@@ -370,11 +402,11 @@ module RSpec::Core
|
|
|
370
402
|
let(:focused_example) { ExampleGroup.describe.send example_alias, "a focused example" }
|
|
371
403
|
|
|
372
404
|
it 'defines an example that can be filtered with :focused => true' do
|
|
373
|
-
focused_example.metadata[:focused].
|
|
405
|
+
expect(focused_example.metadata[:focused]).to be_true
|
|
374
406
|
end
|
|
375
407
|
|
|
376
408
|
it 'defines an example that can be filtered with :focus => true' do
|
|
377
|
-
focused_example.metadata[:focus].
|
|
409
|
+
expect(focused_example.metadata[:focus]).to be_true
|
|
378
410
|
end
|
|
379
411
|
end
|
|
380
412
|
end
|
|
@@ -390,7 +422,7 @@ module RSpec::Core
|
|
|
390
422
|
|
|
391
423
|
group.run
|
|
392
424
|
|
|
393
|
-
order.
|
|
425
|
+
expect(order).to eq([1,2,3])
|
|
394
426
|
end
|
|
395
427
|
|
|
396
428
|
it "does not set RSpec.wants_to_quit in case of an error in before all (without fail_fast?)" do
|
|
@@ -399,7 +431,7 @@ module RSpec::Core
|
|
|
399
431
|
group.example("example") {}
|
|
400
432
|
|
|
401
433
|
group.run
|
|
402
|
-
RSpec.wants_to_quit.
|
|
434
|
+
expect(RSpec.wants_to_quit).to be_false
|
|
403
435
|
end
|
|
404
436
|
|
|
405
437
|
it "runs the before eachs in order" do
|
|
@@ -412,7 +444,7 @@ module RSpec::Core
|
|
|
412
444
|
|
|
413
445
|
group.run
|
|
414
446
|
|
|
415
|
-
order.
|
|
447
|
+
expect(order).to eq([1,2,3])
|
|
416
448
|
end
|
|
417
449
|
|
|
418
450
|
it "runs the after eachs in reverse order" do
|
|
@@ -425,7 +457,7 @@ module RSpec::Core
|
|
|
425
457
|
|
|
426
458
|
group.run
|
|
427
459
|
|
|
428
|
-
order.
|
|
460
|
+
expect(order).to eq([3,2,1])
|
|
429
461
|
end
|
|
430
462
|
|
|
431
463
|
it "runs the after alls in reverse order" do
|
|
@@ -438,7 +470,7 @@ module RSpec::Core
|
|
|
438
470
|
|
|
439
471
|
group.run
|
|
440
472
|
|
|
441
|
-
order.
|
|
473
|
+
expect(order).to eq([3,2,1])
|
|
442
474
|
end
|
|
443
475
|
|
|
444
476
|
it "only runs before/after(:all) hooks from example groups that have specs that run" do
|
|
@@ -469,7 +501,7 @@ module RSpec::Core
|
|
|
469
501
|
unfiltered_group.run
|
|
470
502
|
filtered_group.run
|
|
471
503
|
|
|
472
|
-
hooks_run.
|
|
504
|
+
expect(hooks_run).to eq([:filtered_before_all, :filtered_after_all])
|
|
473
505
|
end
|
|
474
506
|
|
|
475
507
|
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
|
|
@@ -497,7 +529,7 @@ module RSpec::Core
|
|
|
497
529
|
|
|
498
530
|
group.run
|
|
499
531
|
|
|
500
|
-
order.
|
|
532
|
+
expect(order).to eq([
|
|
501
533
|
:before_all_defined_in_config,
|
|
502
534
|
:top_level_before_all,
|
|
503
535
|
:before_each,
|
|
@@ -525,12 +557,12 @@ module RSpec::Core
|
|
|
525
557
|
inner.before(:all) { @inner = "inner" }
|
|
526
558
|
|
|
527
559
|
outer.after(:all) do
|
|
528
|
-
@outer.
|
|
529
|
-
@inner.
|
|
560
|
+
expect(@outer).to eq("outer")
|
|
561
|
+
expect(@inner).to eq("inner")
|
|
530
562
|
end
|
|
531
563
|
inner.after(:all) do
|
|
532
|
-
@inner.
|
|
533
|
-
@outer.
|
|
564
|
+
expect(@inner).to eq("inner")
|
|
565
|
+
expect(@outer).to eq("outer")
|
|
534
566
|
end
|
|
535
567
|
|
|
536
568
|
outer.run
|
|
@@ -542,32 +574,32 @@ module RSpec::Core
|
|
|
542
574
|
|
|
543
575
|
outer.run
|
|
544
576
|
|
|
545
|
-
inner.before_all_ivars[:@inner].
|
|
546
|
-
inner.before_all_ivars[:@outer].
|
|
547
|
-
outer.before_all_ivars[:@inner].
|
|
548
|
-
outer.before_all_ivars[:@outer].
|
|
577
|
+
expect(inner.before_all_ivars[:@inner]).to be_nil
|
|
578
|
+
expect(inner.before_all_ivars[:@outer]).to be_nil
|
|
579
|
+
expect(outer.before_all_ivars[:@inner]).to be_nil
|
|
580
|
+
expect(outer.before_all_ivars[:@outer]).to be_nil
|
|
549
581
|
end
|
|
550
582
|
end
|
|
551
583
|
|
|
552
584
|
it "treats an error in before(:each) as a failure" do
|
|
553
585
|
group = ExampleGroup.describe
|
|
554
586
|
group.before(:each) { raise "error in before each" }
|
|
555
|
-
example = group.example("equality") { 1.
|
|
556
|
-
group.run.
|
|
587
|
+
example = group.example("equality") { expect(1).to eq(2) }
|
|
588
|
+
expect(group.run).to be(false)
|
|
557
589
|
|
|
558
|
-
example.metadata[:execution_result][:exception].message.
|
|
590
|
+
expect(example.metadata[:execution_result][:exception].message).to eq("error in before each")
|
|
559
591
|
end
|
|
560
592
|
|
|
561
593
|
it "treats an error in before(:all) as a failure" do
|
|
562
594
|
group = ExampleGroup.describe
|
|
563
595
|
group.before(:all) { raise "error in before all" }
|
|
564
|
-
example = group.example("equality") { 1.
|
|
565
|
-
group.run.
|
|
596
|
+
example = group.example("equality") { expect(1).to eq(2) }
|
|
597
|
+
expect(group.run).to be_false
|
|
566
598
|
|
|
567
|
-
example.metadata.
|
|
568
|
-
example.metadata[:execution_result].
|
|
569
|
-
example.metadata[:execution_result][:exception].
|
|
570
|
-
example.metadata[:execution_result][:exception].message.
|
|
599
|
+
expect(example.metadata).not_to be_nil
|
|
600
|
+
expect(example.metadata[:execution_result]).not_to be_nil
|
|
601
|
+
expect(example.metadata[:execution_result][:exception]).not_to be_nil
|
|
602
|
+
expect(example.metadata[:execution_result][:exception].message).to eq("error in before all")
|
|
571
603
|
end
|
|
572
604
|
|
|
573
605
|
it "exposes instance variables set in before(:all) from after(:all) even if a before(:all) error occurs" do
|
|
@@ -585,7 +617,7 @@ module RSpec::Core
|
|
|
585
617
|
end
|
|
586
618
|
|
|
587
619
|
group.run
|
|
588
|
-
ivar_value_in_after_hook.
|
|
620
|
+
expect(ivar_value_in_after_hook).to eq(:set_in_before_all)
|
|
589
621
|
end
|
|
590
622
|
|
|
591
623
|
it "treats an error in before(:all) as a failure for a spec in a nested group" do
|
|
@@ -594,15 +626,15 @@ module RSpec::Core
|
|
|
594
626
|
before(:all) { raise "error in before all" }
|
|
595
627
|
|
|
596
628
|
describe "nested" do
|
|
597
|
-
example = it("equality") { 1.
|
|
629
|
+
example = it("equality") { expect(1).to eq(2) }
|
|
598
630
|
end
|
|
599
631
|
end
|
|
600
632
|
group.run
|
|
601
633
|
|
|
602
|
-
example.metadata.
|
|
603
|
-
example.metadata[:execution_result].
|
|
604
|
-
example.metadata[:execution_result][:exception].
|
|
605
|
-
example.metadata[:execution_result][:exception].message.
|
|
634
|
+
expect(example.metadata).not_to be_nil
|
|
635
|
+
expect(example.metadata[:execution_result]).not_to be_nil
|
|
636
|
+
expect(example.metadata[:execution_result][:exception]).not_to be_nil
|
|
637
|
+
expect(example.metadata[:execution_result][:exception].message).to eq("error in before all")
|
|
606
638
|
end
|
|
607
639
|
|
|
608
640
|
context "when an error occurs in an after(:all) hook" do
|
|
@@ -613,16 +645,16 @@ module RSpec::Core
|
|
|
613
645
|
let(:group) do
|
|
614
646
|
ExampleGroup.describe do
|
|
615
647
|
after(:all) { raise "error in after all" }
|
|
616
|
-
it("equality") { 1.
|
|
648
|
+
it("equality") { expect(1).to eq(1) }
|
|
617
649
|
end
|
|
618
650
|
end
|
|
619
651
|
|
|
620
652
|
it "allows the example to pass" do
|
|
621
653
|
group.run
|
|
622
654
|
example = group.examples.first
|
|
623
|
-
example.metadata.
|
|
624
|
-
example.metadata[:execution_result].
|
|
625
|
-
example.metadata[:execution_result][:status].
|
|
655
|
+
expect(example.metadata).not_to be_nil
|
|
656
|
+
expect(example.metadata[:execution_result]).not_to be_nil
|
|
657
|
+
expect(example.metadata[:execution_result][:status]).to eq("passed")
|
|
626
658
|
end
|
|
627
659
|
|
|
628
660
|
it "rescues the error and prints it out" do
|
|
@@ -637,7 +669,7 @@ module RSpec::Core
|
|
|
637
669
|
group.before(:all) { running_example = example }
|
|
638
670
|
group.example("no-op") { }
|
|
639
671
|
group.run
|
|
640
|
-
running_example.
|
|
672
|
+
expect(running_example).to be(nil)
|
|
641
673
|
end
|
|
642
674
|
|
|
643
675
|
it "has access to example options within before(:each)" do
|
|
@@ -646,7 +678,7 @@ module RSpec::Core
|
|
|
646
678
|
group.before(:each) { option = example.options[:data] }
|
|
647
679
|
group.example("no-op", :data => :sample) { }
|
|
648
680
|
group.run
|
|
649
|
-
option.
|
|
681
|
+
expect(option).to eq(:sample)
|
|
650
682
|
end
|
|
651
683
|
|
|
652
684
|
it "has access to example options within after(:each)" do
|
|
@@ -655,7 +687,7 @@ module RSpec::Core
|
|
|
655
687
|
group.after(:each) { option = example.options[:data] }
|
|
656
688
|
group.example("no-op", :data => :sample) { }
|
|
657
689
|
group.run
|
|
658
|
-
option.
|
|
690
|
+
expect(option).to eq(:sample)
|
|
659
691
|
end
|
|
660
692
|
|
|
661
693
|
it "has no 'running example' within after(:all)" do
|
|
@@ -664,7 +696,7 @@ module RSpec::Core
|
|
|
664
696
|
group.after(:all) { running_example = example }
|
|
665
697
|
group.example("no-op") { }
|
|
666
698
|
group.run
|
|
667
|
-
running_example.
|
|
699
|
+
expect(running_example).to be(nil)
|
|
668
700
|
end
|
|
669
701
|
end
|
|
670
702
|
|
|
@@ -677,17 +709,17 @@ module RSpec::Core
|
|
|
677
709
|
|
|
678
710
|
it "generates a pending example" do
|
|
679
711
|
@group.run
|
|
680
|
-
@group.examples.first.
|
|
712
|
+
expect(@group.examples.first).to be_pending
|
|
681
713
|
end
|
|
682
714
|
|
|
683
715
|
it "sets the pending message", :if => method_name == 'pending' do
|
|
684
716
|
@group.run
|
|
685
|
-
@group.examples.first.metadata[:execution_result][:pending_message].
|
|
717
|
+
expect(@group.examples.first.metadata[:execution_result][:pending_message]).to eq(RSpec::Core::Pending::NO_REASON_GIVEN)
|
|
686
718
|
end
|
|
687
719
|
|
|
688
720
|
it "sets the pending message", :unless => method_name == 'pending' do
|
|
689
721
|
@group.run
|
|
690
|
-
@group.examples.first.metadata[:execution_result][:pending_message].
|
|
722
|
+
expect(@group.examples.first.metadata[:execution_result][:pending_message]).to eq("Temporarily disabled with #{method_name}")
|
|
691
723
|
end
|
|
692
724
|
end
|
|
693
725
|
end
|
|
@@ -697,7 +729,7 @@ module RSpec::Core
|
|
|
697
729
|
it "allows adding an example using 'it'" do
|
|
698
730
|
group = ExampleGroup.describe
|
|
699
731
|
group.it("should do something") { }
|
|
700
|
-
group.examples.size.
|
|
732
|
+
expect(group.examples.size).to eq(1)
|
|
701
733
|
end
|
|
702
734
|
|
|
703
735
|
it "exposes all examples at examples" do
|
|
@@ -705,7 +737,7 @@ module RSpec::Core
|
|
|
705
737
|
group.it("should do something 1") { }
|
|
706
738
|
group.it("should do something 2") { }
|
|
707
739
|
group.it("should do something 3") { }
|
|
708
|
-
group.
|
|
740
|
+
expect(group).to have(3).examples
|
|
709
741
|
end
|
|
710
742
|
|
|
711
743
|
it "maintains the example order" do
|
|
@@ -713,9 +745,9 @@ module RSpec::Core
|
|
|
713
745
|
group.it("should 1") { }
|
|
714
746
|
group.it("should 2") { }
|
|
715
747
|
group.it("should 3") { }
|
|
716
|
-
group.examples[0].description.
|
|
717
|
-
group.examples[1].description.
|
|
718
|
-
group.examples[2].description.
|
|
748
|
+
expect(group.examples[0].description).to eq('should 1')
|
|
749
|
+
expect(group.examples[1].description).to eq('should 2')
|
|
750
|
+
expect(group.examples[2].description).to eq('should 3')
|
|
719
751
|
end
|
|
720
752
|
|
|
721
753
|
end
|
|
@@ -724,19 +756,19 @@ module RSpec::Core
|
|
|
724
756
|
|
|
725
757
|
describe "A sample nested group", :nested_describe => "yep" do
|
|
726
758
|
it "sets the described class to the described class of the outer most group" do
|
|
727
|
-
example.example_group.described_class.
|
|
759
|
+
expect(example.example_group.described_class).to eq(ExampleGroup)
|
|
728
760
|
end
|
|
729
761
|
|
|
730
762
|
it "sets the description to 'A sample nested describe'" do
|
|
731
|
-
example.example_group.description.
|
|
763
|
+
expect(example.example_group.description).to eq('A sample nested group')
|
|
732
764
|
end
|
|
733
765
|
|
|
734
766
|
it "has top level metadata from the example_group and its parent groups" do
|
|
735
|
-
example.example_group.metadata.
|
|
767
|
+
expect(example.example_group.metadata).to include(:little_less_nested => 'yep', :nested_describe => 'yep')
|
|
736
768
|
end
|
|
737
769
|
|
|
738
770
|
it "exposes the parent metadata to the contained examples" do
|
|
739
|
-
example.metadata.
|
|
771
|
+
expect(example.metadata).to include(:little_less_nested => 'yep', :nested_describe => 'yep')
|
|
740
772
|
end
|
|
741
773
|
end
|
|
742
774
|
|
|
@@ -748,32 +780,32 @@ module RSpec::Core
|
|
|
748
780
|
|
|
749
781
|
it "returns true if all examples pass" do
|
|
750
782
|
group = ExampleGroup.describe('group') do
|
|
751
|
-
example('ex 1') { 1.
|
|
752
|
-
example('ex 2') { 1.
|
|
783
|
+
example('ex 1') { expect(1).to eq(1) }
|
|
784
|
+
example('ex 2') { expect(1).to eq(1) }
|
|
753
785
|
end
|
|
754
786
|
group.stub(:filtered_examples) { group.examples.extend(Extensions::Ordered::Examples) }
|
|
755
|
-
group.run(reporter).
|
|
787
|
+
expect(group.run(reporter)).to be_true
|
|
756
788
|
end
|
|
757
789
|
|
|
758
790
|
it "returns false if any of the examples fail" do
|
|
759
791
|
group = ExampleGroup.describe('group') do
|
|
760
|
-
example('ex 1') { 1.
|
|
761
|
-
example('ex 2') { 1.
|
|
792
|
+
example('ex 1') { expect(1).to eq(1) }
|
|
793
|
+
example('ex 2') { expect(1).to eq(2) }
|
|
762
794
|
end
|
|
763
795
|
group.stub(:filtered_examples) { group.examples.extend(Extensions::Ordered::Examples) }
|
|
764
|
-
group.run(reporter).
|
|
796
|
+
expect(group.run(reporter)).to be_false
|
|
765
797
|
end
|
|
766
798
|
|
|
767
799
|
it "runs all examples, regardless of any of them failing" do
|
|
768
800
|
group = ExampleGroup.describe('group') do
|
|
769
|
-
example('ex 1') { 1.
|
|
770
|
-
example('ex 2') { 1.
|
|
801
|
+
example('ex 1') { expect(1).to eq(2) }
|
|
802
|
+
example('ex 2') { expect(1).to eq(1) }
|
|
771
803
|
end
|
|
772
804
|
group.stub(:filtered_examples) { group.examples.extend(Extensions::Ordered::Examples) }
|
|
773
805
|
group.filtered_examples.each do |example|
|
|
774
806
|
example.should_receive(:run)
|
|
775
807
|
end
|
|
776
|
-
group.run(reporter).
|
|
808
|
+
expect(group.run(reporter)).to be_false
|
|
777
809
|
end
|
|
778
810
|
end
|
|
779
811
|
|
|
@@ -787,28 +819,28 @@ module RSpec::Core
|
|
|
787
819
|
end
|
|
788
820
|
|
|
789
821
|
it "can access a before each ivar at the same level" do
|
|
790
|
-
@before_each_top_level.
|
|
822
|
+
expect(@before_each_top_level).to eq('before_each_top_level')
|
|
791
823
|
end
|
|
792
824
|
|
|
793
825
|
it "can access a before all ivar at the same level" do
|
|
794
|
-
@before_all_top_level.
|
|
826
|
+
expect(@before_all_top_level).to eq('before_all_top_level')
|
|
795
827
|
end
|
|
796
828
|
|
|
797
829
|
it "can access the before all ivars in the before_all_ivars hash", :ruby => 1.8 do
|
|
798
|
-
example.example_group.before_all_ivars.
|
|
830
|
+
expect(example.example_group.before_all_ivars).to include('@before_all_top_level' => 'before_all_top_level')
|
|
799
831
|
end
|
|
800
832
|
|
|
801
833
|
it "can access the before all ivars in the before_all_ivars hash", :ruby => 1.9 do
|
|
802
|
-
example.example_group.before_all_ivars.
|
|
834
|
+
expect(example.example_group.before_all_ivars).to include(:@before_all_top_level => 'before_all_top_level')
|
|
803
835
|
end
|
|
804
836
|
|
|
805
837
|
describe "but now I am nested" do
|
|
806
838
|
it "can access a parent example groups before each ivar at a nested level" do
|
|
807
|
-
@before_each_top_level.
|
|
839
|
+
expect(@before_each_top_level).to eq('before_each_top_level')
|
|
808
840
|
end
|
|
809
841
|
|
|
810
842
|
it "can access a parent example groups before all ivar at a nested level" do
|
|
811
|
-
@before_all_top_level.
|
|
843
|
+
expect(@before_all_top_level).to eq("before_all_top_level")
|
|
812
844
|
end
|
|
813
845
|
|
|
814
846
|
it "changes to before all ivars from within an example do not persist outside the current describe" do
|
|
@@ -817,7 +849,7 @@ module RSpec::Core
|
|
|
817
849
|
|
|
818
850
|
describe "accessing a before_all ivar that was changed in a parent example_group" do
|
|
819
851
|
it "does not have access to the modified version" do
|
|
820
|
-
@before_all_top_level.
|
|
852
|
+
expect(@before_all_top_level).to eq('before_all_top_level')
|
|
821
853
|
end
|
|
822
854
|
end
|
|
823
855
|
end
|
|
@@ -827,12 +859,12 @@ module RSpec::Core
|
|
|
827
859
|
describe "ivars are not shared across examples" do
|
|
828
860
|
it "(first example)" do
|
|
829
861
|
@a = 1
|
|
830
|
-
defined?(@b).
|
|
862
|
+
expect(defined?(@b)).to be_false
|
|
831
863
|
end
|
|
832
864
|
|
|
833
865
|
it "(second example)" do
|
|
834
866
|
@b = 2
|
|
835
|
-
defined?(@a).
|
|
867
|
+
expect(defined?(@a)).to be_false
|
|
836
868
|
end
|
|
837
869
|
end
|
|
838
870
|
|
|
@@ -847,7 +879,7 @@ module RSpec::Core
|
|
|
847
879
|
end
|
|
848
880
|
end
|
|
849
881
|
|
|
850
|
-
group.top_level_description.
|
|
882
|
+
expect(group.top_level_description).to eq("top")
|
|
851
883
|
end
|
|
852
884
|
end
|
|
853
885
|
|
|
@@ -869,14 +901,14 @@ module RSpec::Core
|
|
|
869
901
|
|
|
870
902
|
group.run
|
|
871
903
|
|
|
872
|
-
examples_run.length.
|
|
904
|
+
expect(examples_run.length).to eq(2)
|
|
873
905
|
end
|
|
874
906
|
|
|
875
907
|
it "sets RSpec.wants_to_quit flag if encountering an exception in before(:all)" do
|
|
876
908
|
group.before(:all) { raise "error in before all" }
|
|
877
|
-
example = group.example("equality") { 1.
|
|
878
|
-
group.run.
|
|
879
|
-
RSpec.wants_to_quit.
|
|
909
|
+
example = group.example("equality") { expect(1).to eq(2) }
|
|
910
|
+
expect(group.run).to be_false
|
|
911
|
+
expect(RSpec.wants_to_quit).to be_true
|
|
880
912
|
end
|
|
881
913
|
end
|
|
882
914
|
|
|
@@ -922,7 +954,7 @@ module RSpec::Core
|
|
|
922
954
|
end
|
|
923
955
|
end
|
|
924
956
|
|
|
925
|
-
group.run(reporter).
|
|
957
|
+
expect(group.run(reporter)).to be_true
|
|
926
958
|
end
|
|
927
959
|
end
|
|
928
960
|
|
|
@@ -939,7 +971,7 @@ module RSpec::Core
|
|
|
939
971
|
end
|
|
940
972
|
end
|
|
941
973
|
|
|
942
|
-
group.run(reporter).
|
|
974
|
+
expect(group.run(reporter)).to be_false
|
|
943
975
|
end
|
|
944
976
|
end
|
|
945
977
|
|
|
@@ -956,7 +988,7 @@ module RSpec::Core
|
|
|
956
988
|
end
|
|
957
989
|
end
|
|
958
990
|
|
|
959
|
-
group.run(reporter).
|
|
991
|
+
expect(group.run(reporter)).to be_false
|
|
960
992
|
end
|
|
961
993
|
end
|
|
962
994
|
end
|
|
@@ -972,7 +1004,7 @@ module RSpec::Core
|
|
|
972
1004
|
it "includes the named examples" do
|
|
973
1005
|
group = ExampleGroup.describe
|
|
974
1006
|
group.send(name, "named this")
|
|
975
|
-
group.examples.first.description.
|
|
1007
|
+
expect(group.examples.first.description).to eq("does something")
|
|
976
1008
|
end
|
|
977
1009
|
|
|
978
1010
|
it "raises a helpful error message when shared content is not found" do
|
|
@@ -996,7 +1028,7 @@ module RSpec::Core
|
|
|
996
1028
|
group.send(name, "named this with params", :value1, :value2)
|
|
997
1029
|
group.run
|
|
998
1030
|
|
|
999
|
-
passed_params.
|
|
1031
|
+
expect(passed_params).to eq({ :param1 => :value1, :param2 => :value2 })
|
|
1000
1032
|
end
|
|
1001
1033
|
|
|
1002
1034
|
it "adds shared instance methods to the group" do
|
|
@@ -1005,7 +1037,7 @@ module RSpec::Core
|
|
|
1005
1037
|
end
|
|
1006
1038
|
group = ExampleGroup.describe('fake group')
|
|
1007
1039
|
group.send(name, "named this with params", :a)
|
|
1008
|
-
group.public_instance_methods.map{|m| m.to_s}.
|
|
1040
|
+
expect(group.public_instance_methods.map{|m| m.to_s}).to include("foo")
|
|
1009
1041
|
end
|
|
1010
1042
|
|
|
1011
1043
|
it "evals the shared example group only once" do
|
|
@@ -1013,14 +1045,14 @@ module RSpec::Core
|
|
|
1013
1045
|
shared_examples("named this with params") { |p| eval_count += 1 }
|
|
1014
1046
|
group = ExampleGroup.describe('fake group')
|
|
1015
1047
|
group.send(name, "named this with params", :a)
|
|
1016
|
-
eval_count.
|
|
1048
|
+
expect(eval_count).to eq(1)
|
|
1017
1049
|
end
|
|
1018
1050
|
|
|
1019
1051
|
it "evals the block when given" do
|
|
1020
1052
|
key = "#{__FILE__}:#{__LINE__}"
|
|
1021
1053
|
shared_examples(key) do
|
|
1022
1054
|
it("does something") do
|
|
1023
|
-
foo.
|
|
1055
|
+
expect(foo).to eq("bar")
|
|
1024
1056
|
end
|
|
1025
1057
|
end
|
|
1026
1058
|
group = ExampleGroup.describe do
|
|
@@ -1028,7 +1060,7 @@ module RSpec::Core
|
|
|
1028
1060
|
def foo; "bar"; end
|
|
1029
1061
|
end
|
|
1030
1062
|
end
|
|
1031
|
-
group.run.
|
|
1063
|
+
expect(group.run).to be_true
|
|
1032
1064
|
end
|
|
1033
1065
|
end
|
|
1034
1066
|
end
|
|
@@ -1038,7 +1070,7 @@ module RSpec::Core
|
|
|
1038
1070
|
shared_examples_for("thing") {}
|
|
1039
1071
|
group = ExampleGroup.describe('fake group')
|
|
1040
1072
|
group.it_should_behave_like("thing")
|
|
1041
|
-
group.
|
|
1073
|
+
expect(group).to have(1).children
|
|
1042
1074
|
end
|
|
1043
1075
|
|
|
1044
1076
|
it "creates a nested group for a class" do
|
|
@@ -1046,7 +1078,7 @@ module RSpec::Core
|
|
|
1046
1078
|
shared_examples_for(klass) {}
|
|
1047
1079
|
group = ExampleGroup.describe('fake group')
|
|
1048
1080
|
group.it_should_behave_like(klass)
|
|
1049
|
-
group.
|
|
1081
|
+
expect(group).to have(1).children
|
|
1050
1082
|
end
|
|
1051
1083
|
|
|
1052
1084
|
it "adds shared examples to nested group" do
|
|
@@ -1055,7 +1087,7 @@ module RSpec::Core
|
|
|
1055
1087
|
end
|
|
1056
1088
|
group = ExampleGroup.describe('fake group')
|
|
1057
1089
|
shared_group = group.it_should_behave_like("thing")
|
|
1058
|
-
shared_group.
|
|
1090
|
+
expect(shared_group).to have(1).examples
|
|
1059
1091
|
end
|
|
1060
1092
|
|
|
1061
1093
|
it "adds shared instance methods to nested group" do
|
|
@@ -1064,7 +1096,7 @@ module RSpec::Core
|
|
|
1064
1096
|
end
|
|
1065
1097
|
group = ExampleGroup.describe('fake group')
|
|
1066
1098
|
shared_group = group.it_should_behave_like("thing")
|
|
1067
|
-
shared_group.public_instance_methods.map{|m| m.to_s}.
|
|
1099
|
+
expect(shared_group.public_instance_methods.map{|m| m.to_s}).to include("foo")
|
|
1068
1100
|
end
|
|
1069
1101
|
|
|
1070
1102
|
it "adds shared class methods to nested group" do
|
|
@@ -1073,7 +1105,7 @@ module RSpec::Core
|
|
|
1073
1105
|
end
|
|
1074
1106
|
group = ExampleGroup.describe('fake group')
|
|
1075
1107
|
shared_group = group.it_should_behave_like("thing")
|
|
1076
|
-
shared_group.methods.map{|m| m.to_s}.
|
|
1108
|
+
expect(shared_group.methods.map{|m| m.to_s}).to include("foo")
|
|
1077
1109
|
end
|
|
1078
1110
|
|
|
1079
1111
|
it "passes parameters to the shared example group" do
|
|
@@ -1091,7 +1123,7 @@ module RSpec::Core
|
|
|
1091
1123
|
end
|
|
1092
1124
|
group.run
|
|
1093
1125
|
|
|
1094
|
-
passed_params.
|
|
1126
|
+
expect(passed_params).to eq({ :param1 => :value1, :param2 => :value2 })
|
|
1095
1127
|
end
|
|
1096
1128
|
|
|
1097
1129
|
it "adds shared instance methods to nested group" do
|
|
@@ -1100,7 +1132,7 @@ module RSpec::Core
|
|
|
1100
1132
|
end
|
|
1101
1133
|
group = ExampleGroup.describe('fake group')
|
|
1102
1134
|
shared_group = group.it_should_behave_like("thing", :a)
|
|
1103
|
-
shared_group.public_instance_methods.map{|m| m.to_s}.
|
|
1135
|
+
expect(shared_group.public_instance_methods.map{|m| m.to_s}).to include("foo")
|
|
1104
1136
|
end
|
|
1105
1137
|
|
|
1106
1138
|
it "evals the shared example group only once" do
|
|
@@ -1108,7 +1140,7 @@ module RSpec::Core
|
|
|
1108
1140
|
shared_examples_for("thing") { |p| eval_count += 1 }
|
|
1109
1141
|
group = ExampleGroup.describe('fake group')
|
|
1110
1142
|
group.it_should_behave_like("thing", :a)
|
|
1111
|
-
eval_count.
|
|
1143
|
+
expect(eval_count).to eq(1)
|
|
1112
1144
|
end
|
|
1113
1145
|
|
|
1114
1146
|
context "given a block" do
|
|
@@ -1128,7 +1160,7 @@ module RSpec::Core
|
|
|
1128
1160
|
end
|
|
1129
1161
|
group.run
|
|
1130
1162
|
|
|
1131
|
-
scopes[0].
|
|
1163
|
+
expect(scopes[0]).to be(scopes[1])
|
|
1132
1164
|
end
|
|
1133
1165
|
end
|
|
1134
1166
|
|