rspec-core 2.11.1 → 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/.document +1 -1
- data/.yardopts +3 -1
- data/Changelog.md +1814 -29
- data/{License.txt → LICENSE.md} +6 -4
- data/README.md +197 -48
- data/exe/rspec +2 -23
- data/lib/rspec/autorun.rb +1 -0
- data/lib/rspec/core/backtrace_formatter.rb +65 -0
- data/lib/rspec/core/bisect/coordinator.rb +62 -0
- data/lib/rspec/core/bisect/example_minimizer.rb +173 -0
- data/lib/rspec/core/bisect/fork_runner.rb +138 -0
- data/lib/rspec/core/bisect/server.rb +61 -0
- data/lib/rspec/core/bisect/shell_command.rb +126 -0
- data/lib/rspec/core/bisect/shell_runner.rb +73 -0
- data/lib/rspec/core/bisect/utilities.rb +69 -0
- data/lib/rspec/core/configuration.rb +1846 -407
- data/lib/rspec/core/configuration_options.rb +154 -50
- data/lib/rspec/core/did_you_mean.rb +46 -0
- data/lib/rspec/core/drb.rb +120 -0
- data/lib/rspec/core/dsl.rb +90 -18
- data/lib/rspec/core/example.rb +488 -152
- data/lib/rspec/core/example_group.rb +733 -294
- data/lib/rspec/core/example_status_persister.rb +235 -0
- data/lib/rspec/core/filter_manager.rb +175 -147
- data/lib/rspec/core/flat_map.rb +20 -0
- data/lib/rspec/core/formatters/base_bisect_formatter.rb +45 -0
- data/lib/rspec/core/formatters/base_formatter.rb +32 -130
- data/lib/rspec/core/formatters/base_text_formatter.rb +62 -190
- data/lib/rspec/core/formatters/bisect_drb_formatter.rb +29 -0
- data/lib/rspec/core/formatters/bisect_progress_formatter.rb +157 -0
- data/lib/rspec/core/formatters/console_codes.rb +76 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +223 -0
- data/lib/rspec/core/formatters/documentation_formatter.rb +62 -27
- data/lib/rspec/core/formatters/exception_presenter.rb +521 -0
- data/lib/rspec/core/formatters/failure_list_formatter.rb +23 -0
- data/lib/rspec/core/formatters/fallback_message_formatter.rb +28 -0
- data/lib/rspec/core/formatters/helpers.rb +93 -14
- data/lib/rspec/core/formatters/html_formatter.rb +104 -415
- data/lib/rspec/core/formatters/html_printer.rb +414 -0
- data/lib/rspec/core/formatters/html_snippet_extractor.rb +120 -0
- data/lib/rspec/core/formatters/json_formatter.rb +102 -0
- data/lib/rspec/core/formatters/profile_formatter.rb +68 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +12 -15
- data/lib/rspec/core/formatters/protocol.rb +182 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +115 -39
- data/lib/rspec/core/formatters/syntax_highlighter.rb +91 -0
- data/lib/rspec/core/formatters.rb +279 -0
- data/lib/rspec/core/hooks.rb +451 -300
- data/lib/rspec/core/invocations.rb +87 -0
- data/lib/rspec/core/memoized_helpers.rb +580 -0
- data/lib/rspec/core/metadata.rb +395 -173
- data/lib/rspec/core/metadata_filter.rb +255 -0
- data/lib/rspec/core/minitest_assertions_adapter.rb +31 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +31 -0
- data/lib/rspec/core/mocking_adapters/mocha.rb +57 -0
- data/lib/rspec/core/mocking_adapters/null.rb +14 -0
- data/lib/rspec/core/mocking_adapters/rr.rb +31 -0
- data/lib/rspec/core/mocking_adapters/rspec.rb +32 -0
- data/lib/rspec/core/notifications.rb +521 -0
- data/lib/rspec/core/option_parser.rb +208 -64
- data/lib/rspec/core/ordering.rb +169 -0
- data/lib/rspec/core/output_wrapper.rb +29 -0
- data/lib/rspec/core/pending.rb +115 -59
- data/lib/rspec/core/profiler.rb +34 -0
- data/lib/rspec/core/project_initializer/.rspec +1 -0
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +98 -0
- data/lib/rspec/core/project_initializer.rb +26 -65
- data/lib/rspec/core/rake_task.rb +140 -131
- data/lib/rspec/core/reporter.rb +207 -44
- data/lib/rspec/core/ruby_project.rb +15 -6
- data/lib/rspec/core/runner.rb +180 -44
- data/lib/rspec/core/sandbox.rb +37 -0
- data/lib/rspec/core/set.rb +54 -0
- data/lib/rspec/core/shared_context.rb +25 -19
- data/lib/rspec/core/shared_example_group.rb +229 -54
- data/lib/rspec/core/shell_escape.rb +49 -0
- 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 +40 -0
- data/lib/rspec/core/world.rb +208 -49
- data/lib/rspec/core.rb +166 -80
- data.tar.gz.sig +0 -0
- metadata +230 -445
- metadata.gz.sig +0 -0
- data/exe/autospec +0 -13
- data/features/Autotest.md +0 -38
- data/features/README.md +0 -17
- data/features/Upgrade.md +0 -364
- data/features/command_line/README.md +0 -28
- data/features/command_line/example_name_option.feature +0 -101
- data/features/command_line/exit_status.feature +0 -83
- data/features/command_line/format_option.feature +0 -81
- data/features/command_line/init.feature +0 -18
- data/features/command_line/line_number_appended_to_path.feature +0 -140
- data/features/command_line/line_number_option.feature +0 -58
- data/features/command_line/order.feature +0 -29
- data/features/command_line/pattern_option.feature +0 -31
- data/features/command_line/rake_task.feature +0 -68
- data/features/command_line/ruby.feature +0 -22
- data/features/command_line/tag.feature +0 -91
- data/features/configuration/alias_example_to.feature +0 -48
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/read_options_from_file.feature +0 -87
- 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 -204
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
- data/features/filtering/exclusion_filters.feature +0 -139
- data/features/filtering/if_and_unless.feature +0 -168
- data/features/filtering/inclusion_filters.feature +0 -105
- data/features/filtering/run_all_when_everything_filtered.feature +0 -46
- data/features/formatters/custom_formatter.feature +0 -36
- data/features/formatters/text_formatter.feature +0 -46
- data/features/helper_methods/arbitrary_methods.feature +0 -40
- data/features/helper_methods/let.feature +0 -50
- data/features/helper_methods/modules.feature +0 -149
- data/features/hooks/around_hooks.feature +0 -343
- data/features/hooks/before_and_after_hooks.feature +0 -423
- data/features/hooks/filtering.feature +0 -234
- data/features/metadata/current_example.feature +0 -17
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -113
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -96
- data/features/mock_framework_integration/use_mocha.feature +0 -97
- data/features/mock_framework_integration/use_rr.feature +0 -98
- data/features/mock_framework_integration/use_rspec.feature +0 -97
- data/features/pending/pending_examples.feature +0 -229
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -30
- data/features/subject/attribute_of_subject.feature +0 -124
- data/features/subject/explicit_subject.feature +0 -82
- data/features/subject/implicit_receiver.feature +0 -29
- data/features/subject/implicit_subject.feature +0 -63
- data/features/support/env.rb +0 -12
- data/lib/autotest/discover.rb +0 -1
- data/lib/autotest/rspec2.rb +0 -73
- data/lib/rspec/core/backward_compatibility.rb +0 -65
- data/lib/rspec/core/command_line.rb +0 -36
- data/lib/rspec/core/deprecation.rb +0 -36
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
- data/lib/rspec/core/extensions/kernel.rb +0 -9
- data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
- data/lib/rspec/core/extensions/ordered.rb +0 -21
- data/lib/rspec/core/extensions.rb +0 -4
- data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
- data/lib/rspec/core/let.rb +0 -110
- data/lib/rspec/core/load_path.rb +0 -3
- data/lib/rspec/core/metadata_hash_builder.rb +0 -97
- data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
- data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
- data/lib/rspec/core/mocking/with_mocha.rb +0 -29
- data/lib/rspec/core/mocking/with_rr.rb +0 -27
- data/lib/rspec/core/mocking/with_rspec.rb +0 -23
- data/lib/rspec/core/subject.rb +0 -219
- data/spec/autotest/discover_spec.rb +0 -19
- data/spec/autotest/failed_results_re_spec.rb +0 -45
- data/spec/autotest/rspec_spec.rb +0 -123
- data/spec/command_line/order_spec.rb +0 -137
- data/spec/rspec/core/command_line_spec.rb +0 -108
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -377
- data/spec/rspec/core/configuration_spec.rb +0 -1196
- data/spec/rspec/core/deprecations_spec.rb +0 -66
- data/spec/rspec/core/drb_command_line_spec.rb +0 -108
- data/spec/rspec/core/drb_options_spec.rb +0 -180
- data/spec/rspec/core/dsl_spec.rb +0 -17
- data/spec/rspec/core/example_group_spec.rb +0 -1098
- data/spec/rspec/core/example_spec.rb +0 -370
- data/spec/rspec/core/filter_manager_spec.rb +0 -256
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -80
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -363
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -88
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -66
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +0 -410
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +0 -409
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +0 -416
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +0 -416
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -82
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -18
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +0 -410
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +0 -409
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +0 -416
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +0 -416
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -83
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -250
- data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
- data/spec/rspec/core/let_spec.rb +0 -55
- data/spec/rspec/core/metadata_spec.rb +0 -447
- data/spec/rspec/core/option_parser_spec.rb +0 -166
- data/spec/rspec/core/pending_example_spec.rb +0 -220
- data/spec/rspec/core/project_initializer_spec.rb +0 -130
- data/spec/rspec/core/rake_task_spec.rb +0 -138
- data/spec/rspec/core/reporter_spec.rb +0 -103
- data/spec/rspec/core/resources/a_bar.rb +0 -0
- data/spec/rspec/core/resources/a_foo.rb +0 -0
- data/spec/rspec/core/resources/a_spec.rb +0 -1
- data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
- data/spec/rspec/core/resources/formatter_specs.rb +0 -60
- data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
- data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
- data/spec/rspec/core/ruby_project_spec.rb +0 -24
- data/spec/rspec/core/runner_spec.rb +0 -81
- data/spec/rspec/core/shared_context_spec.rb +0 -67
- data/spec/rspec/core/shared_example_group_spec.rb +0 -84
- data/spec/rspec/core/subject_spec.rb +0 -244
- data/spec/rspec/core/world_spec.rb +0 -144
- data/spec/rspec/core_spec.rb +0 -35
- data/spec/spec_helper.rb +0 -98
- data/spec/support/config_options_helper.rb +0 -24
- data/spec/support/helper_methods.rb +0 -5
- data/spec/support/matchers.rb +0 -65
- data/spec/support/shared_example_groups.rb +0 -41
- data/spec/support/spec_files.rb +0 -44
@@ -1,227 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module RSpec::Core
|
4
|
-
describe "config block hook filtering" do
|
5
|
-
describe "unfiltered hooks" do
|
6
|
-
it "should be ran" do
|
7
|
-
filters = []
|
8
|
-
RSpec.configure do |c|
|
9
|
-
c.before(:all) { filters << "before all in config"}
|
10
|
-
c.around(:each) {|example| filters << "around each in config"; example.run}
|
11
|
-
c.before(:each) { filters << "before each in config"}
|
12
|
-
c.after(:each) { filters << "after each in config"}
|
13
|
-
c.after(:all) { filters << "after all in config"}
|
14
|
-
end
|
15
|
-
group = ExampleGroup.describe
|
16
|
-
group.example("example") {}
|
17
|
-
group.run
|
18
|
-
filters.should eq([
|
19
|
-
"before all in config",
|
20
|
-
"around each in config",
|
21
|
-
"before each in config",
|
22
|
-
"after each in config",
|
23
|
-
"after all in config"
|
24
|
-
])
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "hooks with single filters" do
|
29
|
-
|
30
|
-
context "with no scope specified" do
|
31
|
-
it "should be ran around|before|after :each if the filter matches the example group's filter" do
|
32
|
-
filters = []
|
33
|
-
RSpec.configure do |c|
|
34
|
-
c.around(:match => true) {|example| filters << "around each in config"; example.run}
|
35
|
-
c.before(:match => true) { filters << "before each in config"}
|
36
|
-
c.after(:match => true) { filters << "after each in config"}
|
37
|
-
end
|
38
|
-
group = ExampleGroup.describe(:match => true)
|
39
|
-
group.example("example") {}
|
40
|
-
group.run
|
41
|
-
filters.should eq([
|
42
|
-
"around each in config",
|
43
|
-
"before each in config",
|
44
|
-
"after each in config"
|
45
|
-
])
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should be ran if the filter matches the example group's filter" do
|
50
|
-
filters = []
|
51
|
-
RSpec.configure do |c|
|
52
|
-
c.before(:all, :match => true) { filters << "before all in config"}
|
53
|
-
c.around(:each, :match => true) {|example| filters << "around each in config"; example.run}
|
54
|
-
c.before(:each, :match => true) { filters << "before each in config"}
|
55
|
-
c.after(:each, :match => true) { filters << "after each in config"}
|
56
|
-
c.after(:all, :match => true) { filters << "after all in config"}
|
57
|
-
end
|
58
|
-
group = ExampleGroup.describe(:match => true)
|
59
|
-
group.example("example") {}
|
60
|
-
group.run
|
61
|
-
filters.should eq([
|
62
|
-
"before all in config",
|
63
|
-
"around each in config",
|
64
|
-
"before each in config",
|
65
|
-
"after each in config",
|
66
|
-
"after all in config"
|
67
|
-
])
|
68
|
-
end
|
69
|
-
|
70
|
-
it "runs before|after :all hooks on matching nested example groups" do
|
71
|
-
filters = []
|
72
|
-
RSpec.configure do |c|
|
73
|
-
c.before(:all, :match => true) { filters << :before_all }
|
74
|
-
c.after(:all, :match => true) { filters << :after_all }
|
75
|
-
end
|
76
|
-
|
77
|
-
example_1_filters = example_2_filters = nil
|
78
|
-
|
79
|
-
group = ExampleGroup.describe "group" do
|
80
|
-
it("example 1") { example_1_filters = filters.dup }
|
81
|
-
describe "subgroup", :match => true do
|
82
|
-
it("example 2") { example_2_filters = filters.dup }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
group.run
|
86
|
-
|
87
|
-
example_1_filters.should be_empty
|
88
|
-
example_2_filters.should eq([:before_all])
|
89
|
-
filters.should eq([:before_all, :after_all])
|
90
|
-
end
|
91
|
-
|
92
|
-
it "runs before|after :all hooks only on the highest level group that matches the filter" do
|
93
|
-
filters = []
|
94
|
-
RSpec.configure do |c|
|
95
|
-
c.before(:all, :match => true) { filters << :before_all }
|
96
|
-
c.after(:all, :match => true) { filters << :after_all }
|
97
|
-
end
|
98
|
-
|
99
|
-
example_1_filters = example_2_filters = example_3_filters = nil
|
100
|
-
|
101
|
-
group = ExampleGroup.describe "group", :match => true do
|
102
|
-
it("example 1") { example_1_filters = filters.dup }
|
103
|
-
describe "subgroup", :match => true do
|
104
|
-
it("example 2") { example_2_filters = filters.dup }
|
105
|
-
describe "sub-subgroup", :match => true do
|
106
|
-
it("example 3") { example_3_filters = filters.dup }
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
group.run
|
111
|
-
|
112
|
-
example_1_filters.should eq([:before_all])
|
113
|
-
example_2_filters.should eq([:before_all])
|
114
|
-
example_3_filters.should eq([:before_all])
|
115
|
-
|
116
|
-
filters.should eq([:before_all, :after_all])
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should not be ran if the filter doesn't match the example group's filter" do
|
120
|
-
filters = []
|
121
|
-
RSpec.configure do |c|
|
122
|
-
c.before(:all, :match => false) { filters << "before all in config"}
|
123
|
-
c.around(:each, :match => false) {|example| filters << "around each in config"; example.run}
|
124
|
-
c.before(:each, :match => false) { filters << "before each in config"}
|
125
|
-
c.after(:each, :match => false) { filters << "after each in config"}
|
126
|
-
c.after(:all, :match => false) { filters << "after all in config"}
|
127
|
-
end
|
128
|
-
group = ExampleGroup.describe(:match => true)
|
129
|
-
group.example("example") {}
|
130
|
-
group.run
|
131
|
-
filters.should eq([])
|
132
|
-
end
|
133
|
-
|
134
|
-
context "when the hook filters apply to individual examples instead of example groups" do
|
135
|
-
let(:each_filters) { [] }
|
136
|
-
let(:all_filters) { [] }
|
137
|
-
|
138
|
-
let(:group) do
|
139
|
-
md = example_metadata
|
140
|
-
ExampleGroup.describe do
|
141
|
-
it("example", md) { }
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def filters
|
146
|
-
each_filters + all_filters
|
147
|
-
end
|
148
|
-
|
149
|
-
before(:each) do
|
150
|
-
af, ef = all_filters, each_filters
|
151
|
-
|
152
|
-
RSpec.configure do |c|
|
153
|
-
c.before(:all, :foo => :bar) { af << "before all in config"}
|
154
|
-
c.around(:each, :foo => :bar) {|example| ef << "around each in config"; example.run}
|
155
|
-
c.before(:each, :foo => :bar) { ef << "before each in config"}
|
156
|
-
c.after(:each, :foo => :bar) { ef << "after each in config"}
|
157
|
-
c.after(:all, :foo => :bar) { af << "after all in config"}
|
158
|
-
end
|
159
|
-
|
160
|
-
group.run
|
161
|
-
end
|
162
|
-
|
163
|
-
describe 'an example with matching metadata' do
|
164
|
-
let(:example_metadata) { { :foo => :bar } }
|
165
|
-
|
166
|
-
it "runs the `:each` hooks" do
|
167
|
-
each_filters.should eq([
|
168
|
-
'around each in config',
|
169
|
-
'before each in config',
|
170
|
-
'after each in config'
|
171
|
-
])
|
172
|
-
end
|
173
|
-
|
174
|
-
it "does not run the `:all` hooks" do
|
175
|
-
all_filters.should be_empty
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
describe 'an example without matching metadata' do
|
180
|
-
let(:example_metadata) { { :foo => :bazz } }
|
181
|
-
|
182
|
-
it "does not run any of the hooks" do
|
183
|
-
filters.should be_empty
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
describe "hooks with multiple filters" do
|
190
|
-
it "should be ran if all hook filters match the group's filters" do
|
191
|
-
filters = []
|
192
|
-
RSpec.configure do |c|
|
193
|
-
c.before(:all, :one => 1) { filters << "before all in config"}
|
194
|
-
c.around(:each, :two => 2, :one => 1) {|example| filters << "around each in config"; example.run}
|
195
|
-
c.before(:each, :one => 1, :two => 2) { filters << "before each in config"}
|
196
|
-
c.after(:each, :one => 1, :two => 2, :three => 3) { filters << "after each in config"}
|
197
|
-
c.after(:all, :one => 1, :three => 3) { filters << "after all in config"}
|
198
|
-
end
|
199
|
-
group = ExampleGroup.describe(:one => 1, :two => 2, :three => 3)
|
200
|
-
group.example("example") {}
|
201
|
-
group.run
|
202
|
-
filters.should eq([
|
203
|
-
"before all in config",
|
204
|
-
"around each in config",
|
205
|
-
"before each in config",
|
206
|
-
"after each in config",
|
207
|
-
"after all in config"
|
208
|
-
])
|
209
|
-
end
|
210
|
-
|
211
|
-
it "should not be ran if some hook filters don't match the group's filters" do
|
212
|
-
filters = []
|
213
|
-
RSpec.configure do |c|
|
214
|
-
c.before(:all, :one => 1, :four => 4) { filters << "before all in config"}
|
215
|
-
c.around(:each, :two => 2, :four => 4) {|example| filters << "around each in config"; example.run}
|
216
|
-
c.before(:each, :one => 1, :two => 2, :four => 4) { filters << "before each in config"}
|
217
|
-
c.after(:each, :one => 1, :two => 2, :three => 3, :four => 4) { filters << "after each in config"}
|
218
|
-
c.after(:all, :one => 1, :three => 3, :four => 4) { filters << "after all in config"}
|
219
|
-
end
|
220
|
-
group = ExampleGroup.describe(:one => 1, :two => 2, :three => 3)
|
221
|
-
group.example("example") {}
|
222
|
-
group.run
|
223
|
-
filters.should eq([])
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
@@ -1,250 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module RSpec::Core
|
4
|
-
describe Hooks do
|
5
|
-
class HooksHost
|
6
|
-
include Hooks
|
7
|
-
end
|
8
|
-
|
9
|
-
[:before, :after, :around].each do |type|
|
10
|
-
[:each, :all].each do |scope|
|
11
|
-
next if type == :around && scope == :all
|
12
|
-
|
13
|
-
describe "##{type}(#{scope})" do
|
14
|
-
it_behaves_like "metadata hash builder" do
|
15
|
-
define_method :metadata_hash do |*args|
|
16
|
-
instance = HooksHost.new
|
17
|
-
args.unshift scope if scope
|
18
|
-
hooks = instance.send(type, *args) {}
|
19
|
-
hooks.first.options
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
[true, false].each do |config_value|
|
26
|
-
context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to #{config_value}" do
|
27
|
-
before(:each) do
|
28
|
-
Kernel.stub(:warn)
|
29
|
-
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = config_value }
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "##{type}(no scope)" do
|
33
|
-
let(:instance) { HooksHost.new }
|
34
|
-
|
35
|
-
it "defaults to :each scope if no arguments are given" do
|
36
|
-
hooks = instance.send(type) {}
|
37
|
-
hook = hooks.first
|
38
|
-
instance.hooks[type][:each].should include(hook)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "defaults to :each scope if the only argument is a metadata hash" do
|
42
|
-
hooks = instance.send(type, :foo => :bar) {}
|
43
|
-
hook = hooks.first
|
44
|
-
instance.hooks[type][:each].should include(hook)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "raises an error if only metadata symbols are given as arguments" do
|
48
|
-
expect { instance.send(type, :foo, :bar) {} }.to raise_error(ArgumentError)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
[:before, :after].each do |type|
|
56
|
-
[:each, :all, :suite].each do |scope|
|
57
|
-
[true, false].each do |config_value|
|
58
|
-
context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to #{config_value}" do
|
59
|
-
before(:each) do
|
60
|
-
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = config_value }
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "##{type}(#{scope.inspect})" do
|
64
|
-
let(:instance) { HooksHost.new }
|
65
|
-
let!(:hook) do
|
66
|
-
hooks = instance.send(type, scope) {}
|
67
|
-
hooks.first
|
68
|
-
end
|
69
|
-
|
70
|
-
it "does not make #{scope.inspect} a metadata key" do
|
71
|
-
hook.options.should be_empty
|
72
|
-
end
|
73
|
-
|
74
|
-
it "is scoped to #{scope.inspect}" do
|
75
|
-
instance.hooks[type][scope].should include(hook)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "#around" do
|
84
|
-
context "when not running the example within the around block" do
|
85
|
-
it "does not run the example" do
|
86
|
-
examples = []
|
87
|
-
group = ExampleGroup.describe do
|
88
|
-
around do |example|
|
89
|
-
end
|
90
|
-
it "foo" do
|
91
|
-
examples << self
|
92
|
-
end
|
93
|
-
end
|
94
|
-
group.run
|
95
|
-
examples.should have(0).example
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context "when running the example within the around block" do
|
100
|
-
it "runs the example" do
|
101
|
-
examples = []
|
102
|
-
group = ExampleGroup.describe do
|
103
|
-
around do |example|
|
104
|
-
example.run
|
105
|
-
end
|
106
|
-
it "foo" do
|
107
|
-
examples << self
|
108
|
-
end
|
109
|
-
end
|
110
|
-
group.run
|
111
|
-
examples.should have(1).example
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context "when running the example within a block passed to a method" do
|
116
|
-
it "runs the example" do
|
117
|
-
examples = []
|
118
|
-
group = ExampleGroup.describe do
|
119
|
-
def yielder
|
120
|
-
yield
|
121
|
-
end
|
122
|
-
|
123
|
-
around do |example|
|
124
|
-
yielder { example.run }
|
125
|
-
end
|
126
|
-
it "foo" do
|
127
|
-
examples << self
|
128
|
-
end
|
129
|
-
end
|
130
|
-
group.run
|
131
|
-
examples.should have(1).example
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
[:all, :each].each do |scope|
|
137
|
-
describe "prepend_before(#{scope})" do
|
138
|
-
it "adds to the front of the list of before(:#{scope}) hooks" do
|
139
|
-
messages = []
|
140
|
-
|
141
|
-
RSpec.configure { |config| config.before(scope) { messages << "config 3" } }
|
142
|
-
RSpec.configure { |config| config.prepend_before(scope) { messages << "config 2" } }
|
143
|
-
RSpec.configure { |config| config.before(scope) { messages << "config 4" } }
|
144
|
-
RSpec.configure { |config| config.prepend_before(scope) { messages << "config 1" } }
|
145
|
-
|
146
|
-
group = ExampleGroup.describe { example {} }
|
147
|
-
group.before(scope) { messages << "group 3" }
|
148
|
-
group.prepend_before(scope) { messages << "group 2" }
|
149
|
-
group.before(scope) { messages << "group 4" }
|
150
|
-
group.prepend_before(scope) { messages << "group 1" }
|
151
|
-
|
152
|
-
group.run
|
153
|
-
|
154
|
-
messages.should eq([
|
155
|
-
'group 1',
|
156
|
-
'group 2',
|
157
|
-
'config 1',
|
158
|
-
'config 2',
|
159
|
-
'config 3',
|
160
|
-
'config 4',
|
161
|
-
'group 3',
|
162
|
-
'group 4'
|
163
|
-
])
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
describe "append_before(#{scope})" do
|
168
|
-
it "adds to the back of the list of before(:#{scope}) hooks (same as `before`)" do
|
169
|
-
messages = []
|
170
|
-
|
171
|
-
RSpec.configure { |config| config.before(scope) { messages << "config 1" } }
|
172
|
-
RSpec.configure { |config| config.append_before(scope) { messages << "config 2" } }
|
173
|
-
RSpec.configure { |config| config.before(scope) { messages << "config 3" } }
|
174
|
-
|
175
|
-
group = ExampleGroup.describe { example {} }
|
176
|
-
group.before(scope) { messages << "group 1" }
|
177
|
-
group.append_before(scope) { messages << "group 2" }
|
178
|
-
group.before(scope) { messages << "group 3" }
|
179
|
-
|
180
|
-
group.run
|
181
|
-
|
182
|
-
messages.should eq([
|
183
|
-
'config 1',
|
184
|
-
'config 2',
|
185
|
-
'config 3',
|
186
|
-
'group 1',
|
187
|
-
'group 2',
|
188
|
-
'group 3'
|
189
|
-
])
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
describe "prepend_after(#{scope})" do
|
194
|
-
it "adds to the front of the list of after(:#{scope}) hooks (same as `after`)" do
|
195
|
-
messages = []
|
196
|
-
|
197
|
-
RSpec.configure { |config| config.after(scope) { messages << "config 3" } }
|
198
|
-
RSpec.configure { |config| config.prepend_after(scope) { messages << "config 2" } }
|
199
|
-
RSpec.configure { |config| config.after(scope) { messages << "config 1" } }
|
200
|
-
|
201
|
-
group = ExampleGroup.describe { example {} }
|
202
|
-
group.after(scope) { messages << "group 3" }
|
203
|
-
group.prepend_after(scope) { messages << "group 2" }
|
204
|
-
group.after(scope) { messages << "group 1" }
|
205
|
-
|
206
|
-
group.run
|
207
|
-
|
208
|
-
messages.should eq([
|
209
|
-
'group 1',
|
210
|
-
'group 2',
|
211
|
-
'group 3',
|
212
|
-
'config 1',
|
213
|
-
'config 2',
|
214
|
-
'config 3'
|
215
|
-
])
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe "append_after(#{scope})" do
|
220
|
-
it "adds to the back of the list of after(:#{scope}) hooks" do
|
221
|
-
messages = []
|
222
|
-
|
223
|
-
RSpec.configure { |config| config.after(scope) { messages << "config 2" } }
|
224
|
-
RSpec.configure { |config| config.append_after(scope) { messages << "config 3" } }
|
225
|
-
RSpec.configure { |config| config.after(scope) { messages << "config 1" } }
|
226
|
-
RSpec.configure { |config| config.append_after(scope) { messages << "config 4" } }
|
227
|
-
|
228
|
-
group = ExampleGroup.describe { example {} }
|
229
|
-
group.after(scope) { messages << "group 2" }
|
230
|
-
group.append_after(scope) { messages << "group 3" }
|
231
|
-
group.after(scope) { messages << "group 1" }
|
232
|
-
group.append_after(scope) { messages << "group 4" }
|
233
|
-
|
234
|
-
group.run
|
235
|
-
|
236
|
-
messages.should eq([
|
237
|
-
'group 1',
|
238
|
-
'group 2',
|
239
|
-
'config 1',
|
240
|
-
'config 2',
|
241
|
-
'config 3',
|
242
|
-
'config 4',
|
243
|
-
'group 3',
|
244
|
-
'group 4'
|
245
|
-
])
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|
250
|
-
end
|
data/spec/rspec/core/let_spec.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "#let" do
|
4
|
-
let(:counter) do
|
5
|
-
Class.new do
|
6
|
-
def initialize
|
7
|
-
@count = 0
|
8
|
-
end
|
9
|
-
def count
|
10
|
-
@count += 1
|
11
|
-
end
|
12
|
-
end.new
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:nil_value) do
|
16
|
-
@nil_value_count += 1
|
17
|
-
nil
|
18
|
-
end
|
19
|
-
|
20
|
-
it "generates an instance method" do
|
21
|
-
counter.count.should eq(1)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "caches the value" do
|
25
|
-
counter.count.should eq(1)
|
26
|
-
counter.count.should eq(2)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "caches a nil value" do
|
30
|
-
@nil_value_count = 0
|
31
|
-
nil_value
|
32
|
-
nil_value
|
33
|
-
|
34
|
-
@nil_value_count.should eq(1)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "#let!" do
|
39
|
-
let!(:creator) do
|
40
|
-
Class.new do
|
41
|
-
@count = 0
|
42
|
-
def self.count
|
43
|
-
@count += 1
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it "evaluates the value non-lazily" do
|
49
|
-
lambda { creator.count }.should_not raise_error
|
50
|
-
end
|
51
|
-
|
52
|
-
it "does not interfere between tests" do
|
53
|
-
creator.count.should eq(1)
|
54
|
-
end
|
55
|
-
end
|