rspec-core 2.0.0.beta.22 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.rspec +0 -1
- data/.travis.yml +7 -0
- data/Gemfile +46 -20
- data/Guardfile +5 -0
- data/License.txt +2 -1
- data/{README.markdown → README.md} +23 -5
- data/Rakefile +58 -31
- 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/Changelog.md +269 -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 +33 -4
- 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 +279 -89
- data/lib/rspec/core/configuration_options.rb +46 -35
- data/lib/rspec/core/deprecation.rb +1 -1
- data/lib/rspec/core/drb_command_line.rb +5 -11
- 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 +11 -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/object.rb +1 -3
- data/lib/rspec/core/formatters/base_formatter.rb +22 -11
- data/lib/rspec/core/formatters/base_text_formatter.rb +46 -30
- 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 +55 -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 +48 -5
- data/lib/rspec/core/pending.rb +22 -4
- data/lib/rspec/core/rake_task.rb +64 -28
- data/lib/rspec/core/reporter.rb +3 -2
- 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 +83 -25
- data/lib/rspec/core.rb +40 -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 +184 -148
- data/spec/rspec/core/configuration_spec.rb +406 -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 +39 -5
- 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 +199 -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 +199 -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 -23
- 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 +99 -168
- 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/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,4 +1,5 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'rspec/core/formatters/base_text_formatter'
|
|
2
3
|
|
|
3
4
|
module RSpec::Core::Formatters
|
|
4
5
|
|
|
@@ -32,7 +33,7 @@ module RSpec::Core::Formatters
|
|
|
32
33
|
before { RSpec.configuration.stub(:color_enabled?) { false } }
|
|
33
34
|
|
|
34
35
|
def run_all_and_dump_failures
|
|
35
|
-
group.
|
|
36
|
+
group.run(formatter)
|
|
36
37
|
formatter.dump_failures
|
|
37
38
|
end
|
|
38
39
|
|
|
@@ -45,6 +46,39 @@ module RSpec::Core::Formatters
|
|
|
45
46
|
output.string.should =~ /(\s+)expected \"that\"\n\1 got \"this\"/m
|
|
46
47
|
end
|
|
47
48
|
|
|
49
|
+
context "with an exception without a message" do
|
|
50
|
+
it "does not throw NoMethodError" do
|
|
51
|
+
exception_without_message = Exception.new()
|
|
52
|
+
exception_without_message.stub(:message) { nil }
|
|
53
|
+
group.example("example name") { raise exception_without_message }
|
|
54
|
+
expect { run_all_and_dump_failures }.not_to raise_error(NoMethodError)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context "with an exception class other than RSpec" do
|
|
59
|
+
it "does not show the error class" do
|
|
60
|
+
group.example("example name") { raise NameError.new('foo') }
|
|
61
|
+
run_all_and_dump_failures
|
|
62
|
+
output.string.should =~ /NameError/m
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context "with a failed expectation (rspec-expectations)" do
|
|
67
|
+
it "does not show the error class" do
|
|
68
|
+
group.example("example name") { "this".should eq("that") }
|
|
69
|
+
run_all_and_dump_failures
|
|
70
|
+
output.string.should_not =~ /RSpec/m
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
context "with a failed message expectation (rspec-mocks)" do
|
|
75
|
+
it "does not show the error class" do
|
|
76
|
+
group.example("example name") { "this".should_receive("that") }
|
|
77
|
+
run_all_and_dump_failures
|
|
78
|
+
output.string.should_not =~ /RSpec/m
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
48
82
|
context 'for #share_examples_for' do
|
|
49
83
|
it 'outputs the name and location' do
|
|
50
84
|
|
|
@@ -133,7 +167,7 @@ module RSpec::Core::Formatters
|
|
|
133
167
|
group = RSpec::Core::ExampleGroup.describe("group") do
|
|
134
168
|
example("example")
|
|
135
169
|
end
|
|
136
|
-
group.
|
|
170
|
+
group.run(double('reporter').as_null_object)
|
|
137
171
|
group.examples
|
|
138
172
|
end
|
|
139
173
|
end
|
|
@@ -145,14 +179,14 @@ module RSpec::Core::Formatters
|
|
|
145
179
|
|
|
146
180
|
it "prints the time" do
|
|
147
181
|
formatter.dump_profile
|
|
148
|
-
output.string.should =~ /0\.\d+ seconds/
|
|
182
|
+
output.string.should =~ /0(\.\d+)? seconds/
|
|
149
183
|
end
|
|
150
184
|
|
|
151
185
|
it "prints the path" do
|
|
152
186
|
formatter.dump_profile
|
|
153
187
|
filename = __FILE__.split(File::SEPARATOR).last
|
|
154
188
|
|
|
155
|
-
output.string.should =~ /#{filename}
|
|
189
|
+
output.string.should =~ /#{filename}\:#{__LINE__ - 21}/
|
|
156
190
|
end
|
|
157
191
|
end
|
|
158
192
|
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
|