rspec 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +57 -32
- data/EXAMPLES.rd +0 -0
- data/Rakefile +22 -21
- data/bin/spec +9 -11
- data/doc/README +1 -3
- data/doc/plugin/syntax.rb +27 -5
- data/doc/src/core_team.page +22 -0
- data/doc/src/default.css +11 -11
- data/doc/src/default.template +0 -1
- data/doc/src/documentation/index.page +183 -8
- data/doc/src/documentation/meta.info +7 -7
- data/doc/src/documentation/mocks.page +168 -109
- data/doc/src/documentation/underscores.page +20 -0
- data/doc/src/examples.page +2 -1
- data/doc/src/images/David_and_Aslak.jpg +0 -0
- data/doc/src/images/Whats_That_Dude.jpg +0 -0
- data/doc/src/index.page +70 -3
- data/doc/src/meta.info +18 -11
- data/doc/src/tools/index.page +40 -134
- data/doc/src/tools/meta.info +9 -3
- data/doc/src/tools/rails.page +3 -1
- data/doc/src/tools/rake.page +20 -3
- data/doc/src/tools/rcov.page +19 -0
- data/doc/src/tools/spec.page +99 -0
- data/doc/src/tools/test2rspec.page +2 -4
- data/doc/src/tutorials/index.page +52 -0
- data/doc/src/tutorials/meta.info +31 -0
- data/doc/src/tutorials/notes.txt +252 -0
- data/doc/src/tutorials/stack.rb +11 -0
- data/doc/src/tutorials/stack_01.page +224 -0
- data/doc/src/tutorials/stack_02.page +180 -0
- data/doc/src/tutorials/stack_03.page +291 -0
- data/doc/src/tutorials/stack_04.page +203 -0
- data/doc/src/tutorials/stack_04.page.orig +123 -0
- data/doc/src/tutorials/stack_05.page +90 -0
- data/doc/src/tutorials/stack_05.page.orig +124 -0
- data/doc/src/tutorials/stack_06.page +359 -0
- data/doc/src/tutorials/stack_06.page.orig +359 -0
- data/doc/src/tutorials/stack_spec.rb +41 -0
- data/examples/airport_spec.rb +4 -4
- data/examples/{spec_framework_spec.rb → bdd_framework_spec.rb} +6 -7
- data/examples/mocking_spec.rb +0 -5
- data/examples/stack_spec.rb +6 -7
- data/examples/sugar_spec.rb +14 -0
- data/lib/spec/api.rb +5 -2
- data/lib/spec/api/helper/should_base.rb +17 -22
- data/lib/spec/api/helper/should_helper.rb +4 -3
- data/lib/spec/api/helper/should_negator.rb +3 -2
- data/lib/spec/api/mocks/argument_expectation.rb +104 -0
- data/lib/spec/api/{mock.rb → mocks/message_expectation.rb} +47 -96
- data/lib/spec/api/mocks/mock.rb +63 -0
- data/lib/spec/api/mocks/order_group.rb +21 -0
- data/lib/spec/api/sugar.rb +47 -0
- data/lib/spec/rake/rcov_verify.rb +45 -0
- data/lib/spec/rake/spectask.rb +41 -56
- data/lib/spec/runner.rb +4 -1
- data/lib/spec/runner/backtrace_tweaker.rb +24 -3
- data/lib/spec/runner/base_text_formatter.rb +28 -0
- data/lib/spec/runner/context.rb +21 -18
- data/lib/spec/runner/context_runner.rb +20 -31
- data/lib/spec/runner/execution_context.rb +3 -3
- data/lib/spec/runner/kernel_ext.rb +10 -1
- data/lib/spec/runner/option_parser.rb +32 -14
- data/lib/spec/runner/progress_bar_formatter.rb +21 -0
- data/lib/spec/runner/rdoc_formatter.rb +15 -5
- data/lib/spec/runner/reporter.rb +100 -0
- data/lib/spec/runner/specdoc_formatter.rb +20 -0
- data/lib/spec/runner/specification.rb +42 -22
- data/lib/spec/version.rb +1 -1
- data/test/rcov/rcov_testtask.rb +1 -0
- data/test/spec/api/duck_type_test.rb +4 -4
- data/test/spec/api/helper/raising_test.rb +37 -17
- data/test/spec/api/{mock_arg_constraints_test.rb → mocks/mock_arg_constraints_test.rb} +10 -4
- data/test/spec/api/mocks/mock_ordering_test.rb +62 -0
- data/test/spec/api/{mock_test.rb → mocks/mock_test.rb} +30 -7
- data/test/spec/api/mocks/null_object_test.rb +31 -0
- data/test/spec/api/sugar_test.rb +71 -0
- data/test/spec/runner/backtrace_tweaker_test.rb +52 -4
- data/test/spec/runner/context_runner_test.rb +41 -21
- data/test/spec/runner/context_test.rb +60 -32
- data/test/spec/runner/execution_context_test.rb +4 -3
- data/test/spec/runner/failure_dump_test.rb +92 -0
- data/test/spec/runner/kernel_ext_test.rb +1 -2
- data/test/spec/runner/option_parser_test.rb +48 -28
- data/test/spec/runner/progress_bar_formatter_test.rb +48 -0
- data/test/spec/runner/rdoc_formatter_test.rb +31 -4
- data/test/spec/runner/reporter_test.rb +103 -0
- data/test/spec/runner/specdoc_formatter_test.rb +50 -0
- data/test/spec/runner/specification_test.rb +49 -11
- data/test/test_helper.rb +1 -4
- metadata +46 -15
- data/doc/src/community.page +0 -7
- data/doc/src/documentation/api.page +0 -185
- data/doc/src/why_rspec.page +0 -7
- data/examples/empty_stack_spec.rb +0 -22
- data/examples/team_spec.rb +0 -30
- data/lib/spec/api/duck_type.rb +0 -16
- data/lib/spec/runner/simple_text_reporter.rb +0 -88
- data/test/rcov/rcov_verify.rb +0 -28
- data/test/spec/runner/simple_text_reporter_test.rb +0 -123
data/doc/src/community.page
DELETED
@@ -1,185 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: Core API
|
3
|
-
inMenu: true
|
4
|
-
ordering: 5
|
5
|
-
---
|
6
|
-
h2. Core API
|
7
|
-
|
8
|
-
When RSpec executes specifications, it defines a method <code>should</code> on every object in the system. This <code>should</code> method is your entry to the magic of RSpec.
|
9
|
-
|
10
|
-
Almost all expectation forms have a corresponding negated form. It is listed when it is supported and, in general, is met when ever the non-negated form would be violated.
|
11
|
-
|
12
|
-
h3. General
|
13
|
-
|
14
|
-
h4. Arbitrary Block
|
15
|
-
|
16
|
-
<pre>
|
17
|
-
target.should.satisfy {|arg| ...}
|
18
|
-
target.should.not.satisfy {|arg| ...}
|
19
|
-
</pre>
|
20
|
-
|
21
|
-
The supplied block is evaluated, passing <code>target</code> as the sole argument. If the block evaluates to <code>false</code> in the case of <code>should.satisfy</code>, or <code>true</code> in the case of <code>should.not.satisfy</code>, <code>ExpectationNotMetError</code> is raised.
|
22
|
-
|
23
|
-
<pre>
|
24
|
-
target.should.satisfy {|arg| arg > 0}
|
25
|
-
</pre>
|
26
|
-
|
27
|
-
h4. Equality
|
28
|
-
|
29
|
-
<pre>
|
30
|
-
target.should.equal <value>
|
31
|
-
target.should.not.equal <value>
|
32
|
-
</pre>
|
33
|
-
|
34
|
-
The target object is compared to <code>value</code> using ==. If the result is <code>false</code> (or <code>true</code> for the negated form) <code>ExpectationNotMetError</code> is raised.
|
35
|
-
|
36
|
-
h4. Floating Point Comparison
|
37
|
-
|
38
|
-
<pre>
|
39
|
-
target.should.be.close <value>, <tolerance>
|
40
|
-
target.should.not.be.close <value>, <tolerance>
|
41
|
-
</pre>
|
42
|
-
|
43
|
-
The target object is compared to <code>value</code>. In the former case, if they differ by more that <code>tolerance</code> <code>ExpectationNotMetError</code> is raised. In the latter case, it is raised if they differ by less than <code>tolerance</code>.
|
44
|
-
|
45
|
-
<pre>
|
46
|
-
target.should.be.close 27.35, 0.05
|
47
|
-
</pre>
|
48
|
-
|
49
|
-
h4. Identity
|
50
|
-
|
51
|
-
<pre>
|
52
|
-
target.should.be <value>
|
53
|
-
target.should.not.be <value>
|
54
|
-
</pre>
|
55
|
-
|
56
|
-
The target object is compared to <code>value</code> using <code>equal?</code>. If the result is <code>false</code> (or <code>true</code> for the negated form) <code>ExpectationNotMetError</code> is raised.
|
57
|
-
|
58
|
-
h4. Arbitrary Predicate
|
59
|
-
|
60
|
-
|
61
|
-
<pre>
|
62
|
-
target.should.predicate [optional args]
|
63
|
-
target.should.be.predicate [optional args]
|
64
|
-
target.should.not.predicate [optional args]
|
65
|
-
target.should.not.be.predicate [optional args]
|
66
|
-
</pre>
|
67
|
-
|
68
|
-
The message <code>predicate?</code> is sent to <code>target</code> with any supplied arguments. If the result is <code>false</code> (or <code>true</code> for the negated form) <code>ExpectationNotMetError</code> is raised.
|
69
|
-
|
70
|
-
<pre>
|
71
|
-
container.should.include 'a' => container.include? 'a'
|
72
|
-
container.should.be.empty => container.empty?
|
73
|
-
</pre>
|
74
|
-
|
75
|
-
h4. Pattern Matching
|
76
|
-
|
77
|
-
<pre>
|
78
|
-
target.should.match <regex>
|
79
|
-
target.should.not.match <regex>
|
80
|
-
</pre>
|
81
|
-
|
82
|
-
The <code>target</code> is matched against <code>regex</code>. An <code>ExpectationNotMetError</code> is raised if the match fails or succeeds, respectively.
|
83
|
-
|
84
|
-
h3. Class/Type
|
85
|
-
|
86
|
-
h4. Direct Instance
|
87
|
-
|
88
|
-
<pre>
|
89
|
-
target.should.be.an.instance.of <class>
|
90
|
-
target.should.not.be.an.instance.of <class>
|
91
|
-
</pre>
|
92
|
-
|
93
|
-
An <code>ExpectationNotMetError</code> is raised if <code>target</code> is not or is, respectively, an direct instance of <code>class</code>. As expected this correlates to <code>target.instance_of? class</code>.
|
94
|
-
|
95
|
-
h4. Ancestor Class
|
96
|
-
|
97
|
-
<pre>
|
98
|
-
target.should.be.a.kind.of <class>
|
99
|
-
target.should.not.be.a.kind.of <class>
|
100
|
-
</pre>
|
101
|
-
|
102
|
-
As above, but uses <code>target.kind_of? class</code>: checking whether <code>class</code> is the direct class of <code>target</code>, or an ancestor of <code>target</code>'s class.
|
103
|
-
|
104
|
-
h4. Type
|
105
|
-
|
106
|
-
<pre>
|
107
|
-
target.should.respond.to <symbol>
|
108
|
-
target.should.not.respond.to <symbol>
|
109
|
-
</pre>
|
110
|
-
|
111
|
-
Uses <code>target.respond_to? symbol?</code> to check whether <code>symbol</code> is the name of a message that <code>target</code> understands.
|
112
|
-
|
113
|
-
h3. Procs
|
114
|
-
|
115
|
-
h4. Raising
|
116
|
-
|
117
|
-
<pre>
|
118
|
-
proc.should.raise <exception>
|
119
|
-
proc.should.not.raise <exception>
|
120
|
-
</pre>
|
121
|
-
|
122
|
-
Checks that <code>proc</code> does or doesn't cause the named exception to be raised. Typically the <code>proc</code> is created in place using <code>lambda</code>. For example:
|
123
|
-
|
124
|
-
<pre>
|
125
|
-
lambda { 3 / 0 }.should.raise ZeroDivisionError
|
126
|
-
</pre>
|
127
|
-
|
128
|
-
There is a more general form as well.
|
129
|
-
|
130
|
-
<pre>
|
131
|
-
proc.should.raise
|
132
|
-
proc.should.not.raise
|
133
|
-
</pre>
|
134
|
-
|
135
|
-
These forms don't worry about what exception is raised (or not). All they are concern with is that some except was raised, or that no exception was raised.
|
136
|
-
|
137
|
-
h4. Throwing
|
138
|
-
|
139
|
-
<pre>
|
140
|
-
proc.should.throw <symbol>
|
141
|
-
proc.should.not.throw <symbol>
|
142
|
-
</pre>
|
143
|
-
|
144
|
-
Similar to the above, but checks that <code>symbol</code> is thrown from within <code>proc</code>, or that it is not. The latter is actually one of two cases: some other symbol is
|
145
|
-
thrown, or no symbol is thrown.
|
146
|
-
|
147
|
-
<pre>
|
148
|
-
proc.should.not.throw
|
149
|
-
</pre>
|
150
|
-
|
151
|
-
This form is more specific. It checks that no symbol is thrown from within <code>proc</code>.
|
152
|
-
|
153
|
-
h3. Collections
|
154
|
-
|
155
|
-
h4. Containment
|
156
|
-
|
157
|
-
<pre>
|
158
|
-
target.should.include <object>
|
159
|
-
</pre>
|
160
|
-
|
161
|
-
This is simply a specific case of the arbitrary predicate form. It uses <code>target.include? object</code> and raises an <code>ExpectationNotMetError</code> if that returns false. The remaining collection forms are a little more involved. They rely on two things: <code>target</code> responds to the message <code>things</code> by returning an object that responds to either <code>length</code> or <code>size</code>, which return a number that is a measure of size. Currently <code>length</code> is used if is appropriate, otherwise <code>size</code> is attempted.
|
162
|
-
|
163
|
-
h4. Exact Size
|
164
|
-
|
165
|
-
<pre>
|
166
|
-
target.should.have(<number>).<things>
|
167
|
-
</pre>
|
168
|
-
|
169
|
-
The <code>things</code> of <code>target</code> has a length/size of exactly <code>number</code>.
|
170
|
-
|
171
|
-
h4. Lower Bound
|
172
|
-
|
173
|
-
<pre>
|
174
|
-
target.should.have.at.least(<number>).<things>
|
175
|
-
</pre>
|
176
|
-
|
177
|
-
The <code>things</code> of <code>target</code> has a length/size of no less than <code>number</code>.
|
178
|
-
|
179
|
-
h4. Upper Bound
|
180
|
-
|
181
|
-
<pre>
|
182
|
-
target.should.have.at.most(<number>).<things>
|
183
|
-
</pre>
|
184
|
-
|
185
|
-
The <code>things</code> of <code>target</code> has a length/size of no more than <code>number</code>.
|
data/doc/src/why_rspec.page
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../lib/spec'
|
2
|
-
require File.dirname(__FILE__) + "/stack"
|
3
|
-
|
4
|
-
context "An empty stack" do
|
5
|
-
|
6
|
-
setup do
|
7
|
-
@stack = Stack.new
|
8
|
-
end
|
9
|
-
|
10
|
-
specify "should accept an item when sent push" do
|
11
|
-
lambda { @stack.push Object.new }.should.not.raise
|
12
|
-
end
|
13
|
-
|
14
|
-
specify "should complain when sent top" do
|
15
|
-
lambda { @stack.top }.should.raise StackUnderflowError
|
16
|
-
end
|
17
|
-
|
18
|
-
specify "should complain when sent pop" do
|
19
|
-
lambda { @stack.pop }.should.raise StackUnderflowError
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
data/examples/team_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../lib/spec'
|
2
|
-
|
3
|
-
class Team
|
4
|
-
attr_reader :players
|
5
|
-
def initialize
|
6
|
-
@players = Players.new
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class Players
|
11
|
-
def size
|
12
|
-
0
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "A new team" do
|
17
|
-
|
18
|
-
setup do
|
19
|
-
@team = Team.new
|
20
|
-
end
|
21
|
-
|
22
|
-
specify "should have 3 players (failing example)" do
|
23
|
-
@team.should.have(3).players
|
24
|
-
end
|
25
|
-
|
26
|
-
specify "should have 1 player (failing example)" do
|
27
|
-
@team.players.size.should.be 1
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
data/lib/spec/api/duck_type.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Spec
|
2
|
-
module Api
|
3
|
-
|
4
|
-
class DuckType
|
5
|
-
def initialize(*methods_to_respond_do)
|
6
|
-
@methods_to_respond_do = methods_to_respond_do
|
7
|
-
end
|
8
|
-
|
9
|
-
def walks_like?(obj)
|
10
|
-
@methods_to_respond_do.each { |sym| return false unless obj.respond_to? sym }
|
11
|
-
return true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
module Spec
|
2
|
-
module Runner
|
3
|
-
class SimpleTextReporter
|
4
|
-
def initialize(output=STDOUT,verbose=false,backtrace_tweaker=BacktraceTweaker.new)
|
5
|
-
@output = output
|
6
|
-
@context_names = []
|
7
|
-
@errors = []
|
8
|
-
@spec_names = []
|
9
|
-
@verbose = verbose
|
10
|
-
@backtrace_tweaker = backtrace_tweaker
|
11
|
-
end
|
12
|
-
|
13
|
-
def add_context(name)
|
14
|
-
@output << "\n" if @context_names.empty? unless @verbose
|
15
|
-
@output << "\n#{name}\n" if @verbose
|
16
|
-
@context_names << name
|
17
|
-
end
|
18
|
-
|
19
|
-
def add_spec(name, errors=[])
|
20
|
-
if errors.empty?
|
21
|
-
spec_passed(name)
|
22
|
-
else
|
23
|
-
errors.each { |error| @backtrace_tweaker.tweak_backtrace(error, name) }
|
24
|
-
# only show the first one (there might be more)
|
25
|
-
spec_failed(name, errors[0])
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def start
|
30
|
-
@start_time = Time.new
|
31
|
-
end
|
32
|
-
|
33
|
-
def end
|
34
|
-
@end_time = Time.new
|
35
|
-
end
|
36
|
-
|
37
|
-
def dump
|
38
|
-
@output << "\n"
|
39
|
-
dump_errors
|
40
|
-
@output << "\n\n" unless @errors.empty?
|
41
|
-
@output << "\n" if @errors.empty?
|
42
|
-
@output << "Finished in " << (duration).to_s << " seconds\n\n"
|
43
|
-
@output << "#{@context_names.length} context#{'s' unless @context_names.length == 1 }, "
|
44
|
-
@output << "#{@spec_names.length} specification#{'s' unless @spec_names.length == 1 }, "
|
45
|
-
@output << "#{@errors.length} failure#{'s' unless @errors.length == 1 }"
|
46
|
-
@output << "\n"
|
47
|
-
end
|
48
|
-
|
49
|
-
def dump_errors
|
50
|
-
return if @errors.empty?
|
51
|
-
@output << "\n"
|
52
|
-
@errors.inject(1) do |index, error|
|
53
|
-
@output << "\n\n" if index > 1
|
54
|
-
@output << index.to_s << ")\n"
|
55
|
-
@output << "#{error.message} (#{error.class.name})\n"
|
56
|
-
dump_backtrace(error.backtrace)
|
57
|
-
index + 1
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def dump_backtrace(trace)
|
62
|
-
@output << trace.join("\n") unless trace.nil?
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def duration
|
68
|
-
return @end_time - @start_time unless (@end_time.nil? or @start_time.nil?)
|
69
|
-
return "0.0"
|
70
|
-
end
|
71
|
-
|
72
|
-
def spec_passed(name)
|
73
|
-
@spec_names << name
|
74
|
-
@output << "- #{name}\n" if @verbose
|
75
|
-
@output << '.' unless @verbose
|
76
|
-
end
|
77
|
-
|
78
|
-
def spec_failed(name, error)
|
79
|
-
@spec_names << name
|
80
|
-
@errors << error
|
81
|
-
@output << "- #{name} (FAILED - #{@errors.length})\n" if @verbose
|
82
|
-
@output << 'F' unless @verbose
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
end
|
data/test/rcov/rcov_verify.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module RCov
|
2
|
-
class VerifyTask < Rake::TaskLib
|
3
|
-
attr_accessor :name
|
4
|
-
attr_accessor :index_html
|
5
|
-
attr_accessor :threshold
|
6
|
-
|
7
|
-
def initialize(name=:rcov_verify)
|
8
|
-
@name = name
|
9
|
-
yield self if block_given?
|
10
|
-
raise "Threshold must be set" if @threshold.nil?
|
11
|
-
define
|
12
|
-
end
|
13
|
-
|
14
|
-
def define
|
15
|
-
desc "Verify that rcov coverage is at least #{threshold}"
|
16
|
-
task @name do
|
17
|
-
total_coverage = nil
|
18
|
-
File.open(index_html).each_line do |line|
|
19
|
-
if line =~ /<tt>(\d+\.\d+)%<\/tt> <\/td>/
|
20
|
-
total_coverage = eval($1)
|
21
|
-
break
|
22
|
-
end
|
23
|
-
end
|
24
|
-
raise "Coverage must be at least #{threshold}% but was #{total_coverage}%" if total_coverage < threshold
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,123 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
|
3
|
-
module Spec
|
4
|
-
module Runner
|
5
|
-
class SimpleTextReporterTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@io = StringIO.new
|
9
|
-
@backtrace_tweaker = Spec::Api::Mock.new("backtrace tweaker")
|
10
|
-
@reporter = SimpleTextReporter.new(@io, false, @backtrace_tweaker)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_should_include_time
|
14
|
-
@reporter.start
|
15
|
-
@reporter.end
|
16
|
-
@reporter.dump
|
17
|
-
assert_match(/Finished in [0-9].[0-9|e|-]+ seconds/, @io.string)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_should_output_stats_even_with_no_data
|
21
|
-
@reporter.dump
|
22
|
-
assert_match(/Finished in 0.0 seconds/, @io.string)
|
23
|
-
assert_match(/0 contexts, 0 specifications, 0 failures/, @io.string)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_should_account_for_context_in_stats_for_pass
|
27
|
-
@reporter.add_context "context"
|
28
|
-
@reporter.dump
|
29
|
-
assert_match(/1 context, 0 specifications, 0 failures/, @io.string)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_should_account_for_spec_in_stats_for_pass
|
33
|
-
@reporter.add_spec Specification.new("spec"), {}
|
34
|
-
@reporter.dump
|
35
|
-
assert_match(/0 contexts, 1 specification, 0 failures/, @io.string)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_should_account_for_spec_and_error_in_stats_for_pass
|
39
|
-
@backtrace_tweaker.should.receive(:tweak_backtrace)
|
40
|
-
@reporter.add_context "context"
|
41
|
-
@reporter.add_spec Specification.new("spec"), [RuntimeError.new]
|
42
|
-
@reporter.dump
|
43
|
-
assert_match(/1 context, 1 specification, 1 failure/, @io.string)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_should_handle_multiple_contexts_same_name
|
47
|
-
@reporter.add_context Context.new("context") {}
|
48
|
-
@reporter.add_context Context.new("context") {}
|
49
|
-
@reporter.add_context Context.new("context") {}
|
50
|
-
@reporter.dump
|
51
|
-
assert_match(/3 contexts, 0 specifications, 0 failures/, @io.string)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_should_handle_multiple_specs_same_name
|
55
|
-
@backtrace_tweaker.should.receive(:tweak_backtrace)
|
56
|
-
@reporter.add_context "context"
|
57
|
-
@reporter.add_spec "spec"
|
58
|
-
@reporter.add_spec "spec", [RuntimeError.new]
|
59
|
-
@reporter.add_context "context"
|
60
|
-
@reporter.add_spec "spec"
|
61
|
-
@reporter.add_spec "spec", [RuntimeError.new]
|
62
|
-
@reporter.dump
|
63
|
-
assert_match(/2 contexts, 4 specifications, 2 failures/, @io.string)
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_should_delegate_to_backtrace_tweaker
|
67
|
-
@backtrace_tweaker.should.receive(:tweak_backtrace)
|
68
|
-
@reporter.add_context "context"
|
69
|
-
@reporter.add_spec "spec", [RuntimeError.new]
|
70
|
-
@backtrace_tweaker.__verify
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
class SimpleTextReporterQuietOutputTest < Test::Unit::TestCase
|
76
|
-
|
77
|
-
def setup
|
78
|
-
@io = StringIO.new
|
79
|
-
@reporter = SimpleTextReporter.new(@io)
|
80
|
-
@reporter.add_context "context"
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_should_remain_silent_when_context_name_provided
|
84
|
-
assert_equal("\n", @io.string)
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_should_output_dot_when_spec_passed
|
88
|
-
@reporter.add_spec "spec"
|
89
|
-
assert_equal("\n.", @io.string)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_should_output_F_when_spec_failed
|
93
|
-
@reporter.add_spec "spec", [RuntimeError.new]
|
94
|
-
assert_equal("\nF", @io.string)
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
class SimpleTextReporterVerboseOutputTest < Test::Unit::TestCase
|
100
|
-
|
101
|
-
def setup
|
102
|
-
@io = StringIO.new
|
103
|
-
@reporter = SimpleTextReporter.new(@io, true)
|
104
|
-
@reporter.add_context "context"
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_should_output_when_context_name_provided
|
108
|
-
assert_match(/\ncontext\n/, @io.string)
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_should_output_spec_name_when_spec_passed
|
112
|
-
@reporter.add_spec "spec"
|
113
|
-
assert_match(/- spec\n/, @io.string)
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_should_output_failure_when_spec_failed
|
117
|
-
@reporter.add_spec "spec", [RuntimeError.new]
|
118
|
-
assert_match(/spec \(FAILED - 1\)/, @io.string)
|
119
|
-
end
|
120
|
-
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|