rspec-core 2.99.2 → 3.0.0.beta1
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 +14 -6
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +103 -191
- data/License.txt +1 -0
- data/README.md +4 -25
- data/features/Upgrade.md +2 -14
- data/features/command_line/dry_run.feature +29 -0
- data/features/command_line/example_name_option.feature +1 -1
- data/features/command_line/fail_fast.feature +26 -0
- data/features/command_line/format_option.feature +3 -3
- data/features/command_line/line_number_option.feature +16 -11
- data/features/command_line/order.feature +2 -3
- data/features/command_line/pattern_option.feature +3 -3
- data/features/command_line/randomization.feature +63 -0
- data/features/command_line/require_option.feature +2 -2
- data/features/command_line/ruby.feature +1 -1
- data/features/configuration/alias_example_to.feature +13 -22
- data/features/configuration/{backtrace_clean_patterns.feature → backtrace_exclusion_patterns.feature} +17 -14
- data/features/configuration/custom_settings.feature +11 -11
- data/features/configuration/overriding_global_ordering.feature +93 -0
- data/features/configuration/profile.feature +13 -13
- data/features/configuration/read_options_from_file.feature +7 -7
- data/features/example_groups/basic_structure.feature +1 -1
- data/features/example_groups/shared_context.feature +8 -8
- data/features/example_groups/shared_examples.feature +6 -14
- data/features/expectation_framework_integration/configure_expectation_framework.feature +27 -122
- data/features/filtering/exclusion_filters.feature +2 -5
- data/features/filtering/inclusion_filters.feature +1 -5
- data/features/formatters/json_formatter.feature +2 -2
- data/features/formatters/text_formatter.feature +4 -4
- data/features/helper_methods/arbitrary_methods.feature +2 -2
- data/features/helper_methods/let.feature +5 -5
- data/features/helper_methods/modules.feature +5 -8
- data/features/hooks/around_hooks.feature +2 -2
- data/features/hooks/before_and_after_hooks.feature +14 -14
- data/features/hooks/filtering.feature +12 -14
- data/features/metadata/described_class.feature +1 -1
- data/features/metadata/user_defined.feature +16 -29
- data/features/mock_framework_integration/use_flexmock.feature +1 -1
- data/features/mock_framework_integration/use_mocha.feature +1 -1
- data/features/mock_framework_integration/use_rr.feature +1 -1
- data/features/mock_framework_integration/use_rspec.feature +5 -5
- data/features/pending/pending_examples.feature +5 -5
- data/features/spec_files/arbitrary_file_suffix.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +3 -3
- data/features/subject/explicit_subject.feature +8 -8
- data/features/subject/implicit_receiver.feature +29 -0
- data/features/subject/implicit_subject.feature +4 -4
- data/features/support/env.rb +10 -3
- data/features/support/require_expect_syntax_in_aruba_specs.rb +16 -0
- data/lib/rspec/core.rb +11 -48
- data/lib/rspec/core/backport_random.rb +302 -0
- data/lib/rspec/core/backtrace_formatter.rb +65 -0
- data/lib/rspec/core/command_line.rb +7 -18
- data/lib/rspec/core/configuration.rb +202 -507
- data/lib/rspec/core/configuration_options.rb +17 -30
- data/lib/rspec/core/example.rb +29 -39
- data/lib/rspec/core/example_group.rb +166 -259
- data/lib/rspec/core/filter_manager.rb +30 -47
- data/lib/rspec/core/flat_map.rb +17 -0
- data/lib/rspec/core/formatters.rb +0 -138
- data/lib/rspec/core/formatters/base_formatter.rb +46 -1
- data/lib/rspec/core/formatters/base_text_formatter.rb +38 -61
- data/lib/rspec/core/formatters/deprecation_formatter.rb +21 -52
- data/lib/rspec/core/formatters/helpers.rb +0 -28
- data/lib/rspec/core/formatters/html_formatter.rb +1 -1
- data/lib/rspec/core/formatters/json_formatter.rb +38 -9
- data/lib/rspec/core/formatters/snippet_extractor.rb +14 -5
- data/lib/rspec/core/hooks.rb +55 -39
- data/lib/rspec/core/memoized_helpers.rb +17 -167
- data/lib/rspec/core/metadata.rb +16 -64
- data/lib/rspec/core/option_parser.rb +30 -39
- data/lib/rspec/core/ordering.rb +154 -0
- data/lib/rspec/core/pending.rb +12 -69
- data/lib/rspec/core/project_initializer.rb +12 -10
- data/lib/rspec/core/rake_task.rb +5 -108
- data/lib/rspec/core/reporter.rb +15 -18
- data/lib/rspec/core/runner.rb +16 -30
- data/lib/rspec/core/shared_context.rb +3 -5
- data/lib/rspec/core/shared_example_group.rb +3 -51
- data/lib/rspec/core/shared_example_group/collection.rb +1 -19
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/warnings.rb +22 -0
- data/lib/rspec/core/world.rb +12 -8
- data/spec/command_line/order_spec.rb +20 -23
- data/spec/rspec/core/backtrace_formatter_spec.rb +216 -0
- data/spec/rspec/core/command_line_spec.rb +32 -48
- data/spec/rspec/core/configuration_options_spec.rb +19 -50
- data/spec/rspec/core/configuration_spec.rb +142 -713
- data/spec/rspec/core/drb_command_line_spec.rb +2 -0
- data/spec/rspec/core/dsl_spec.rb +0 -1
- data/spec/rspec/core/example_group_spec.rb +192 -223
- data/spec/rspec/core/example_spec.rb +40 -16
- data/spec/rspec/core/filter_manager_spec.rb +2 -2
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -41
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +5 -123
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +2 -87
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +2 -3
- data/spec/rspec/core/formatters/{text_mate_formatted.html → html_formatted-1.8.7-jruby.html} +44 -25
- data/spec/rspec/core/formatters/html_formatted-1.8.7-rbx.html +477 -0
- data/spec/rspec/core/formatters/{html_formatted.html → html_formatted-1.8.7.html} +42 -25
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +425 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.3-jruby.html +416 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.3-rbx.html +477 -0
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +419 -0
- data/spec/rspec/core/formatters/html_formatted-2.0.0.html +425 -0
- data/spec/rspec/core/formatters/html_formatter_spec.rb +21 -46
- data/spec/rspec/core/formatters/json_formatter_spec.rb +97 -8
- data/spec/rspec/core/hooks_filtering_spec.rb +5 -5
- data/spec/rspec/core/hooks_spec.rb +61 -47
- data/spec/rspec/core/memoized_helpers_spec.rb +20 -322
- data/spec/rspec/core/metadata_spec.rb +1 -24
- data/spec/rspec/core/option_parser_spec.rb +20 -62
- data/spec/rspec/core/ordering_spec.rb +102 -0
- data/spec/rspec/core/pending_example_spec.rb +0 -40
- data/spec/rspec/core/project_initializer_spec.rb +1 -25
- data/spec/rspec/core/rake_task_spec.rb +5 -72
- data/spec/rspec/core/random_spec.rb +47 -0
- data/spec/rspec/core/reporter_spec.rb +23 -48
- data/spec/rspec/core/runner_spec.rb +31 -39
- data/spec/rspec/core/shared_context_spec.rb +3 -15
- data/spec/rspec/core/shared_example_group/collection_spec.rb +4 -17
- data/spec/rspec/core/shared_example_group_spec.rb +12 -45
- data/spec/rspec/core/{deprecation_spec.rb → warnings_spec.rb} +3 -1
- data/spec/rspec/core_spec.rb +4 -21
- data/spec/spec_helper.rb +41 -5
- data/spec/support/helper_methods.rb +0 -29
- data/spec/support/sandboxed_mock_space.rb +0 -16
- data/spec/support/shared_example_groups.rb +7 -36
- data/spec/support/stderr_splitter.rb +36 -0
- metadata +163 -157
- metadata.gz.sig +1 -0
- data/exe/autospec +0 -13
- data/features/Autotest.md +0 -38
- data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
- data/features/subject/attribute_of_subject.feature +0 -124
- data/features/subject/one_liner_syntax.feature +0 -71
- data/lib/autotest/discover.rb +0 -10
- data/lib/autotest/rspec2.rb +0 -77
- data/lib/rspec/core/backtrace_cleaner.rb +0 -46
- data/lib/rspec/core/backward_compatibility.rb +0 -55
- data/lib/rspec/core/caller_filter.rb +0 -60
- data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
- data/lib/rspec/core/deprecation.rb +0 -26
- data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
- data/lib/rspec/core/extensions/kernel.rb +0 -9
- data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
- data/lib/rspec/core/extensions/ordered.rb +0 -27
- data/lib/rspec/core/formatters/console_codes.rb +0 -42
- data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
- data/lib/rspec/core/metadata_hash_builder.rb +0 -97
- data/lib/rspec/core/minitest_assertions_adapter.rb +0 -28
- data/lib/rspec/core/test_unit_assertions_adapter.rb +0 -30
- data/spec/autotest/discover_spec.rb +0 -49
- data/spec/autotest/failed_results_re_spec.rb +0 -45
- data/spec/autotest/rspec_spec.rb +0 -133
- data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
- data/spec/rspec/core/caller_filter_spec.rb +0 -58
- data/spec/rspec/core/deprecations_spec.rb +0 -59
- data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
- data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
- data/spec/rspec/core/pending_spec.rb +0 -27
- data/spec/support/silence_dsl_deprecations.rb +0 -32
|
@@ -22,6 +22,8 @@ describe "::DRbCommandLine", :type => :drb, :unless => RUBY_PLATFORM == 'java' d
|
|
|
22
22
|
it "raises an error" do
|
|
23
23
|
expect { command_line.run(err, out) }.to raise_error(DRb::DRbConnError)
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
after { DRb.stop_service }
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
describe "--drb-port" do
|
data/spec/rspec/core/dsl_spec.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
1
2
|
require 'spec_helper'
|
|
2
3
|
|
|
3
4
|
class SelfObserver
|
|
@@ -27,37 +28,185 @@ module RSpec::Core
|
|
|
27
28
|
end
|
|
28
29
|
end
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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")
|
|
34
55
|
end
|
|
35
56
|
|
|
36
|
-
it '
|
|
37
|
-
|
|
38
|
-
|
|
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")
|
|
39
69
|
end
|
|
40
70
|
|
|
41
|
-
it '
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
87
|
+
# on 1.8.7, "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/)
|
|
45
106
|
end
|
|
46
107
|
end
|
|
47
108
|
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
50
113
|
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
53
130
|
end
|
|
54
131
|
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
57
163
|
end
|
|
58
164
|
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
61
210
|
end
|
|
62
211
|
end
|
|
63
212
|
|
|
@@ -73,7 +222,7 @@ module RSpec::Core
|
|
|
73
222
|
end
|
|
74
223
|
|
|
75
224
|
group.run
|
|
76
|
-
expect(examples_run).to
|
|
225
|
+
expect(examples_run.count).to eq(1)
|
|
77
226
|
end
|
|
78
227
|
|
|
79
228
|
context "with a failure in the top level group" do
|
|
@@ -92,7 +241,7 @@ module RSpec::Core
|
|
|
92
241
|
end
|
|
93
242
|
|
|
94
243
|
group.run
|
|
95
|
-
expect(examples_run).to
|
|
244
|
+
expect(examples_run.count).to eq(2)
|
|
96
245
|
end
|
|
97
246
|
end
|
|
98
247
|
|
|
@@ -292,7 +441,7 @@ module RSpec::Core
|
|
|
292
441
|
context "and a string in an inner group" do
|
|
293
442
|
it "is the top level constant" do
|
|
294
443
|
group = ExampleGroup.describe(String) do
|
|
295
|
-
describe
|
|
444
|
+
describe :symbol do
|
|
296
445
|
example "described_class is String" do
|
|
297
446
|
expect(described_class).to eq(String)
|
|
298
447
|
end
|
|
@@ -308,7 +457,7 @@ module RSpec::Core
|
|
|
308
457
|
group = ExampleGroup.describe(String) do
|
|
309
458
|
described_class
|
|
310
459
|
metadata[:example_group][:described_class] = Object
|
|
311
|
-
describe
|
|
460
|
+
describe :symbol do
|
|
312
461
|
example "described_class is Object" do
|
|
313
462
|
expect(described_class).to eq(Object)
|
|
314
463
|
end
|
|
@@ -332,76 +481,6 @@ module RSpec::Core
|
|
|
332
481
|
|
|
333
482
|
expect(group.run).to be_truthy, "expected examples in group to pass"
|
|
334
483
|
end
|
|
335
|
-
|
|
336
|
-
def capture_deprecation_options
|
|
337
|
-
warn_opts = nil
|
|
338
|
-
allow(RSpec.configuration.reporter).to receive(:deprecation) do |opts|
|
|
339
|
-
warn_opts = opts
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
yield
|
|
343
|
-
|
|
344
|
-
warn_opts
|
|
345
|
-
end
|
|
346
|
-
|
|
347
|
-
it "prints a deprecation warning since the semantics of an inner described_class are changing in RSpec 3" do
|
|
348
|
-
warn_opts = capture_deprecation_options do
|
|
349
|
-
ExampleGroup.describe(String) do
|
|
350
|
-
describe Array do
|
|
351
|
-
example { described_class }
|
|
352
|
-
end
|
|
353
|
-
end.run
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
expect(warn_opts[:message]).to include("#{__FILE__}:#{__LINE__ - 5}")
|
|
357
|
-
expect(warn_opts[:message]).to include("described_class")
|
|
358
|
-
end
|
|
359
|
-
|
|
360
|
-
it "prints a deprecation warning since the semantics of an inner described symbol are changing in RSpec 3" do
|
|
361
|
-
warn_opts = capture_deprecation_options do
|
|
362
|
-
ExampleGroup.describe(String) do
|
|
363
|
-
describe :method do
|
|
364
|
-
example { described_class }
|
|
365
|
-
end
|
|
366
|
-
end.run
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
expect(warn_opts[:message]).to include("#{__FILE__}:#{__LINE__ - 6}")
|
|
370
|
-
expect(warn_opts[:message]).to include("described_class")
|
|
371
|
-
end
|
|
372
|
-
|
|
373
|
-
it "prints a deprecation even when `described_class` has already been referenced in the outer group" do
|
|
374
|
-
warn_opts = capture_deprecation_options do
|
|
375
|
-
outer_dc = inner_dc = nil
|
|
376
|
-
ExampleGroup.describe(String) do
|
|
377
|
-
outer_dc = described_class
|
|
378
|
-
describe Array do
|
|
379
|
-
example { inner_dc = described_class }
|
|
380
|
-
end
|
|
381
|
-
end.run
|
|
382
|
-
|
|
383
|
-
expect(outer_dc).to eq(String)
|
|
384
|
-
expect(inner_dc).to eq(String)
|
|
385
|
-
end
|
|
386
|
-
|
|
387
|
-
expect(warn_opts[:message]).to include("#{__FILE__}:#{__LINE__ - 8}")
|
|
388
|
-
expect(warn_opts[:message]).to include("described_class")
|
|
389
|
-
end
|
|
390
|
-
|
|
391
|
-
it "does not print a deprecation warning when the inner example group has no description args" do
|
|
392
|
-
dc = :unset
|
|
393
|
-
deprecations = []
|
|
394
|
-
allow(RSpec).to receive(:warn_deprecation) { |msg| deprecations << msg }
|
|
395
|
-
|
|
396
|
-
ExampleGroup.describe(String) do
|
|
397
|
-
describe do
|
|
398
|
-
example { dc = described_class }
|
|
399
|
-
end
|
|
400
|
-
end.run
|
|
401
|
-
|
|
402
|
-
expect(dc).to be(String)
|
|
403
|
-
expect(deprecations).to eq([])
|
|
404
|
-
end
|
|
405
484
|
end
|
|
406
485
|
|
|
407
486
|
context "for `describe(SomeClass)` within a `describe 'some string' group" do
|
|
@@ -747,7 +826,6 @@ module RSpec::Core
|
|
|
747
826
|
it "has access to example options within before(:each)" do
|
|
748
827
|
group = ExampleGroup.describe
|
|
749
828
|
option = nil
|
|
750
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /options/)
|
|
751
829
|
group.before(:each) {|ex| option = ex.options[:data] }
|
|
752
830
|
group.example("no-op", :data => :sample) { }
|
|
753
831
|
group.run
|
|
@@ -757,7 +835,6 @@ module RSpec::Core
|
|
|
757
835
|
it "has access to example options within after(:each)" do
|
|
758
836
|
group = ExampleGroup.describe
|
|
759
837
|
option = nil
|
|
760
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /options/)
|
|
761
838
|
group.after(:each) {|ex| option = ex.options[:data] }
|
|
762
839
|
group.example("no-op", :data => :sample) { }
|
|
763
840
|
group.run
|
|
@@ -765,70 +842,30 @@ module RSpec::Core
|
|
|
765
842
|
end
|
|
766
843
|
end
|
|
767
844
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
845
|
+
%w[pending xit xspecify xexample].each do |method_name|
|
|
846
|
+
describe "::#{method_name}" do
|
|
847
|
+
before do
|
|
848
|
+
@group = ExampleGroup.describe
|
|
849
|
+
@group.send(method_name, "is pending") { }
|
|
772
850
|
end
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
before { group.run }
|
|
776
|
-
|
|
777
|
-
it 'generates a pending example' do
|
|
778
|
-
expect(group.examples.first).to be_pending
|
|
779
|
-
end
|
|
780
|
-
|
|
781
|
-
it 'sets the pending message' do
|
|
782
|
-
expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq('skip this')
|
|
783
|
-
end
|
|
784
|
-
end
|
|
785
|
-
|
|
786
|
-
%w[pending skip].each do |method_name|
|
|
787
|
-
describe ".#{method_name}" do
|
|
788
|
-
let(:group) { ExampleGroup.describe.tap {|x|
|
|
789
|
-
x.send(method_name, "is pending") { }
|
|
790
|
-
}}
|
|
791
|
-
|
|
792
|
-
before { group.run }
|
|
793
851
|
|
|
794
852
|
it "generates a pending example" do
|
|
795
|
-
|
|
853
|
+
@group.run
|
|
854
|
+
expect(@group.examples.first).to be_pending
|
|
796
855
|
end
|
|
797
856
|
|
|
798
|
-
it "sets the pending message" do
|
|
799
|
-
|
|
857
|
+
it "sets the pending message", :if => method_name == 'pending' do
|
|
858
|
+
@group.run
|
|
859
|
+
expect(@group.examples.first.metadata[:execution_result][:pending_message]).to eq(RSpec::Core::Pending::NO_REASON_GIVEN)
|
|
800
860
|
end
|
|
801
|
-
end
|
|
802
|
-
end
|
|
803
|
-
|
|
804
|
-
%w[xit xspecify xexample].each do |method_name|
|
|
805
|
-
describe ".#{method_name}" do
|
|
806
|
-
let(:group) { ExampleGroup.describe.tap {|x|
|
|
807
|
-
x.send(method_name, "is pending") { }
|
|
808
|
-
}}
|
|
809
861
|
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
expect(group.examples.first).to be_pending
|
|
814
|
-
end
|
|
815
|
-
|
|
816
|
-
it "sets the pending message" do
|
|
817
|
-
expect(group.examples.first.metadata[:execution_result][:pending_message]).to eq("Temporarily disabled with #{method_name}")
|
|
862
|
+
it "sets the pending message", :unless => method_name == 'pending' do
|
|
863
|
+
@group.run
|
|
864
|
+
expect(@group.examples.first.metadata[:execution_result][:pending_message]).to eq("Temporarily disabled with #{method_name}")
|
|
818
865
|
end
|
|
819
866
|
end
|
|
820
867
|
end
|
|
821
868
|
|
|
822
|
-
describe '::pending' do
|
|
823
|
-
it 'shows upgrade warning' do
|
|
824
|
-
expect_warn_deprecation_with_call_site(
|
|
825
|
-
"example_group_spec.rb", __LINE__ + 3
|
|
826
|
-
)
|
|
827
|
-
group = ExampleGroup.describe
|
|
828
|
-
group.send(:pending, "is pending") { }
|
|
829
|
-
end
|
|
830
|
-
end
|
|
831
|
-
|
|
832
869
|
describe "adding examples" do
|
|
833
870
|
|
|
834
871
|
it "allows adding an example using 'it'" do
|
|
@@ -842,7 +879,7 @@ module RSpec::Core
|
|
|
842
879
|
group.it("should do something 1") { }
|
|
843
880
|
group.it("should do something 2") { }
|
|
844
881
|
group.it("should do something 3") { }
|
|
845
|
-
expect(group).to
|
|
882
|
+
expect(group.examples.count).to eq(3)
|
|
846
883
|
end
|
|
847
884
|
|
|
848
885
|
it "maintains the example order" do
|
|
@@ -888,7 +925,7 @@ module RSpec::Core
|
|
|
888
925
|
example('ex 1') { expect(1).to eq(1) }
|
|
889
926
|
example('ex 2') { expect(1).to eq(1) }
|
|
890
927
|
end
|
|
891
|
-
group.stub(:filtered_examples) { group.examples
|
|
928
|
+
group.stub(:filtered_examples) { group.examples }
|
|
892
929
|
expect(group.run(reporter)).to be_truthy
|
|
893
930
|
end
|
|
894
931
|
|
|
@@ -897,7 +934,7 @@ module RSpec::Core
|
|
|
897
934
|
example('ex 1') { expect(1).to eq(1) }
|
|
898
935
|
example('ex 2') { expect(1).to eq(2) }
|
|
899
936
|
end
|
|
900
|
-
group.stub(:filtered_examples) { group.examples
|
|
937
|
+
group.stub(:filtered_examples) { group.examples }
|
|
901
938
|
expect(group.run(reporter)).to be_falsey
|
|
902
939
|
end
|
|
903
940
|
|
|
@@ -906,7 +943,7 @@ module RSpec::Core
|
|
|
906
943
|
example('ex 1') { expect(1).to eq(2) }
|
|
907
944
|
example('ex 2') { expect(1).to eq(1) }
|
|
908
945
|
end
|
|
909
|
-
group.stub(:filtered_examples) { group.examples
|
|
946
|
+
group.stub(:filtered_examples) { group.examples }
|
|
910
947
|
group.filtered_examples.each do |example|
|
|
911
948
|
example.should_receive(:run)
|
|
912
949
|
end
|
|
@@ -1167,41 +1204,6 @@ module RSpec::Core
|
|
|
1167
1204
|
end
|
|
1168
1205
|
expect(group.run).to be_truthy
|
|
1169
1206
|
end
|
|
1170
|
-
|
|
1171
|
-
it "warns when extra args are submitted to a zero-arity shared block", :if => RUBY_VERSION.to_f >= 1.9 do
|
|
1172
|
-
group = ExampleGroup.describe
|
|
1173
|
-
group.shared_examples("named this") {}
|
|
1174
|
-
|
|
1175
|
-
expect(group).to receive(:warn) {|message|
|
|
1176
|
-
expect(message).to match(/expected 0 args/)
|
|
1177
|
-
expect(message).to match(/called from #{__FILE__}:#{__LINE__ + 2}/)
|
|
1178
|
-
}
|
|
1179
|
-
group.send(name, "named this", "extra arg")
|
|
1180
|
-
end
|
|
1181
|
-
|
|
1182
|
-
it "warns with usage message when 2nd arg is the name of another shared group", :if => RUBY_VERSION.to_f >= 1.9 do
|
|
1183
|
-
group = ExampleGroup.describe
|
|
1184
|
-
group.shared_examples("named this") {}
|
|
1185
|
-
group.shared_examples("named that") {}
|
|
1186
|
-
|
|
1187
|
-
expect(group).to receive(:warn) {|message|
|
|
1188
|
-
expect(message).to match(/shared (context|examples) supports? the name of only one example group, received \["named this", "named that"\]/)
|
|
1189
|
-
expect(message).to match(/called from #{__FILE__}:#{__LINE__ + 2}/)
|
|
1190
|
-
}
|
|
1191
|
-
group.send(name, "named this", "named that")
|
|
1192
|
-
end
|
|
1193
|
-
|
|
1194
|
-
it 'does not warn when the shared example group has a default arg', :if => RUBY_VERSION.to_f >= 1.9 do
|
|
1195
|
-
group = ExampleGroup.describe
|
|
1196
|
-
|
|
1197
|
-
# 1.8.7 can't parse blocks with arg defaults, so we have to eval it
|
|
1198
|
-
# to delay when it is parsed.
|
|
1199
|
-
eval('group.shared_examples("named this") { |opts={}| }')
|
|
1200
|
-
|
|
1201
|
-
expect(group).not_to receive(:warn)
|
|
1202
|
-
|
|
1203
|
-
group.send(name, "named this", :foo => 1)
|
|
1204
|
-
end
|
|
1205
1207
|
end
|
|
1206
1208
|
end
|
|
1207
1209
|
|
|
@@ -1210,7 +1212,7 @@ module RSpec::Core
|
|
|
1210
1212
|
group = ExampleGroup.describe('fake group')
|
|
1211
1213
|
group.shared_examples_for("thing") {}
|
|
1212
1214
|
group.it_should_behave_like("thing")
|
|
1213
|
-
expect(group).to
|
|
1215
|
+
expect(group.children.count).to eq(1)
|
|
1214
1216
|
end
|
|
1215
1217
|
|
|
1216
1218
|
it "creates a nested group for a class" do
|
|
@@ -1218,7 +1220,7 @@ module RSpec::Core
|
|
|
1218
1220
|
group = ExampleGroup.describe('fake group')
|
|
1219
1221
|
group.shared_examples_for(klass) {}
|
|
1220
1222
|
group.it_should_behave_like(klass)
|
|
1221
|
-
expect(group).to
|
|
1223
|
+
expect(group.children.count).to eq(1)
|
|
1222
1224
|
end
|
|
1223
1225
|
|
|
1224
1226
|
it "adds shared examples to nested group" do
|
|
@@ -1227,7 +1229,7 @@ module RSpec::Core
|
|
|
1227
1229
|
it("does something")
|
|
1228
1230
|
end
|
|
1229
1231
|
shared_group = group.it_should_behave_like("thing")
|
|
1230
|
-
expect(shared_group).to
|
|
1232
|
+
expect(shared_group.examples.count).to eq(1)
|
|
1231
1233
|
end
|
|
1232
1234
|
|
|
1233
1235
|
it "adds shared instance methods to nested group" do
|
|
@@ -1313,38 +1315,5 @@ module RSpec::Core
|
|
|
1313
1315
|
end.to raise_error(ArgumentError,%q|Could not find shared examples "shared stuff"|)
|
|
1314
1316
|
end
|
|
1315
1317
|
end
|
|
1316
|
-
|
|
1317
|
-
describe "deprecated methods" do
|
|
1318
|
-
specify ".describes is deprecated" do
|
|
1319
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /describes/)
|
|
1320
|
-
expect(self.class.describes).to eq(self.class.described_class)
|
|
1321
|
-
end
|
|
1322
|
-
|
|
1323
|
-
specify ".display_name is deprecated" do
|
|
1324
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /display_name/)
|
|
1325
|
-
expect(self.class.display_name).to eq(self.class.description)
|
|
1326
|
-
end
|
|
1327
|
-
|
|
1328
|
-
specify ".alias_it_behaves_like_to is deprecated" do
|
|
1329
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 2, /alias_it_behaves_like_to/)
|
|
1330
|
-
expect {
|
|
1331
|
-
ExampleGroup.alias_it_behaves_like_to(:it_does_something, "it does something")
|
|
1332
|
-
}.to change { ExampleGroup.respond_to?(:it_does_something) }.from(false).to(true)
|
|
1333
|
-
end
|
|
1334
|
-
|
|
1335
|
-
specify ".alias_example_to is deprecated" do
|
|
1336
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 2, /alias_example_to/)
|
|
1337
|
-
expect {
|
|
1338
|
-
ExampleGroup.alias_example_to(:an_example)
|
|
1339
|
-
}.to change { ExampleGroup.respond_to?(:an_example) }.from(false).to(true)
|
|
1340
|
-
end
|
|
1341
|
-
|
|
1342
|
-
specify ".focused is deprecated" do
|
|
1343
|
-
expect_deprecation_with_call_site(__FILE__, __LINE__ + 2, /focused/)
|
|
1344
|
-
ExampleGroup.describe("group") do
|
|
1345
|
-
focused("example") { }
|
|
1346
|
-
end
|
|
1347
|
-
end
|
|
1348
|
-
end
|
|
1349
1318
|
end
|
|
1350
1319
|
end
|