Class: Orangutan::Expectation
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#raiser ⇒ Object
readonly
Returns the value of attribute raiser.
-
#return_container ⇒ Object
readonly
Returns the value of attribute return_container.
-
#yield_container ⇒ Object
readonly
Returns the value of attribute yield_container.
Instance Method Summary collapse
- #exactly(count) ⇒ Object
-
#initialize ⇒ Expectation
constructor
A new instance of Expectation.
- #matched? ⇒ Boolean
- #matches?(method, *args) ⇒ Boolean
- #once ⇒ Object
- #raise(*args) ⇒ Object
- #receives(method) ⇒ Object
- #return(*value) ⇒ Object
- #times ⇒ Object
- #twice ⇒ Object
- #with(*args) ⇒ Object
- #yield(*value) ⇒ Object
Constructor Details
#initialize ⇒ Expectation
Returns a new instance of Expectation.
8 9 10 11 12 |
# File 'lib/orangutan/expectation.rb', line 8 def initialize @return_container = nil @yield_container = nil @raiser = nil end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
6 7 8 |
# File 'lib/orangutan/expectation.rb', line 6 def count @count end |
#raiser ⇒ Object (readonly)
Returns the value of attribute raiser.
6 7 8 |
# File 'lib/orangutan/expectation.rb', line 6 def raiser @raiser end |
#return_container ⇒ Object (readonly)
Returns the value of attribute return_container.
6 7 8 |
# File 'lib/orangutan/expectation.rb', line 6 def return_container @return_container end |
#yield_container ⇒ Object (readonly)
Returns the value of attribute yield_container.
6 7 8 |
# File 'lib/orangutan/expectation.rb', line 6 def yield_container @yield_container end |
Instance Method Details
#exactly(count) ⇒ Object
51 52 53 54 |
# File 'lib/orangutan/expectation.rb', line 51 def exactly count @limit = count self end |
#matched? ⇒ Boolean
68 69 70 71 72 73 74 |
# File 'lib/orangutan/expectation.rb', line 68 def matched? if @limit @count && @count >= @limit else @count end end |
#matches?(method, *args) ⇒ Boolean
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/orangutan/expectation.rb', line 40 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 |
#once ⇒ Object
56 57 58 |
# File 'lib/orangutan/expectation.rb', line 56 def once exactly 1 end |
#raise(*args) ⇒ Object
35 36 37 38 |
# File 'lib/orangutan/expectation.rb', line 35 def raise *args @raiser = Raiser.new args self end |
#receives(method) ⇒ Object
14 15 16 17 |
# File 'lib/orangutan/expectation.rb', line 14 def receives method @method = method self end |
#return(*value) ⇒ Object
24 25 26 27 |
# File 'lib/orangutan/expectation.rb', line 24 def return *value @return_container = Container.new value self end |
#times ⇒ Object
64 65 66 |
# File 'lib/orangutan/expectation.rb', line 64 def times self end |
#twice ⇒ Object
60 61 62 |
# File 'lib/orangutan/expectation.rb', line 60 def twice exactly 2 end |
#with(*args) ⇒ Object
19 20 21 22 |
# File 'lib/orangutan/expectation.rb', line 19 def with *args @args = args self end |