Module: HigherExpectations
- Defined in:
- lib/higher_expectations.rb,
lib/instance_methods.rb,
lib/higher_expectations/version.rb
Overview
Higher expectations module
Provides method to load instance methods in a group of arguments
Requires instance methods
Usage:
class Something
include HigherExpectations
end
..or optionally inject into Object (not recommended)
Defined Under Namespace
Modules: InstanceMethods, VERSION
Instance Method Summary collapse
-
#has_expectations(*objects) ⇒ Object
(also: #has_expectation)
Should be called at method entrance, extends each given object with expectation methods.
Instance Method Details
#has_expectations(*objects) ⇒ Object Also known as: has_expectation
Should be called at method entrance, extends each given object with expectation methods
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/higher_expectations.rb', line 21 def has_expectations(*objects) objects.map do |obj| #next if obj.respond_to?(:raise_ae) # skip objects that have already instance methods begin obj.extend(HigherExpectations::InstanceMethods) # TypeErrors are generated when trying to extend Numeric objects, which are not and cannot be singeltons and hence cannot get new methods. # Handled below via Numeric rescue TypeError next end end end |