Class: Selector
- Inherits:
-
Object
- Object
- Selector
- Includes:
- RSpec::Matchers
- Defined in:
- lib/brine/selector.rb
Overview
Selectors here are small wrappers around RSpec expectation behavior to encapsulate variations in some expecation associated behavior in classes.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#coercer ⇒ Object
Returns the value of attribute coercer.
Instance Method Summary collapse
- #assert_that(value) ⇒ Object
- #filter_matcher(matcher) ⇒ Object
-
#initialize(target, negated) ⇒ Selector
constructor
A new instance of Selector.
Constructor Details
#initialize(target, negated) ⇒ Selector
Returns a new instance of Selector.
12 13 14 15 |
# File 'lib/brine/selector.rb', line 12 def initialize(target, negated) @target = target @message = negated ? :to_not : :to end |
Instance Attribute Details
#coercer ⇒ Object
Returns the value of attribute coercer.
10 11 12 |
# File 'lib/brine/selector.rb', line 10 def coercer @coercer end |
Instance Method Details
#assert_that(value) ⇒ Object
21 22 23 24 25 |
# File 'lib/brine/selector.rb', line 21 def assert_that(value) target, value = coercer.coerce(@target, value) matcher = filter_matcher(yield(value)) expect(target).send(@message, matcher) end |
#filter_matcher(matcher) ⇒ Object
17 18 19 |
# File 'lib/brine/selector.rb', line 17 def filter_matcher(matcher) matcher end |