Module: AE::Expect
- Included in:
- Object
- Defined in:
- lib/ae/expect.rb
Overview
Expect
"When love and skill work together, expect a masterpiece."
--John Ruskin (1819 - 1900)
Instance Method Summary collapse
-
#expect(*args, &block) ⇒ Object
The #expect method is a convenient tool for defining certain sets of expectations in your specifications.
-
#expect!(*args, &block) ⇒ Object
(also: #forbid)
Designate a negated expectation.
-
#expected(*args, &block) ⇒ Object
Like #expect but uses the reciever as the object of expectation.
Instance Method Details
#expect(*args, &block) ⇒ Object
The #expect method is a convenient tool for defining certain sets of expectations in your specifications.
Expect is used to expect a result from a block of code. If the argument to expect is a subclass of Exception or instance thereof, then the block is monitored for the raising of such an exception.
expect StandardError do
raise ArgumentError
end
All other expectations are compared using case equality (#===). This allows one to verify matching Regexp.
expect /x/ do
"x"
end
As well as checking that an object is an instance of a given Class.
expect String do
"x"
end
Like #assert it can be used to designate an expectation via a functor.
4.expect == 3
41 42 43 |
# File 'lib/ae/expect.rb', line 41 def expect(*args, &block) Assertor.new(self, :backtrace=>caller).expect(*args, &block) end |
#expect!(*args, &block) ⇒ Object Also known as: forbid
Designate a negated expectation. Read this as “expect not”.
See #expect.
49 50 51 |
# File 'lib/ae/expect.rb', line 49 def expect!(*args, &block) Assertor.new(self, :backtrace=>caller).not.expect(*args, &block) end |
#expected(*args, &block) ⇒ Object
Like #expect but uses the reciever as the object of expectation.
64 65 66 |
# File 'lib/ae/expect.rb', line 64 def expected(*args, &block) expect(self, *args, &block) end |