Class Test::Spec::ShouldNot
In: lib/test/spec.rb
Parent: Object

Methods

==   =~   _raise   add_assertion   be   be_nil   equal   match   method_missing   new   nil   not   pass   satisfy   throw  

Included Modules

Test::Unit::Assertions

Public Class methods

[Source]

     # File lib/test/spec.rb, line 203
203:     def initialize(object, message=nil)
204:       @object = object
205:       @message = message
206:     end

Public Instance methods

==(value)

Alias for equal

=~(value)

Alias for match

[Source]

     # File lib/test/spec.rb, line 245
245:     def _raise(*args, &block)
246:       block ||= @object
247:       assert_nothing_raised(*(args+[@message]), &block)
248:     end

[Source]

     # File lib/test/spec.rb, line 208
208:     def add_assertion
209:       $TEST_SPEC_TESTCASE && $TEST_SPEC_TESTCASE.__send__(:add_assertion)
210:     end

[Source]

     # File lib/test/spec.rb, line 224
224:     def be(*value)
225:       case value.size
226:       when 0
227:         self
228:       when 1
229:         if CustomShould === value.first 
230:           pass value.first
231:         else
232:           assert_not_same value.first, @object, @message
233:         end
234:       else
235:         Kernel.raise ArgumentError, "should.be needs zero or one argument"
236:       end
237:     end

[Source]

     # File lib/test/spec.rb, line 258
258:     def be_nil
259:       warn "Test::Spec::ShouldNot#be_nil is deprecated and will be removed in future versions."
260:       self.nil
261:     end

[Source]

     # File lib/test/spec.rb, line 219
219:     def equal(value)
220:       assert_not_equal value, @object, @message
221:     end

[Source]

     # File lib/test/spec.rb, line 239
239:     def match(value)
240:       # Icky Regexp check
241:       assert_no_match value, @object, @message
242:     end

[Source]

     # File lib/test/spec.rb, line 282
282:     def method_missing(name, *args, &block)
283:       # This will make raise call Kernel.raise, and self.raise call _raise.
284:       return _raise(*args, &block)  if name == :raise
285: 
286:       if @object.respond_to?("#{name}?")
287:         assert_block("#{name}? expected to be false. #{@message}") {
288:           not @object.__send__("#{name}?", *args)
289:         }
290:       else
291:         if @object.respond_to?(name)
292:           assert_block("#{name} expected to be false. #{@message}") {
293:             not @object.__send__("#{name}", *args)
294:           }
295:         else
296:           super
297:         end
298:       end
299:     end

[Source]

     # File lib/test/spec.rb, line 254
254:     def nil
255:       assert_not_nil @object, @message
256:     end

[Source]

     # File lib/test/spec.rb, line 263
263:     def not(*args)
264:       case args.size
265:       when 0
266:         Should.new(@object, @message)
267:       when 1
268:         Should.new(@object, @message).pass(args.first)
269:       else
270:         raise ArgumentError, "#not takes zero or one argument(s)."
271:       end
272:     end

[Source]

     # File lib/test/spec.rb, line 274
274:     def pass(custom)
275:       _wrap_assertion {
276:         begin
277:           assert !custom.matches?(@object), @message || custom.failure_message
278:         end
279:       }
280:     end

[Source]

     # File lib/test/spec.rb, line 213
213:     def satisfy(&block)
214:       assert_block(@message || "not.satisfy block succeded.") {
215:         not yield @object
216:       }
217:     end

[Source]

     # File lib/test/spec.rb, line 250
250:     def throw
251:       assert_nothing_thrown(@message, &@object)
252:     end

[Validate]