Module: Kookaburra::TestHelpers
- Extended by:
- Forwardable
- Defined in:
- lib/kookaburra/test_helpers.rb
Overview
This module is intended to be mixed in to your testing context to provide convenient access to your Kookaburra objects. Examples for both RSpec and Cucumber are given below; mixing it in to other test setups should be pretty straight-forward.
Instance Method Summary collapse
-
#assert_mental_model_matches(collection_key, actual, message = nil) ⇒ Object
Custom assertion for Test::Unit-style tests (really, anything that uses #assert(predicate, message = nil)).
-
#given ⇒ Object
Delegates to #k.
-
#k ⇒ Kookaburra
The Kookaburra instance to be used by your tests.
-
#match_mental_model_of(collection_key) ⇒ Object
RSpec-style custom matcher that compares a given array with the current state of one named collection in the mental model.
-
#ui ⇒ Object
Delegates to #k.
Instance Method Details
#assert_mental_model_matches(collection_key, actual, message = nil) ⇒ Object
Custom assertion for Test::Unit-style tests (really, anything that uses #assert(predicate, message = nil))
115 116 117 118 119 120 121 122 |
# File 'lib/kookaburra/test_helpers.rb', line 115 def assert_mental_model_matches(collection_key, actual, = nil) matcher = match_mental_model_of(collection_key) result = matcher.matches?(actual) return if !!result # don't even bother ||= matcher. assert result, end |
#given ⇒ Object
Delegates to #k
97 |
# File 'lib/kookaburra/test_helpers.rb', line 97 def_delegator :k, :given |
#k ⇒ Kookaburra
The Kookaburra instance to be used by your tests. It gets configured using the options set in Kookaburra.configuration, and the result is memoized.
91 92 93 |
# File 'lib/kookaburra/test_helpers.rb', line 91 def k @k ||= Kookaburra.new end |
#match_mental_model_of(collection_key) ⇒ Object
RSpec-style custom matcher that compares a given array with the current state of one named collection in the mental model
107 108 109 |
# File 'lib/kookaburra/test_helpers.rb', line 107 def match_mental_model_of(collection_key) MentalModel::Matcher.new(k.send(:__mental_model__), collection_key) end |
#ui ⇒ Object
Delegates to #k
101 |
# File 'lib/kookaburra/test_helpers.rb', line 101 def_delegator :k, :ui |