Sha256: d7ba59f1b8e7e9153cf0fa5ec09625478a43ce1caa403cb5b010a1906a8177eb
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
require 'orangutan/raiser' require 'orangutan/container' module Orangutan class Expectation attr_reader :return_container, :yield_container, :raiser, :count def initialize @return_container = nil @yield_container = nil @raiser = nil end def receives method @method = method self end def with *args @args = args self end def return *value @return_container = Container.new value self end def yield *value @yield_container ||= Container.new([]) @yield_container.value << value self end def raise *args @raiser = Raiser.new args self end def matches? method, *args return false unless method == @method matched = @args ? @args == args : true return false if @limit && @count && @count >= @limit if matched @count ||= 0 @count += 1 end matched end def exactly count @limit = count self end def once exactly 1 end def twice exactly 2 end def times self end def matched? if @limit @count && @count >= @limit else @count end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
orangutan-0.0.7 | lib/orangutan/expectation.rb |
orangutan-0.0.6 | lib/orangutan/expectation.rb |
orangutan-0.0.5 | lib/orangutan/expectation.rb |