In Files

Parent

Bacon::TestUnitOutput::TapOutput::Should

Public Class Methods

new(object) click to toggle source
# File lib/bacon.rb, line 295
def initialize(object)
  @object = object
  @negated = false
end

Public Instance Methods

a(*args, &block) click to toggle source
Alias for: be
an(*args, &block) click to toggle source
Alias for: be
be(*args, &block) click to toggle source
# File lib/bacon.rb, line 310
def be(*args, &block)
  if args.empty?
    self
  else
    block = args.shift  unless block_given?
    satisfy(*args, &block)
  end
end
Also aliased as: a, an
equal(value) click to toggle source
# File lib/bacon.rb, line 343
def equal(value)         self == value      end
flunk(reason="Flunked") click to toggle source
# File lib/bacon.rb, line 348
def flunk(reason="Flunked")
  raise Bacon::Error.new(:failed, reason)
end
identical_to(value) click to toggle source
# File lib/bacon.rb, line 345
def identical_to(value)  self.equal? value  end
Also aliased as: same_as
match(value) click to toggle source
# File lib/bacon.rb, line 344
def match(value)         self =~ value      end
method_missing(name, *args, &block) click to toggle source
# File lib/bacon.rb, line 333
def method_missing(name, *args, &block)
  name = "#{name}?"  if name.to_s =~ /\w[^?]\z/

  desc = @negated ? "not " : ""
  desc << @object.inspect << "." << name.to_s
  desc << "(" << args.map{|x|x.inspect}.join(", ") << ") failed"

  satisfy(desc) { |x| x.__send__(name, *args, &block) }
end
not(*args, &block) click to toggle source
# File lib/bacon.rb, line 300
def not(*args, &block)
  @negated = !@negated

  if args.empty?
    self
  else
    be(*args, &block)
  end
end
same_as(value) click to toggle source
Alias for: identical_to
satisfy(description="", &block) click to toggle source
# File lib/bacon.rb, line 322
def satisfy(description="", &block)
  r = yield(@object)
  if Bacon::Counter[:depth] > 0
    Bacon::Counter[:requirements] += 1
    raise Bacon::Error.new(:failed, description)  unless @negated ^ r
    r
  else
    @negated ? !r : !!r
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.