Class: Matchi::Fix
- Inherits:
-
Object
- Object
- Matchi::Fix
- Defined in:
- lib/matchi/fix.rb
Overview
Fix specing matcher.
Instance Attribute Summary collapse
-
#expected ⇒ #against
readonly
A set of specifications.
Instance Method Summary collapse
-
#initialize(name = nil, &block) ⇒ Fix
constructor
Initialize the matcher with a behavioral definition.
-
#inspect ⇒ Object
A string containing a human-readable representation of the matcher.
-
#matches?(&block) ⇒ Boolean
Boolean comparison between an actual value and the expected specs.
-
#to_s ⇒ Object
Returns a string representing the matcher.
Constructor Details
#initialize(name = nil, &block) ⇒ Fix
Initialize the matcher with a behavioral definition.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/matchi/fix.rb', line 30 def initialize(name = nil, &block) @name = name @expected = if unnamed? raise ::ArgumentError, "Pass either an argument or a block" unless block Fix(&block) else raise ::ArgumentError, "Can't pass both an argument and a block" if block ::Fix[name] end end |
Instance Attribute Details
#expected ⇒ #against (readonly)
Returns A set of specifications.
10 11 12 |
# File 'lib/matchi/fix.rb', line 10 def expected @expected end |
Instance Method Details
#inspect ⇒ Object
A string containing a human-readable representation of the matcher.
76 77 78 |
# File 'lib/matchi/fix.rb', line 76 def inspect "#{self.class}(#{parameter})" end |
#matches?(&block) ⇒ Boolean
Boolean comparison between an actual value and the expected specs.
69 70 71 72 73 |
# File 'lib/matchi/fix.rb', line 69 def matches?(&block) expected.against(log_level: 0, &block) rescue ::SystemExit => e e.success? end |
#to_s ⇒ Object
Returns a string representing the matcher.
81 82 83 |
# File 'lib/matchi/fix.rb', line 81 def to_s "fix #{parameter}" end |