rspec 1.1.3 → 1.1.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/CHANGES +35 -0
- data/MIT-LICENSE +1 -1
- data/README +9 -44
- data/Rakefile +34 -51
- data/TODO +0 -1
- data/UPGRADE +0 -24
- data/bin/spec +0 -0
- data/bin/spec_translator +0 -0
- data/examples/pure/behave_as_example.rb +0 -0
- data/examples/pure/partial_mock_example.rb +1 -0
- data/examples/stories/calculator.rb +1 -1
- data/lib/autotest/rspec.rb +7 -9
- data/lib/spec/example.rb +1 -1
- data/lib/spec/example/configuration.rb +30 -16
- data/lib/spec/example/example_group.rb +2 -1
- data/lib/spec/example/example_group_factory.rb +23 -21
- data/lib/spec/example/example_group_methods.rb +18 -5
- data/lib/spec/example/example_matcher.rb +0 -0
- data/lib/spec/example/example_methods.rb +6 -0
- data/lib/spec/example/module_inclusion_warnings.rb +37 -0
- data/lib/spec/expectations/differs/default.rb +1 -1
- data/lib/spec/expectations/extensions/object.rb +4 -12
- data/lib/spec/expectations/handler.rb +8 -0
- data/lib/spec/extensions.rb +1 -0
- data/lib/spec/extensions/metaclass.rb +7 -0
- data/lib/spec/extensions/object.rb +0 -4
- data/lib/spec/matchers/change.rb +1 -1
- data/lib/spec/matchers/has.rb +1 -11
- data/lib/spec/matchers/operator_matcher.rb +0 -0
- data/lib/spec/matchers/raise_error.rb +53 -30
- data/lib/spec/mocks.rb +1 -1
- data/lib/spec/mocks/argument_constraint_matchers.rb +5 -1
- data/lib/spec/mocks/argument_expectation.rb +26 -0
- data/lib/spec/mocks/extensions.rb +1 -0
- data/lib/spec/mocks/framework.rb +15 -0
- data/lib/spec/mocks/message_expectation.rb +29 -5
- data/lib/spec/mocks/mock.rb +9 -7
- data/lib/spec/mocks/proxy.rb +26 -12
- data/lib/spec/rake/spectask.rb +5 -5
- data/lib/spec/runner/backtrace_tweaker.rb +1 -1
- data/lib/spec/runner/formatter/base_formatter.rb +2 -3
- data/lib/spec/runner/formatter/base_text_formatter.rb +2 -2
- data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +4 -8
- data/lib/spec/runner/formatter/html_formatter.rb +18 -14
- data/lib/spec/runner/formatter/nested_text_formatter.rb +65 -0
- data/lib/spec/runner/formatter/profile_formatter.rb +4 -0
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +5 -1
- data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -1
- data/lib/spec/runner/formatter/story/plain_text_formatter.rb +18 -7
- data/lib/spec/runner/option_parser.rb +17 -15
- data/lib/spec/runner/options.rb +37 -14
- data/lib/spec/runner/reporter.rb +15 -11
- data/lib/spec/story/extensions/regexp.rb +2 -2
- data/lib/spec/story/extensions/string.rb +2 -2
- data/lib/spec/story/runner.rb +9 -5
- data/lib/spec/story/runner/plain_text_story_runner.rb +2 -2
- data/lib/spec/story/runner/scenario_runner.rb +8 -0
- data/lib/spec/story/runner/story_mediator.rb +1 -1
- data/lib/spec/story/runner/story_runner.rb +3 -1
- data/lib/spec/story/step.rb +4 -4
- data/lib/spec/story/story.rb +8 -11
- data/lib/spec/story/world.rb +0 -1
- data/lib/spec/version.rb +2 -2
- data/plugins/mock_frameworks/rspec.rb +2 -0
- data/spec/autotest/rspec_spec.rb +12 -10
- data/spec/spec/example/configuration_spec.rb +0 -0
- data/spec/spec/example/example_group/described_module_spec.rb +20 -0
- data/spec/spec/example/example_group/warning_messages_spec.rb +76 -0
- data/spec/spec/example/example_group_factory_spec.rb +117 -102
- data/spec/spec/example/example_group_methods_spec.rb +51 -17
- data/spec/spec/example/example_group_spec.rb +13 -1
- data/spec/spec/example/example_methods_spec.rb +28 -6
- data/spec/spec/example/nested_example_group_spec.rb +12 -0
- data/spec/spec/example/predicate_matcher_spec.rb +0 -0
- data/spec/spec/expectations/differs/default_spec.rb +27 -9
- data/spec/spec/matchers/be_spec.rb +24 -0
- data/spec/spec/matchers/has_spec.rb +16 -0
- data/spec/spec/matchers/raise_error_spec.rb +124 -0
- data/spec/spec/mocks/{bug_report_10263.rb → bug_report_10263_spec.rb} +0 -0
- data/spec/spec/mocks/bug_report_11545_spec.rb +2 -0
- data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +8 -0
- data/spec/spec/mocks/hash_including_matcher_spec.rb +32 -0
- data/spec/spec/mocks/mock_spec.rb +56 -37
- data/spec/spec/mocks/partial_mock_spec.rb +41 -5
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +6 -0
- data/spec/spec/runner/execution_context_spec.rb +7 -1
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +3 -2
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +30 -25
- data/spec/spec/runner/formatter/html_formatter_spec.rb +0 -3
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +333 -0
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +12 -2
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +110 -78
- data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +105 -1
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +33 -28
- data/spec/spec/runner/option_parser_spec.rb +65 -49
- data/spec/spec/runner/options_spec.rb +103 -17
- data/spec/spec/runner/reporter_spec.rb +10 -7
- data/spec/spec/runner/spec_drb.opts +1 -0
- data/spec/spec/runner/spec_parser_spec.rb +10 -4
- data/spec/spec/story/runner/plain_text_story_runner_spec.rb +14 -13
- data/spec/spec/story/runner/scenario_runner_spec.rb +124 -52
- data/spec/spec/story/runner/story_mediator_spec.rb +2 -2
- data/spec/spec/story/runner/story_runner_spec.rb +40 -2
- data/spec/spec/story/runner_spec.rb +59 -72
- data/spec/spec/story/step_spec.rb +20 -1
- data/spec/spec/story/story_spec.rb +2 -2
- data/stories/all.rb +1 -1
- data/stories/example_groups/stories.rb +4 -3
- data/stories/mock_framework_integration/stories.rb +7 -0
- data/stories/mock_framework_integration/use_flexmock.story +9 -0
- data/stories/resources/spec/spec_with_flexmock.rb +18 -0
- metadata +21 -18
- data/pre_commit/lib/pre_commit.rb +0 -4
- data/pre_commit/lib/pre_commit/core.rb +0 -50
- data/pre_commit/lib/pre_commit/pre_commit.rb +0 -54
- data/pre_commit/lib/pre_commit/rspec.rb +0 -111
- data/pre_commit/lib/pre_commit/rspec_on_rails.rb +0 -313
- data/pre_commit/spec/pre_commit/pre_commit_spec.rb +0 -15
- data/pre_commit/spec/pre_commit/rspec_on_rails_spec.rb +0 -36
- data/pre_commit/spec/spec_helper.rb +0 -3
- data/pre_commit/spec/spec_suite.rb +0 -11
|
@@ -17,9 +17,6 @@ module Spec
|
|
|
17
17
|
expected_file = File.dirname(__FILE__) + "/html_formatted-#{::VERSION}#{suffix}.html"
|
|
18
18
|
raise "There is no HTML file with expected content for this platform: #{expected_file}" unless File.file?(expected_file)
|
|
19
19
|
expected_html = File.read(expected_file)
|
|
20
|
-
unless jruby?
|
|
21
|
-
raise "There should be no absolute paths in html_formatted.html!!" if (expected_html =~ /\/Users/n || expected_html =~ /\/home/n)
|
|
22
|
-
end
|
|
23
20
|
|
|
24
21
|
Dir.chdir(root) do
|
|
25
22
|
args = ['failing_examples/mocking_example.rb', 'failing_examples/diffing_spec.rb', 'examples/pure/stubbing_example.rb', 'examples/pure/pending_example.rb', '--format', 'html', opt]
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper.rb'
|
|
2
|
+
require 'spec/runner/formatter/nested_text_formatter'
|
|
3
|
+
|
|
4
|
+
module Spec
|
|
5
|
+
module Runner
|
|
6
|
+
module Formatter
|
|
7
|
+
describe NestedTextFormatter do
|
|
8
|
+
it_should_behave_like "sandboxed rspec_options"
|
|
9
|
+
attr_reader :io, :options, :formatter, :example_group
|
|
10
|
+
before(:each) do
|
|
11
|
+
@io = StringIO.new
|
|
12
|
+
options.stub!(:dry_run).and_return(false)
|
|
13
|
+
options.stub!(:colour).and_return(false)
|
|
14
|
+
@formatter = NestedTextFormatter.new(options, io)
|
|
15
|
+
@example_group = ::Spec::Example::ExampleGroup.describe("ExampleGroup") do
|
|
16
|
+
specify "example" do
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "where ExampleGroup has no superclasss with a description" do
|
|
22
|
+
before do
|
|
23
|
+
add_example_group
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def add_example_group
|
|
27
|
+
formatter.add_example_group(example_group)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "#dump_summary" do
|
|
31
|
+
it "should produce standard summary without pending when pending has a 0 count" do
|
|
32
|
+
formatter.dump_summary(3, 2, 1, 0)
|
|
33
|
+
expected_output = <<-OUT
|
|
34
|
+
ExampleGroup
|
|
35
|
+
|
|
36
|
+
Finished in 3 seconds
|
|
37
|
+
|
|
38
|
+
2 examples, 1 failure
|
|
39
|
+
OUT
|
|
40
|
+
|
|
41
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should produce standard summary" do
|
|
45
|
+
formatter.dump_summary(3, 2, 1, 4)
|
|
46
|
+
expected_output = <<-OUT
|
|
47
|
+
ExampleGroup
|
|
48
|
+
|
|
49
|
+
Finished in 3 seconds
|
|
50
|
+
|
|
51
|
+
2 examples, 1 failure, 4 pending
|
|
52
|
+
OUT
|
|
53
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe "#add_example_group" do
|
|
58
|
+
describe "when ExampleGroup has description_args" do
|
|
59
|
+
before do
|
|
60
|
+
example_group.description_args.should_not be_nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe "when ExampleGroup has no parents with description args" do
|
|
64
|
+
before do
|
|
65
|
+
example_group.superclass.description_args.should be_nil
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should push ExampleGroup name" do
|
|
69
|
+
io.string.should eql("ExampleGroup\n")
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe "when ExampleGroup has one parent with description args" do
|
|
74
|
+
attr_reader :child_example_group
|
|
75
|
+
def add_example_group
|
|
76
|
+
example_group.description_args.should_not be_nil
|
|
77
|
+
@child_example_group = Class.new(example_group).describe("Child ExampleGroup")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe "and parent ExampleGroups have not been printed" do
|
|
81
|
+
before do
|
|
82
|
+
formatter.add_example_group(child_example_group)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should push ExampleGroup name with two spaces of indentation" do
|
|
86
|
+
expected_output = <<-OUT
|
|
87
|
+
ExampleGroup
|
|
88
|
+
Child ExampleGroup
|
|
89
|
+
OUT
|
|
90
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe "and parent ExampleGroups have been printed" do
|
|
95
|
+
before do
|
|
96
|
+
formatter.add_example_group(example_group)
|
|
97
|
+
io.string = ""
|
|
98
|
+
formatter.add_example_group(child_example_group)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should print only the indented ExampleGroup" do
|
|
102
|
+
expected_output = <<-OUT
|
|
103
|
+
Child ExampleGroup
|
|
104
|
+
OUT
|
|
105
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe "when ExampleGroup has two parents with description args" do
|
|
111
|
+
attr_reader :child_example_group, :grand_child_example_group
|
|
112
|
+
def add_example_group
|
|
113
|
+
example_group.description_args.should_not be_nil
|
|
114
|
+
@child_example_group = Class.new(example_group).describe("Child ExampleGroup")
|
|
115
|
+
@grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup")
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe "and parent ExampleGroups have not been printed" do
|
|
119
|
+
before do
|
|
120
|
+
formatter.add_example_group(grand_child_example_group)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it "should print the entire nested ExampleGroup heirarchy" do
|
|
124
|
+
expected_output = <<-OUT
|
|
125
|
+
ExampleGroup
|
|
126
|
+
Child ExampleGroup
|
|
127
|
+
GrandChild ExampleGroup
|
|
128
|
+
OUT
|
|
129
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe "and parent ExampleGroups have been printed" do
|
|
134
|
+
before do
|
|
135
|
+
formatter.add_example_group(child_example_group)
|
|
136
|
+
io.string = ""
|
|
137
|
+
formatter.add_example_group(grand_child_example_group)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "should print only the indented ExampleGroup" do
|
|
141
|
+
expected_output = <<-OUT
|
|
142
|
+
GrandChild ExampleGroup
|
|
143
|
+
OUT
|
|
144
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe "when ExampleGroup description_args is nil" do
|
|
151
|
+
attr_reader :child_example_group
|
|
152
|
+
|
|
153
|
+
describe "and parent ExampleGroups have not been printed" do
|
|
154
|
+
def add_example_group
|
|
155
|
+
@child_example_group = Class.new(example_group)
|
|
156
|
+
child_example_group.description_args.should be_nil
|
|
157
|
+
formatter.add_example_group(child_example_group)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "should render only the parent ExampleGroup" do
|
|
161
|
+
expected_output = <<-OUT
|
|
162
|
+
ExampleGroup
|
|
163
|
+
OUT
|
|
164
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
describe "and parent ExampleGroups have been printed" do
|
|
169
|
+
def add_example_group
|
|
170
|
+
@child_example_group = Class.new(example_group)
|
|
171
|
+
child_example_group.description_args.should be_nil
|
|
172
|
+
formatter.add_example_group(example_group)
|
|
173
|
+
io.string = ""
|
|
174
|
+
formatter.add_example_group(child_example_group)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
it "should not render anything" do
|
|
178
|
+
io.string.should == ""
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
describe "when ExampleGroup description_args is empty" do
|
|
184
|
+
def add_example_group
|
|
185
|
+
example_group.set_description
|
|
186
|
+
example_group.description_args.should be_empty
|
|
187
|
+
super
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it "should not render anything" do
|
|
191
|
+
io.string.should == ""
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
describe "#example_failed" do
|
|
197
|
+
describe "where ExampleGroup has no superclasss with a description" do
|
|
198
|
+
describe "when having an error" do
|
|
199
|
+
it "should push failing spec name and failure number" do
|
|
200
|
+
formatter.example_failed(
|
|
201
|
+
example_group.it("spec"),
|
|
202
|
+
98,
|
|
203
|
+
Reporter::Failure.new("c s", RuntimeError.new)
|
|
204
|
+
)
|
|
205
|
+
expected_output = <<-OUT
|
|
206
|
+
ExampleGroup
|
|
207
|
+
spec (ERROR - 98)
|
|
208
|
+
OUT
|
|
209
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
describe "when having an expectation failure" do
|
|
214
|
+
it "should push failing spec name and failure number" do
|
|
215
|
+
formatter.example_failed(
|
|
216
|
+
example_group.it("spec"),
|
|
217
|
+
98,
|
|
218
|
+
Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
|
|
219
|
+
)
|
|
220
|
+
expected_output = <<-OUT
|
|
221
|
+
ExampleGroup
|
|
222
|
+
spec (FAILED - 98)
|
|
223
|
+
OUT
|
|
224
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
describe "where ExampleGroup has two superclasses with a description" do
|
|
230
|
+
attr_reader :child_example_group, :grand_child_example_group
|
|
231
|
+
|
|
232
|
+
def add_example_group
|
|
233
|
+
@child_example_group = Class.new(example_group).describe("Child ExampleGroup")
|
|
234
|
+
@grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup")
|
|
235
|
+
formatter.add_example_group(grand_child_example_group)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
describe "when having an error" do
|
|
239
|
+
it "should push failing spec name and failure number" do
|
|
240
|
+
formatter.example_failed(
|
|
241
|
+
grand_child_example_group.it("spec"),
|
|
242
|
+
98,
|
|
243
|
+
Reporter::Failure.new("c s", RuntimeError.new)
|
|
244
|
+
)
|
|
245
|
+
expected_output = <<-OUT
|
|
246
|
+
ExampleGroup
|
|
247
|
+
Child ExampleGroup
|
|
248
|
+
GrandChild ExampleGroup
|
|
249
|
+
spec (ERROR - 98)
|
|
250
|
+
OUT
|
|
251
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
describe "when having an expectation" do
|
|
256
|
+
it "should push failing spec name and failure number" do
|
|
257
|
+
formatter.example_failed(
|
|
258
|
+
grand_child_example_group.it("spec"),
|
|
259
|
+
98,
|
|
260
|
+
Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
|
|
261
|
+
)
|
|
262
|
+
expected_output = <<-OUT
|
|
263
|
+
ExampleGroup
|
|
264
|
+
Child ExampleGroup
|
|
265
|
+
GrandChild ExampleGroup
|
|
266
|
+
spec (FAILED - 98)
|
|
267
|
+
OUT
|
|
268
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
describe "#start" do
|
|
275
|
+
it "should push nothing on start" do
|
|
276
|
+
formatter.start(5)
|
|
277
|
+
expected_output = <<-OUT
|
|
278
|
+
ExampleGroup
|
|
279
|
+
OUT
|
|
280
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
describe "#start_dump" do
|
|
285
|
+
it "should push nothing on start dump" do
|
|
286
|
+
formatter.start_dump
|
|
287
|
+
expected_output = <<-OUT
|
|
288
|
+
ExampleGroup
|
|
289
|
+
OUT
|
|
290
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
describe "#example_passed" do
|
|
295
|
+
it "should push passing spec name" do
|
|
296
|
+
formatter.example_passed(example_group.it("spec"))
|
|
297
|
+
expected_output = <<-OUT
|
|
298
|
+
ExampleGroup
|
|
299
|
+
spec
|
|
300
|
+
OUT
|
|
301
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
describe "#example_pending" do
|
|
306
|
+
it "should push pending example name and message" do
|
|
307
|
+
formatter.example_pending(example_group.examples.first, 'reason')
|
|
308
|
+
expected_output = <<-OUT
|
|
309
|
+
ExampleGroup
|
|
310
|
+
example (PENDING: reason)
|
|
311
|
+
OUT
|
|
312
|
+
io.string.should == expected_output.gsub(/^ /, '')
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
it "should dump pending" do
|
|
316
|
+
formatter.example_pending(example_group.examples.first, 'reason')
|
|
317
|
+
io.rewind
|
|
318
|
+
formatter.dump_pending
|
|
319
|
+
io.string.should =~ /Pending\:\nExampleGroup example \(reason\)\n/
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
def have_single_level_example_group_output(expected_output)
|
|
324
|
+
expected = "ExampleGroup\n #{expected_output}"
|
|
325
|
+
::Spec::Matchers::SimpleMatcher.new(expected) do |actual|
|
|
326
|
+
actual == expected
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
end
|
|
@@ -24,7 +24,12 @@ module Spec
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "should produce standard summary" do
|
|
27
|
-
|
|
27
|
+
example_group = ExampleGroup.describe("example_group") do
|
|
28
|
+
specify "example" do
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
example = example_group.examples.first
|
|
32
|
+
@formatter.example_pending(example, "message")
|
|
28
33
|
@io.rewind
|
|
29
34
|
@formatter.dump_summary(3, 2, 1, 1)
|
|
30
35
|
@io.string.should eql(%Q|
|
|
@@ -84,7 +89,12 @@ EOE
|
|
|
84
89
|
end
|
|
85
90
|
|
|
86
91
|
it "should dump pending" do
|
|
87
|
-
|
|
92
|
+
example_group = ExampleGroup.describe("example_group") do
|
|
93
|
+
specify "example" do
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
example = example_group.examples.first
|
|
97
|
+
@formatter.example_pending(example, "message")
|
|
88
98
|
@formatter.dump_pending
|
|
89
99
|
@io.string.should =~ /Pending\:\nexample_group example \(message\)\n/
|
|
90
100
|
end
|
|
@@ -50,10 +50,10 @@ module Spec
|
|
|
50
50
|
# Spec::Runner::CommandLine.run(
|
|
51
51
|
# ::Spec::Runner::OptionParser.parse(args, err, out)
|
|
52
52
|
# )
|
|
53
|
-
#
|
|
53
|
+
#
|
|
54
54
|
# seconds = /\d+\.\d+ seconds/
|
|
55
55
|
# html = out.string.gsub seconds, 'x seconds'
|
|
56
|
-
#
|
|
56
|
+
#
|
|
57
57
|
# File.open(expected_file, 'w') {|io| io.write(html)}
|
|
58
58
|
# end
|
|
59
59
|
# end
|
|
@@ -12,71 +12,137 @@ module Spec
|
|
|
12
12
|
options.stub!(:dry_run).and_return(false)
|
|
13
13
|
options.stub!(:colour).and_return(false)
|
|
14
14
|
@formatter = SpecdocFormatter.new(options, io)
|
|
15
|
-
@example_group =
|
|
15
|
+
@example_group = ::Spec::Example::ExampleGroup.describe("ExampleGroup") do
|
|
16
|
+
specify "example" do
|
|
17
|
+
end
|
|
18
|
+
end
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
describe "where ExampleGroup has no superclasss with a description" do
|
|
19
22
|
before do
|
|
20
|
-
|
|
23
|
+
add_example_group
|
|
21
24
|
end
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
formatter.
|
|
25
|
-
io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure\n")
|
|
26
|
+
def add_example_group
|
|
27
|
+
formatter.add_example_group(example_group)
|
|
26
28
|
end
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
describe "#dump_summary" do
|
|
31
|
+
it "should produce standard summary without pending when pending has a 0 count" do
|
|
32
|
+
formatter.dump_summary(3, 2, 1, 0)
|
|
33
|
+
io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure\n")
|
|
34
|
+
end
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
it "should produce standard summary" do
|
|
37
|
+
formatter.dump_summary(3, 2, 1, 4)
|
|
38
|
+
io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure, 4 pending\n")
|
|
39
|
+
end
|
|
35
40
|
end
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Reporter::Failure.new("c s", RuntimeError.new)
|
|
42
|
-
)
|
|
43
|
-
io.string.should have_example_group_output("- spec (ERROR - 98)\n")
|
|
42
|
+
describe "#add_example_group" do
|
|
43
|
+
it "should push ExampleGroup name" do
|
|
44
|
+
io.string.should eql("\nExampleGroup\n")
|
|
45
|
+
end
|
|
44
46
|
end
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
describe "#example_failed" do
|
|
49
|
+
describe "where ExampleGroup has no superclasss with a description" do
|
|
50
|
+
describe "when having an error" do
|
|
51
|
+
it "should push failing spec name and failure number" do
|
|
52
|
+
formatter.example_failed(
|
|
53
|
+
example_group.it("spec"),
|
|
54
|
+
98,
|
|
55
|
+
Reporter::Failure.new("c s", RuntimeError.new)
|
|
56
|
+
)
|
|
57
|
+
io.string.should have_example_group_output("- spec (ERROR - 98)\n")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe "when having an expectation failure" do
|
|
62
|
+
it "should push failing spec name and failure number" do
|
|
63
|
+
formatter.example_failed(
|
|
64
|
+
example_group.it("spec"),
|
|
65
|
+
98,
|
|
66
|
+
Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
|
|
67
|
+
)
|
|
68
|
+
io.string.should have_example_group_output("- spec (FAILED - 98)\n")
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
73
|
+
describe "where ExampleGroup has two superclasses with a description" do
|
|
74
|
+
attr_reader :child_example_group, :grand_child_example_group
|
|
75
|
+
|
|
76
|
+
def add_example_group
|
|
77
|
+
@child_example_group = Class.new(example_group).describe("Child ExampleGroup")
|
|
78
|
+
@grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup")
|
|
79
|
+
formatter.add_example_group(grand_child_example_group)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe "when having an error" do
|
|
83
|
+
it "should push failing spec name and failure number" do
|
|
84
|
+
formatter.example_failed(
|
|
85
|
+
example_group.it("spec"),
|
|
86
|
+
98,
|
|
87
|
+
Reporter::Failure.new("c s", RuntimeError.new)
|
|
88
|
+
)
|
|
89
|
+
io.string.should have_nested_example_group_output("- spec (ERROR - 98)\n")
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
describe "when having an expectation" do
|
|
94
|
+
it "should push failing spec name and failure number" do
|
|
95
|
+
formatter.example_failed(
|
|
96
|
+
example_group.it("spec"),
|
|
97
|
+
98,
|
|
98
|
+
Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
|
|
99
|
+
)
|
|
100
|
+
io.string.should have_nested_example_group_output("- spec (FAILED - 98)\n")
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def have_nested_example_group_output(expected_output)
|
|
105
|
+
expected_full_output = "\nExampleGroup Child ExampleGroup GrandChild ExampleGroup\n#{expected_output}"
|
|
106
|
+
::Spec::Matchers::SimpleMatcher.new(expected_full_output) do |actual|
|
|
107
|
+
actual == expected_full_output
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
58
111
|
end
|
|
59
112
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
113
|
+
describe "#start" do
|
|
114
|
+
it "should push nothing on start" do
|
|
115
|
+
formatter.start(5)
|
|
116
|
+
io.string.should have_example_group_output("")
|
|
117
|
+
end
|
|
63
118
|
end
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
119
|
+
|
|
120
|
+
describe "#start_dump" do
|
|
121
|
+
it "should push nothing on start dump" do
|
|
122
|
+
formatter.start_dump
|
|
123
|
+
io.string.should have_example_group_output("")
|
|
124
|
+
end
|
|
68
125
|
end
|
|
69
126
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
127
|
+
describe "#example_passed" do
|
|
128
|
+
it "should push passing spec name" do
|
|
129
|
+
formatter.example_passed(example_group.it("spec"))
|
|
130
|
+
io.string.should have_example_group_output("- spec\n")
|
|
131
|
+
end
|
|
73
132
|
end
|
|
74
133
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
134
|
+
describe "#example_pending" do
|
|
135
|
+
it "should push pending example name and message" do
|
|
136
|
+
formatter.example_pending(example_group.examples.first, 'reason')
|
|
137
|
+
io.string.should have_example_group_output("- example (PENDING: reason)\n")
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "should dump pending" do
|
|
141
|
+
formatter.example_pending(example_group.examples.first, 'reason')
|
|
142
|
+
io.rewind
|
|
143
|
+
formatter.dump_pending
|
|
144
|
+
io.string.should =~ /Pending\:\nExampleGroup example \(reason\)\n/
|
|
145
|
+
end
|
|
80
146
|
end
|
|
81
147
|
|
|
82
148
|
def have_example_group_output(expected_output)
|
|
@@ -86,40 +152,6 @@ module Spec
|
|
|
86
152
|
end
|
|
87
153
|
end
|
|
88
154
|
end
|
|
89
|
-
|
|
90
|
-
describe "where ExampleGroup has two superclasses with a description" do
|
|
91
|
-
attr_reader :child_example_group, :grand_child_example_group
|
|
92
|
-
before do
|
|
93
|
-
@child_example_group = Class.new(example_group).describe("Child ExampleGroup")
|
|
94
|
-
@grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup")
|
|
95
|
-
formatter.add_example_group(grand_child_example_group)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
specify "when having an error, should push failing spec name and failure number" do
|
|
99
|
-
formatter.example_failed(
|
|
100
|
-
example_group.it("spec"),
|
|
101
|
-
98,
|
|
102
|
-
Reporter::Failure.new("c s", RuntimeError.new)
|
|
103
|
-
)
|
|
104
|
-
io.string.should have_nested_example_group_output("- spec (ERROR - 98)\n")
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
specify "when having an expectation failure, should push failing spec name and failure number" do
|
|
108
|
-
formatter.example_failed(
|
|
109
|
-
example_group.it("spec"),
|
|
110
|
-
98,
|
|
111
|
-
Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
|
|
112
|
-
)
|
|
113
|
-
io.string.should have_nested_example_group_output("- spec (FAILED - 98)\n")
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def have_nested_example_group_output(expected_output)
|
|
117
|
-
expected_full_output = "\nExampleGroup Child ExampleGroup GrandChild ExampleGroup\n#{expected_output}"
|
|
118
|
-
::Spec::Matchers::SimpleMatcher.new(expected_full_output) do |actual|
|
|
119
|
-
actual == expected_full_output
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
155
|
end
|
|
124
156
|
end
|
|
125
157
|
end
|