rspec-core 2.0.0.beta.22 → 2.6.4
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/.gitignore +1 -0
- data/.rspec +0 -1
- data/.travis.yml +9 -0
- data/Changelog.md +305 -0
- data/Gemfile +45 -20
- data/Guardfile +5 -0
- data/License.txt +2 -1
- data/{README.markdown → README.md} +23 -5
- data/Rakefile +63 -32
- data/bin/autospec +13 -0
- data/bin/rspec +24 -2
- data/cucumber.yml +1 -1
- data/features/.nav +57 -0
- data/features/Autotest.md +38 -0
- data/features/README.md +17 -0
- data/features/Upgrade.md +320 -0
- data/features/command_line/README.md +28 -0
- data/features/command_line/configure.feature +18 -15
- data/features/command_line/example_name_option.feature +37 -23
- data/features/command_line/exit_status.feature +16 -31
- data/features/command_line/format_option.feature +73 -0
- data/features/command_line/line_number_appended_to_path.feature +25 -27
- data/features/command_line/line_number_option.feature +11 -10
- data/features/command_line/rake_task.feature +68 -0
- data/features/command_line/tag.feature +90 -0
- data/features/configuration/alias_example_to.feature +48 -0
- data/features/configuration/custom_settings.feature +8 -10
- data/features/configuration/fail_fast.feature +77 -0
- data/features/configuration/read_options_from_file.feature +42 -26
- data/features/example_groups/basic_structure.feature +55 -0
- data/features/example_groups/shared_context.feature +74 -0
- data/features/example_groups/shared_example_group.feature +56 -41
- data/features/expectation_framework_integration/configure_expectation_framework.feature +73 -0
- data/features/filtering/exclusion_filters.feature +69 -9
- data/features/filtering/if_and_unless.feature +168 -0
- data/features/filtering/inclusion_filters.feature +58 -26
- data/features/filtering/run_all_when_everything_filtered.feature +46 -0
- data/features/formatters/custom_formatter.feature +17 -13
- data/features/formatters/text_formatter.feature +43 -0
- data/features/helper_methods/arbitrary_methods.feature +40 -0
- data/features/helper_methods/let.feature +50 -0
- data/features/helper_methods/modules.feature +149 -0
- data/features/hooks/around_hooks.feature +99 -69
- data/features/hooks/before_and_after_hooks.feature +74 -40
- data/features/hooks/filtering.feature +227 -0
- data/features/metadata/current_example.feature +17 -0
- data/features/metadata/described_class.feature +17 -0
- data/features/metadata/user_defined.feature +111 -0
- data/features/mock_framework_integration/use_any_framework.feature +106 -0
- data/features/mock_framework_integration/use_flexmock.feature +84 -11
- data/features/mock_framework_integration/use_mocha.feature +85 -11
- data/features/mock_framework_integration/use_rr.feature +86 -11
- data/features/mock_framework_integration/use_rspec.feature +85 -11
- data/features/pending/pending_examples.feature +143 -5
- data/features/spec_files/arbitrary_file_suffix.feature +2 -2
- data/features/step_definitions/additional_cli_steps.rb +30 -0
- data/features/subject/attribute_of_subject.feature +93 -15
- data/features/subject/explicit_subject.feature +28 -17
- data/features/subject/implicit_receiver.feature +29 -0
- data/features/subject/implicit_subject.feature +9 -10
- data/features/support/env.rb +6 -1
- data/lib/autotest/discover.rb +1 -0
- data/lib/autotest/rspec2.rb +15 -11
- data/lib/rspec/autorun.rb +2 -0
- data/lib/rspec/core/backward_compatibility.rb +32 -3
- data/lib/rspec/core/command_line.rb +4 -28
- data/lib/rspec/core/command_line_configuration.rb +16 -16
- data/lib/rspec/core/configuration.rb +286 -89
- data/lib/rspec/core/configuration_options.rb +74 -40
- data/lib/rspec/core/deprecation.rb +1 -1
- data/lib/rspec/core/drb_command_line.rb +5 -11
- data/lib/rspec/core/dsl.rb +11 -0
- data/lib/rspec/core/example.rb +63 -39
- data/lib/rspec/core/example_group.rb +109 -59
- data/lib/rspec/core/expecting/with_rspec.rb +9 -0
- data/lib/rspec/core/expecting/with_stdlib.rb +9 -0
- data/lib/rspec/core/extensions/kernel.rb +1 -1
- data/lib/rspec/core/extensions.rb +0 -1
- data/lib/rspec/core/formatters/base_formatter.rb +30 -15
- data/lib/rspec/core/formatters/base_text_formatter.rb +68 -40
- data/lib/rspec/core/formatters/documentation_formatter.rb +4 -2
- data/lib/rspec/core/formatters/helpers.rb +0 -4
- data/lib/rspec/core/formatters/html_formatter.rb +146 -41
- data/lib/rspec/core/formatters/progress_formatter.rb +1 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +1 -1
- data/lib/rspec/core/formatters/text_mate_formatter.rb +3 -1
- data/lib/rspec/core/hooks.rb +56 -17
- data/lib/rspec/core/metadata.rb +75 -64
- data/lib/rspec/core/metadata_hash_builder.rb +93 -0
- data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
- data/lib/rspec/core/mocking/with_mocha.rb +2 -0
- data/lib/rspec/core/mocking/with_rr.rb +2 -0
- data/lib/rspec/core/mocking/with_rspec.rb +3 -1
- data/lib/rspec/core/option_parser.rb +49 -7
- data/lib/rspec/core/pending.rb +22 -4
- data/lib/rspec/core/rake_task.rb +64 -28
- data/lib/rspec/core/reporter.rb +6 -5
- data/lib/rspec/core/ruby_project.rb +2 -2
- data/lib/rspec/core/runner.rb +50 -6
- data/lib/rspec/core/shared_context.rb +16 -0
- data/lib/rspec/core/shared_example_group.rb +19 -4
- data/lib/rspec/core/subject.rb +92 -65
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +85 -27
- data/lib/rspec/core.rb +55 -24
- data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
- data/rspec-core.gemspec +4 -25
- data/script/FullBuildRakeFile +63 -0
- data/script/cucumber +1 -0
- data/script/full_build +1 -0
- data/script/spec +1 -0
- data/spec/autotest/discover_spec.rb +19 -0
- data/spec/autotest/failed_results_re_spec.rb +25 -9
- data/spec/autotest/rspec_spec.rb +32 -41
- data/spec/rspec/core/command_line_spec.rb +62 -7
- data/spec/rspec/core/configuration_options_spec.rb +216 -148
- data/spec/rspec/core/configuration_spec.rb +419 -108
- data/spec/rspec/core/deprecations_spec.rb +38 -1
- data/spec/rspec/core/drb_command_line_spec.rb +21 -56
- data/spec/rspec/core/example_group_spec.rb +366 -127
- data/spec/rspec/core/example_spec.rb +125 -45
- data/spec/rspec/core/formatters/base_formatter_spec.rb +61 -1
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +134 -97
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +7 -6
- data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +199 -81
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +195 -83
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +199 -81
- data/spec/rspec/core/formatters/html_formatted-1.9.1.html +206 -81
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +206 -61
- data/spec/rspec/core/formatters/html_formatter_spec.rb +17 -9
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +1 -1
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +199 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +195 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +199 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +206 -81
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +206 -81
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +22 -7
- data/spec/rspec/core/hooks_filtering_spec.rb +128 -5
- data/spec/rspec/core/hooks_spec.rb +90 -4
- data/spec/rspec/core/metadata_spec.rb +176 -163
- data/spec/rspec/core/option_parser_spec.rb +73 -6
- data/spec/rspec/core/pending_example_spec.rb +137 -35
- data/spec/rspec/core/rake_task_spec.rb +62 -29
- data/spec/rspec/core/reporter_spec.rb +20 -4
- data/spec/rspec/core/resources/formatter_specs.rb +25 -1
- data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
- data/spec/rspec/core/runner_spec.rb +60 -10
- data/spec/rspec/core/shared_context_spec.rb +30 -0
- data/spec/rspec/core/shared_example_group_spec.rb +59 -23
- data/spec/rspec/core/subject_spec.rb +136 -0
- data/spec/rspec/core/world_spec.rb +211 -68
- data/spec/rspec/core_spec.rb +28 -0
- data/spec/spec_helper.rb +41 -24
- data/spec/support/matchers.rb +44 -13
- data/spec/support/shared_example_groups.rb +41 -0
- data/spec/support/spec_files.rb +44 -0
- data/spec.txt +1126 -0
- metadata +100 -170
- data/.treasure_map.rb +0 -23
- data/History.md +0 -30
- data/Upgrade.markdown +0 -150
- data/autotest/discover.rb +0 -2
- data/features/README.markdown +0 -12
- data/features/example_groups/describe_aliases.feature +0 -25
- data/features/example_groups/nested_groups.feature +0 -44
- data/features/hooks/described_class.feature +0 -14
- data/features/hooks/halt.feature +0 -26
- data/lib/rspec/core/around_proxy.rb +0 -14
- data/lib/rspec/core/extensions/object.rb +0 -15
- data/lib/rspec/core/formatters.rb +0 -8
- data/spec/ruby_forker.rb +0 -13
- data/specs.watchr +0 -59
|
@@ -9,10 +9,63 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
9
9
|
example_group.example('example description')
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
it_behaves_like "metadata hash builder" do
|
|
13
|
+
def metadata_hash(*args)
|
|
14
|
+
example = example_group.example('example description', *args)
|
|
15
|
+
example.metadata
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "auto-generated example descriptions" do
|
|
20
|
+
let(:generated_description) { "the generated description" }
|
|
21
|
+
let(:rspec_example) { example_group.specify { 5.should == 5 } }
|
|
22
|
+
before(:each) { RSpec::Matchers.stub(:generated_description => generated_description) }
|
|
23
|
+
|
|
24
|
+
def expect_with(*frameworks)
|
|
25
|
+
RSpec.configuration.stub(:expecting_with_rspec?).and_return(frameworks.include?(:rspec))
|
|
26
|
+
|
|
27
|
+
if frameworks.include?(:stdlib)
|
|
28
|
+
example_group.class_eval do
|
|
29
|
+
def assert(val)
|
|
30
|
+
raise "Expected #{val} to be true" unless val
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "when `expect_with :rspec` is configured" do
|
|
37
|
+
before(:each) { expect_with :rspec }
|
|
38
|
+
|
|
39
|
+
it "generates a description for an example with no description" do
|
|
40
|
+
expect {
|
|
41
|
+
example_group.run
|
|
42
|
+
}.to change { rspec_example.metadata[:description] }.from("").to(generated_description)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context "when `expect_with :rspec, :stdlib` is configured" do
|
|
47
|
+
before(:each) { expect_with :rspec, :stdlib }
|
|
48
|
+
|
|
49
|
+
it "generates a description for an example with no description" do
|
|
50
|
+
expect {
|
|
51
|
+
example_group.run
|
|
52
|
+
}.to change { rspec_example.metadata[:description] }.from("").to(generated_description)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context "when `expect_with :stdlib` is configured" do
|
|
57
|
+
let!(:stdlib_example) { example_group.specify { assert 5 == 5 } }
|
|
58
|
+
before(:each) { expect_with :stdlib }
|
|
59
|
+
|
|
60
|
+
it "does not attempt to get the generated description from RSpec::Matchers" do
|
|
61
|
+
RSpec::Matchers.should_not_receive(:generated_description)
|
|
62
|
+
example_group.run
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "fails an example with no description" do
|
|
66
|
+
example_group.run
|
|
67
|
+
stdlib_example.should have_failed_with(NotImplementedError)
|
|
68
|
+
end
|
|
16
69
|
end
|
|
17
70
|
end
|
|
18
71
|
|
|
@@ -40,17 +93,12 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
40
93
|
end
|
|
41
94
|
|
|
42
95
|
describe "#run" do
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
group = RSpec::Core::ExampleGroup.describe
|
|
47
|
-
example = group.example('example') {}
|
|
48
|
-
|
|
49
|
-
reporter = double('reporter').as_null_object
|
|
50
|
-
reporter.should_not_receive(:example_started)
|
|
51
|
-
|
|
52
|
-
example.run(group.new,reporter)
|
|
96
|
+
it "sets its reference to the example group instance to nil" do
|
|
97
|
+
group = RSpec::Core::ExampleGroup.describe do
|
|
98
|
+
example('example') { 1.should eq(1) }
|
|
53
99
|
end
|
|
100
|
+
group.run
|
|
101
|
+
group.examples.first.instance_variable_get("@example_group_instance").should be_nil
|
|
54
102
|
end
|
|
55
103
|
|
|
56
104
|
it "runs after(:each) when the example passes" do
|
|
@@ -59,7 +107,7 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
59
107
|
after(:each) { after_run = true }
|
|
60
108
|
example('example') { 1.should == 1 }
|
|
61
109
|
end
|
|
62
|
-
group.
|
|
110
|
+
group.run
|
|
63
111
|
after_run.should be_true, "expected after(:each) to be run"
|
|
64
112
|
end
|
|
65
113
|
|
|
@@ -69,7 +117,7 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
69
117
|
after(:each) { after_run = true }
|
|
70
118
|
example('example') { 1.should == 2 }
|
|
71
119
|
end
|
|
72
|
-
group.
|
|
120
|
+
group.run
|
|
73
121
|
after_run.should be_true, "expected after(:each) to be run"
|
|
74
122
|
end
|
|
75
123
|
|
|
@@ -79,7 +127,7 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
79
127
|
after(:each) { after_run = true }
|
|
80
128
|
example('example') { raise "this error" }
|
|
81
129
|
end
|
|
82
|
-
group.
|
|
130
|
+
group.run
|
|
83
131
|
after_run.should be_true, "expected after(:each) to be run"
|
|
84
132
|
end
|
|
85
133
|
|
|
@@ -91,7 +139,7 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
91
139
|
after(:each) { raise "FOO" }
|
|
92
140
|
example('example') { 1.should == 1 }
|
|
93
141
|
end
|
|
94
|
-
group.
|
|
142
|
+
group.run
|
|
95
143
|
after_run.should be_true, "expected after(:each) to be run"
|
|
96
144
|
end
|
|
97
145
|
|
|
@@ -100,9 +148,9 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
100
148
|
group.after(:each) { raise "FOO" }
|
|
101
149
|
example = group.example('example') { 1.should == 1 }
|
|
102
150
|
|
|
103
|
-
group.
|
|
151
|
+
group.run
|
|
104
152
|
|
|
105
|
-
example.metadata[:execution_result][:
|
|
153
|
+
example.metadata[:execution_result][:exception].message.should == "FOO"
|
|
106
154
|
end
|
|
107
155
|
end
|
|
108
156
|
|
|
@@ -119,7 +167,7 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
119
167
|
example { results << "example" }
|
|
120
168
|
end
|
|
121
169
|
|
|
122
|
-
group.
|
|
170
|
+
group.run
|
|
123
171
|
results.should eq([
|
|
124
172
|
"around (before)",
|
|
125
173
|
"before",
|
|
@@ -128,17 +176,34 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
128
176
|
"around (after)"
|
|
129
177
|
])
|
|
130
178
|
end
|
|
131
|
-
end
|
|
132
179
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
180
|
+
context "clearing ivars" do
|
|
181
|
+
it "sets ivars to nil to prep them for GC" do
|
|
182
|
+
group = RSpec::Core::ExampleGroup.describe do
|
|
183
|
+
before(:all) { @before_all = :before_all }
|
|
184
|
+
before(:each) { @before_each = :before_each }
|
|
185
|
+
after(:each) { @after_each = :after_each }
|
|
186
|
+
after(:all) { @after_all = :after_all }
|
|
187
|
+
end
|
|
188
|
+
example = group.example("does something") do
|
|
189
|
+
@in_example = :in_example
|
|
190
|
+
end
|
|
191
|
+
example_group_instance = group.new
|
|
192
|
+
example.run(example_group_instance, double('reporter').as_null_object)
|
|
193
|
+
|
|
194
|
+
%w[@before_all @before_each @after_each @after_all].each do |ivar|
|
|
195
|
+
example_group_instance.instance_variable_get(ivar).should be_nil
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it "does not impact the before_all_ivars which are copied to each example" do
|
|
200
|
+
group = RSpec::Core::ExampleGroup.describe do
|
|
201
|
+
before(:all) { @before_all = "abc" }
|
|
202
|
+
example("first") { @before_all.should_not be_nil }
|
|
203
|
+
example("second") { @before_all.should_not be_nil }
|
|
204
|
+
end
|
|
205
|
+
group.run.should be_true
|
|
206
|
+
end
|
|
142
207
|
end
|
|
143
208
|
end
|
|
144
209
|
|
|
@@ -148,45 +213,60 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
148
213
|
group = RSpec::Core::ExampleGroup.describe do
|
|
149
214
|
example { pending }
|
|
150
215
|
end
|
|
151
|
-
group.
|
|
216
|
+
group.run
|
|
152
217
|
group.examples.first.should be_pending
|
|
153
218
|
end
|
|
219
|
+
|
|
220
|
+
it "allows post-example processing in around hooks (see https://github.com/rspec/rspec-core/issues/322)" do
|
|
221
|
+
blah = nil
|
|
222
|
+
group = RSpec::Core::ExampleGroup.describe do
|
|
223
|
+
around do |example|
|
|
224
|
+
example.run
|
|
225
|
+
blah = :success
|
|
226
|
+
end
|
|
227
|
+
example { pending }
|
|
228
|
+
end
|
|
229
|
+
group.run
|
|
230
|
+
blah.should be(:success)
|
|
231
|
+
end
|
|
154
232
|
end
|
|
155
233
|
|
|
156
234
|
context "in before(:each)" do
|
|
157
|
-
it "sets
|
|
235
|
+
it "sets each example to pending" do
|
|
158
236
|
group = RSpec::Core::ExampleGroup.describe do
|
|
159
237
|
before(:each) { pending }
|
|
160
238
|
example {}
|
|
239
|
+
example {}
|
|
161
240
|
end
|
|
162
|
-
group.
|
|
241
|
+
group.run
|
|
163
242
|
group.examples.first.should be_pending
|
|
243
|
+
group.examples.last.should be_pending
|
|
164
244
|
end
|
|
165
245
|
end
|
|
166
246
|
|
|
167
|
-
context "in
|
|
168
|
-
it "sets
|
|
247
|
+
context "in before(:all)" do
|
|
248
|
+
it "sets each example to pending" do
|
|
169
249
|
group = RSpec::Core::ExampleGroup.describe do
|
|
170
|
-
|
|
250
|
+
before(:all) { pending }
|
|
251
|
+
example {}
|
|
171
252
|
example {}
|
|
172
253
|
end
|
|
173
|
-
group.
|
|
254
|
+
group.run
|
|
174
255
|
group.examples.first.should be_pending
|
|
256
|
+
group.examples.last.should be_pending
|
|
175
257
|
end
|
|
176
258
|
end
|
|
177
259
|
|
|
178
|
-
context "in
|
|
179
|
-
|
|
260
|
+
context "in around(:each)" do
|
|
261
|
+
it "sets the example to pending" do
|
|
180
262
|
group = RSpec::Core::ExampleGroup.describe do
|
|
181
|
-
|
|
263
|
+
around(:each) { pending }
|
|
182
264
|
example {}
|
|
183
265
|
end
|
|
184
|
-
group.
|
|
266
|
+
group.run
|
|
185
267
|
group.examples.first.should be_pending
|
|
186
|
-
expect do
|
|
187
|
-
group.run_all
|
|
188
|
-
end.to raise_error(/undefined method `metadata'/)
|
|
189
268
|
end
|
|
190
269
|
end
|
|
270
|
+
|
|
191
271
|
end
|
|
192
272
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'rspec/core/formatters/base_formatter'
|
|
2
3
|
|
|
3
4
|
describe RSpec::Core::Formatters::BaseFormatter do
|
|
4
5
|
|
|
@@ -17,4 +18,63 @@ describe RSpec::Core::Formatters::BaseFormatter do
|
|
|
17
18
|
end
|
|
18
19
|
end
|
|
19
20
|
|
|
21
|
+
describe "read_failed_line" do
|
|
22
|
+
it "deals gracefully with a heterogeneous language stack trace" do
|
|
23
|
+
exception = mock(:Exception, :backtrace => [
|
|
24
|
+
"at Object.prototypeMethod (foo:331:18)",
|
|
25
|
+
"at Array.forEach (native)",
|
|
26
|
+
"at a_named_javascript_function (/some/javascript/file.js:39:5)",
|
|
27
|
+
"/some/line/of/ruby.rb:14"
|
|
28
|
+
])
|
|
29
|
+
example = mock(:Example, :file_path => __FILE__)
|
|
30
|
+
lambda {
|
|
31
|
+
formatter.send(:read_failed_line, exception, example)
|
|
32
|
+
}.should_not raise_error
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context "when String alias to_int to_i" do
|
|
36
|
+
before do
|
|
37
|
+
String.class_eval do
|
|
38
|
+
alias :to_int :to_i
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
after do
|
|
43
|
+
String.class_eval do
|
|
44
|
+
undef to_int
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "doesn't hang when file exists" do
|
|
49
|
+
pending("This issue still exists on JRuby, but should be resolved shortly: https://github.com/rspec/rspec-core/issues/295", :if => RUBY_PLATFORM == 'java')
|
|
50
|
+
exception = mock(:Exception, :backtrace => [ "#{__FILE__}:#{__LINE__}"])
|
|
51
|
+
|
|
52
|
+
example = mock(:Example, :file_path => __FILE__)
|
|
53
|
+
formatter.send(:read_failed_line, exception, example).should
|
|
54
|
+
eql %Q{ exception = mock(:Exception, :backtrace => [ "\#{__FILE__}:\#{__LINE__}"])\n}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe "#format_backtrace" do
|
|
61
|
+
let(:rspec_expectations_dir) { "/path/to/rspec-expectations/lib" }
|
|
62
|
+
let(:rspec_core_dir) { "/path/to/rspec-core/lib" }
|
|
63
|
+
let(:backtrace) do
|
|
64
|
+
[
|
|
65
|
+
"#{rspec_expectations_dir}/rspec/matchers/operator_matcher.rb:51:in `eval_match'",
|
|
66
|
+
"#{rspec_expectations_dir}/rspec/matchers/operator_matcher.rb:29:in `=='",
|
|
67
|
+
"./my_spec.rb:5",
|
|
68
|
+
"#{rspec_core_dir}/rspec/core/example.rb:52:in `run'",
|
|
69
|
+
"#{rspec_core_dir}/rspec/core/runner.rb:37:in `run'",
|
|
70
|
+
RSpec::Core::Runner::AT_EXIT_HOOK_BACKTRACE_LINE,
|
|
71
|
+
"./my_spec.rb:3"
|
|
72
|
+
]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "removes lines from rspec and lines that come before the invocation of the at_exit autorun hook" do
|
|
76
|
+
formatter.format_backtrace(backtrace, stub.as_null_object).should == ["./my_spec.rb:5"]
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
20
80
|
end
|
|
@@ -1,55 +1,112 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'rspec/core/formatters/base_text_formatter'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
describe RSpec::Core::Formatters::BaseTextFormatter do
|
|
5
|
+
let(:output) { StringIO.new }
|
|
6
|
+
let(:formatter) { RSpec::Core::Formatters::BaseTextFormatter.new(output) }
|
|
4
7
|
|
|
5
|
-
describe
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
describe "#summary_line" do
|
|
9
|
+
it "with 0s outputs pluralized (excluding pending)" do
|
|
10
|
+
formatter.summary_line(0,0,0).should eq("0 examples, 0 failures")
|
|
11
|
+
end
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
formatter.summary_line(0,0,0).should eq("0 examples, 0 failures")
|
|
13
|
-
end
|
|
14
|
-
end
|
|
13
|
+
it "with 1s outputs singular (including pending)" do
|
|
14
|
+
formatter.summary_line(1,1,1).should eq("1 example, 1 failure, 1 pending")
|
|
15
|
+
end
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end
|
|
17
|
+
it "with 2s outputs pluralized (including pending)" do
|
|
18
|
+
formatter.summary_line(2,2,2).should eq("2 examples, 2 failures, 2 pending")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
describe "#dump_commands_to_rerun_failed_examples" do
|
|
23
|
+
it "includes command to re-run each failed example" do
|
|
24
|
+
group = RSpec::Core::ExampleGroup.describe("example group") do
|
|
25
|
+
it("fails") { fail }
|
|
26
26
|
end
|
|
27
|
+
line = __LINE__ - 2
|
|
28
|
+
group.run(formatter)
|
|
29
|
+
formatter.dump_commands_to_rerun_failed_examples
|
|
30
|
+
output.string.should include("rspec #{RSpec::Core::Formatters::BaseFormatter::relative_path("#{__FILE__}:#{line}")} # example group fails")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "#dump_failures" do
|
|
35
|
+
let(:group) { RSpec::Core::ExampleGroup.describe("group name") }
|
|
36
|
+
|
|
37
|
+
before { RSpec.configuration.stub(:color_enabled?) { false } }
|
|
38
|
+
|
|
39
|
+
def run_all_and_dump_failures
|
|
40
|
+
group.run(formatter)
|
|
41
|
+
formatter.dump_failures
|
|
27
42
|
end
|
|
28
43
|
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
it "preserves formatting" do
|
|
45
|
+
group.example("example name") { "this".should eq("that") }
|
|
46
|
+
|
|
47
|
+
run_all_and_dump_failures
|
|
48
|
+
|
|
49
|
+
output.string.should =~ /group name example name/m
|
|
50
|
+
output.string.should =~ /(\s+)expected \"that\"\n\1 got \"this\"/m
|
|
51
|
+
end
|
|
31
52
|
|
|
32
|
-
|
|
53
|
+
context "with an exception without a message" do
|
|
54
|
+
it "does not throw NoMethodError" do
|
|
55
|
+
exception_without_message = Exception.new()
|
|
56
|
+
exception_without_message.stub(:message) { nil }
|
|
57
|
+
group.example("example name") { raise exception_without_message }
|
|
58
|
+
expect { run_all_and_dump_failures }.not_to raise_error(NoMethodError)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
33
61
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
62
|
+
context "with an exception class other than RSpec" do
|
|
63
|
+
it "does not show the error class" do
|
|
64
|
+
group.example("example name") { raise NameError.new('foo') }
|
|
65
|
+
run_all_and_dump_failures
|
|
66
|
+
output.string.should =~ /NameError/m
|
|
37
67
|
end
|
|
68
|
+
end
|
|
38
69
|
|
|
39
|
-
|
|
70
|
+
context "with a failed expectation (rspec-expectations)" do
|
|
71
|
+
it "does not show the error class" do
|
|
40
72
|
group.example("example name") { "this".should eq("that") }
|
|
73
|
+
run_all_and_dump_failures
|
|
74
|
+
output.string.should_not =~ /RSpec/m
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context "with a failed message expectation (rspec-mocks)" do
|
|
79
|
+
it "does not show the error class" do
|
|
80
|
+
group.example("example name") { "this".should_receive("that") }
|
|
81
|
+
run_all_and_dump_failures
|
|
82
|
+
output.string.should_not =~ /RSpec/m
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context 'for #share_examples_for' do
|
|
87
|
+
it 'outputs the name and location' do
|
|
88
|
+
|
|
89
|
+
share_examples_for 'foo bar' do
|
|
90
|
+
it("example name") { "this".should eq("that") }
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
line = __LINE__.next
|
|
94
|
+
group.it_should_behave_like('foo bar')
|
|
41
95
|
|
|
42
96
|
run_all_and_dump_failures
|
|
43
97
|
|
|
44
|
-
output.string.should
|
|
45
|
-
|
|
98
|
+
output.string.should include(
|
|
99
|
+
'Shared Example Group: "foo bar" called from ' +
|
|
100
|
+
"./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
|
|
101
|
+
)
|
|
46
102
|
end
|
|
47
103
|
|
|
48
|
-
context '
|
|
104
|
+
context 'that contains nested example groups' do
|
|
49
105
|
it 'outputs the name and location' do
|
|
50
|
-
|
|
51
106
|
share_examples_for 'foo bar' do
|
|
52
|
-
|
|
107
|
+
describe 'nested group' do
|
|
108
|
+
it("example name") { "this".should eq("that") }
|
|
109
|
+
end
|
|
53
110
|
end
|
|
54
111
|
|
|
55
112
|
line = __LINE__.next
|
|
@@ -62,98 +119,78 @@ module RSpec::Core::Formatters
|
|
|
62
119
|
"./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
|
|
63
120
|
)
|
|
64
121
|
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
65
124
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
end
|
|
125
|
+
context 'for #share_as' do
|
|
126
|
+
it 'outputs the name and location' do
|
|
127
|
+
|
|
128
|
+
share_as :FooBar do
|
|
129
|
+
it("example name") { "this".should eq("that") }
|
|
130
|
+
end
|
|
73
131
|
|
|
74
|
-
|
|
75
|
-
|
|
132
|
+
line = __LINE__.next
|
|
133
|
+
group.send(:include, FooBar)
|
|
76
134
|
|
|
77
|
-
|
|
135
|
+
run_all_and_dump_failures
|
|
78
136
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
end
|
|
137
|
+
output.string.should include(
|
|
138
|
+
'Shared Example Group: "FooBar" called from ' +
|
|
139
|
+
"./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
|
|
140
|
+
)
|
|
85
141
|
end
|
|
86
142
|
|
|
87
|
-
context '
|
|
143
|
+
context 'that contains nested example groups' do
|
|
88
144
|
it 'outputs the name and location' do
|
|
89
145
|
|
|
90
|
-
share_as :
|
|
91
|
-
|
|
146
|
+
share_as :NestedFoo do
|
|
147
|
+
describe 'nested group' do
|
|
148
|
+
describe 'hell' do
|
|
149
|
+
it("example name") { "this".should eq("that") }
|
|
150
|
+
end
|
|
151
|
+
end
|
|
92
152
|
end
|
|
93
153
|
|
|
94
154
|
line = __LINE__.next
|
|
95
|
-
group.send(:include,
|
|
155
|
+
group.send(:include, NestedFoo)
|
|
96
156
|
|
|
97
157
|
run_all_and_dump_failures
|
|
98
158
|
|
|
99
159
|
output.string.should include(
|
|
100
|
-
'Shared Example Group: "
|
|
160
|
+
'Shared Example Group: "NestedFoo" called from ' +
|
|
101
161
|
"./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
|
|
102
162
|
)
|
|
103
163
|
end
|
|
104
|
-
|
|
105
|
-
context 'that contains nested example groups' do
|
|
106
|
-
it 'outputs the name and location' do
|
|
107
|
-
|
|
108
|
-
share_as :NestedFoo do
|
|
109
|
-
describe 'nested group' do
|
|
110
|
-
describe 'hell' do
|
|
111
|
-
it("example name") { "this".should eq("that") }
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
line = __LINE__.next
|
|
117
|
-
group.send(:include, NestedFoo)
|
|
118
|
-
|
|
119
|
-
run_all_and_dump_failures
|
|
120
|
-
|
|
121
|
-
output.string.should include(
|
|
122
|
-
'Shared Example Group: "NestedFoo" called from ' +
|
|
123
|
-
"./spec/rspec/core/formatters/base_text_formatter_spec.rb:#{line}"
|
|
124
|
-
)
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
164
|
end
|
|
128
165
|
end
|
|
166
|
+
end
|
|
129
167
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
end
|
|
136
|
-
group.run_all(double('reporter').as_null_object)
|
|
137
|
-
group.examples
|
|
168
|
+
describe "#dump_profile" do
|
|
169
|
+
before do
|
|
170
|
+
formatter.stub(:examples) do
|
|
171
|
+
group = RSpec::Core::ExampleGroup.describe("group") do
|
|
172
|
+
example("example")
|
|
138
173
|
end
|
|
174
|
+
group.run(double('reporter').as_null_object)
|
|
175
|
+
group.examples
|
|
139
176
|
end
|
|
177
|
+
end
|
|
140
178
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
179
|
+
it "names the example" do
|
|
180
|
+
formatter.dump_profile
|
|
181
|
+
output.string.should =~ /group example/m
|
|
182
|
+
end
|
|
145
183
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
184
|
+
it "prints the time" do
|
|
185
|
+
formatter.dump_profile
|
|
186
|
+
output.string.should =~ /0(\.\d+)? seconds/
|
|
187
|
+
end
|
|
150
188
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
189
|
+
it "prints the path" do
|
|
190
|
+
formatter.dump_profile
|
|
191
|
+
filename = __FILE__.split(File::SEPARATOR).last
|
|
154
192
|
|
|
155
|
-
|
|
156
|
-
end
|
|
193
|
+
output.string.should =~ /#{filename}\:#{__LINE__ - 21}/
|
|
157
194
|
end
|
|
158
195
|
end
|
|
159
196
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'rspec/core/formatters/documentation_formatter'
|
|
2
3
|
|
|
3
4
|
module RSpec::Core::Formatters
|
|
4
5
|
describe DocumentationFormatter do
|
|
@@ -7,11 +8,11 @@ module RSpec::Core::Formatters
|
|
|
7
8
|
examples = [
|
|
8
9
|
double("example 1",
|
|
9
10
|
:description => "first example",
|
|
10
|
-
:execution_result => {:status => 'failed', :
|
|
11
|
+
:execution_result => {:status => 'failed', :exception => Exception.new }
|
|
11
12
|
),
|
|
12
13
|
double("example 2",
|
|
13
14
|
:description => "second example",
|
|
14
|
-
:execution_result => {:status => 'failed', :
|
|
15
|
+
:execution_result => {:status => 'failed', :exception => Exception.new }
|
|
15
16
|
)
|
|
16
17
|
]
|
|
17
18
|
|
|
@@ -46,9 +47,9 @@ module RSpec::Core::Formatters
|
|
|
46
47
|
context2.example("nested example 2.1"){}
|
|
47
48
|
context2.example("nested example 2.2"){}
|
|
48
49
|
|
|
49
|
-
group.
|
|
50
|
+
group.run(RSpec::Core::Reporter.new(formatter))
|
|
50
51
|
|
|
51
|
-
output.string.should eql
|
|
52
|
+
output.string.should eql("
|
|
52
53
|
root
|
|
53
54
|
context 1
|
|
54
55
|
nested example 1.1
|
|
@@ -59,7 +60,7 @@ root
|
|
|
59
60
|
context 2
|
|
60
61
|
nested example 2.1
|
|
61
62
|
nested example 2.2
|
|
62
|
-
"
|
|
63
|
+
")
|
|
63
64
|
end
|
|
64
65
|
end
|
|
65
66
|
end
|