Class: ContextAsserter
- Inherits:
-
ContextAsserterBase
- Object
- MiniTest::Unit::TestCase
- ContextAsserterBase
- ContextAsserter
- Defined in:
- lib/maroon/contracts.rb
Instance Method Summary collapse
- #can_play(role) ⇒ Object
-
#initialize(contracts, obj, is_asserting = true) ⇒ ContextAsserter
constructor
A new instance of ContextAsserter.
- #is_test ⇒ Object
Constructor Details
#initialize(contracts, obj, is_asserting = true) ⇒ ContextAsserter
Returns a new instance of ContextAsserter.
12 13 14 15 16 17 |
# File 'lib/maroon/contracts.rb', line 12 def initialize(contracts, obj, is_asserting = true) raise 'Contracts must be supplied' unless contracts @obj = obj @contracts = contracts @is_asserting = is_asserting end |
Instance Method Details
#can_play(role) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/maroon/contracts.rb', line 23 def can_play(role) msg = "#{@is_asserting ? 'Was' : "wasn't"} expected to be able to play #{role}".intern if is_test assert_equal(@is_asserting, can_play?(role), msg) else raise msg if @is_asserting != can_play?(role) end end |
#is_test ⇒ Object
19 20 21 |
# File 'lib/maroon/contracts.rb', line 19 def is_test Kernel::const_defined? :MiniTest end |