In Files

Files

Bacon::TestUnitOutput::TapOutput::KnockOutput::Context

Attributes

name[R]
block[R]

Public Class Methods

new(name, &block) click to toggle source
     # File lib/bacon.rb, line 131
131:     def initialize(name, &block)
132:       @name = name
133:       @before, @after = [], []
134:       @block = block
135:     end

Public Instance Methods

after(&block) click to toggle source
     # File lib/bacon.rb, line 144
144:     def after(&block);  @after << block; end
before(&block) click to toggle source
     # File lib/bacon.rb, line 143
143:     def before(&block); @before << block; end
behaves_like(*names) click to toggle source
     # File lib/bacon.rb, line 146
146:     def behaves_like(*names)
147:       names.each { |name| instance_eval(&Shared[name]) }
148:     end
change?(*args, &block) click to toggle source
     # File lib/bacon.rb, line 220
220:     def change?(*args, &block); block.change?(*args); end
describe(*args, &block) click to toggle source
     # File lib/bacon.rb, line 211
211:     def describe(*args, &block)
212:       context = Bacon::Context.new(args.join(' '), &block)
213:       @before.each { |b| context.before(&b) }
214:       @after.each { |b| context.after(&b) }
215:       context.run
216:     end
it(description, &block) click to toggle source
     # File lib/bacon.rb, line 150
150:     def it(description, &block)
151:       return  unless description =~ RestrictName
152:       block ||= lambda { should.flunk "not implemented" }
153:       Counter[:specifications] += 1
154:       run_requirement description, block
155:     end
raise?(*args, &block) click to toggle source
     # File lib/bacon.rb, line 218
218:     def raise?(*args, &block); block.raise?(*args); end
run() click to toggle source
     # File lib/bacon.rb, line 137
137:     def run
138:       return  unless name =~ RestrictContext
139:       Bacon.handle_specification(name) { instance_eval(&block) }
140:       self
141:     end
run_requirement(description, spec) click to toggle source
     # File lib/bacon.rb, line 165
165:     def run_requirement(description, spec)
166:       Bacon.handle_requirement description do
167:         begin
168:           Counter[:depth] += 1
169:           rescued = false
170:           begin
171:             @before.each { |block| instance_eval(&block) }
172:             prev_req = Counter[:requirements]
173:             instance_eval(&spec)
174:           rescue Object => e
175:             rescued = true
176:             raise e
177:           ensure
178:             if Counter[:requirements] == prev_req and not rescued
179:               raise Error.new(:missing,
180:                               "empty specification: #{@name} #{description}")
181:             end
182:             begin
183:               @after.each { |block| instance_eval(&block) }
184:             rescue Object => e
185:               raise e  unless rescued
186:             end
187:           end
188:         rescue Object => e
189:           ErrorLog << "#{e.class}: #{e.message}\n"
190:           e.backtrace.find_all { |line| line !~ /bin\/bacon|\/bacon\.rb:\d+/ }.
191:             each_with_index { |line, i|
192:             ErrorLog << "\t#{line}#{i==0 ? ": #@name - #{description}" : ""}\n"
193:           }
194:           ErrorLog << "\n"
195: 
196:           if e.kind_of? Error
197:             Counter[e.count_as] += 1
198:             e.count_as.to_s.upcase
199:           else
200:             Counter[:errors] += 1
201:             "ERROR: #{e.class}"
202:           end
203:         else
204:           ""
205:         ensure
206:           Counter[:depth] -= 1
207:         end
208:       end
209:     end
should(*args, &block) click to toggle source
     # File lib/bacon.rb, line 157
157:     def should(*args, &block)
158:       if Counter[:depth]==0
159:         it('should '+args.first,&block)
160:       else
161:         super(*args,&block)
162:       end
163:     end
throw?(*args, &block) click to toggle source
     # File lib/bacon.rb, line 219
219:     def throw?(*args, &block); block.throw?(*args); end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.