Class: Kookaburra::MentalModel
- Inherits:
-
Object
- Object
- Kookaburra::MentalModel
- Defined in:
- lib/kookaburra/mental_model.rb,
lib/kookaburra/mental_model_matcher.rb
Overview
Each instance of Kookaburra has its own instance of MentalModel. This object is used to maintain a shared understanding of the application state between your GivenDriver and your UIDriver. You can access the various test data collections in your test implementations via #get_data.
The mental model is not intended to represent a copy of all of the data within your application. Rather it is meant to represent the mental image of the data that a user of your application might have while working with your system. Certainly you can store whatever you want in it, but thinking about it in these terms can help you design better, more robust tests.
Defined Under Namespace
Classes: Collection, Matcher
Instance Method Summary collapse
-
#initialize ⇒ MentalModel
constructor
A new instance of MentalModel.
-
#method_missing(name, *args) ⇒ Object
MentalModel instances will respond to any message that has an arity of 0 by returning either a new or existing Collection having the name of the method.
-
#respond_to? ⇒ Boolean
MentalModel instances respond to everything.
Constructor Details
#initialize ⇒ MentalModel
Returns a new instance of MentalModel.
16 17 18 |
# File 'lib/kookaburra/mental_model.rb', line 16 def initialize @data = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
MentalModel instances will respond to any message that has an arity of 0 by returning either a new or existing Collection having the name of the method.
23 24 25 26 |
# File 'lib/kookaburra/mental_model.rb', line 23 def method_missing(name, *args) return super unless args.empty? @data[name] ||= Collection.new(name) end |
Instance Method Details
#respond_to? ⇒ Boolean
MentalModel instances respond to everything.
31 32 33 |
# File 'lib/kookaburra/mental_model.rb', line 31 def respond_to? true end |