Class: Normalizr::RSpec::Matcher::Normalization
- Inherits:
-
Object
- Object
- Normalizr::RSpec::Matcher::Normalization
- Defined in:
- lib/normalizr/rspec/matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object (also: #negative_failure_message)
- #from(value) ⇒ Object
-
#initialize(attribute) ⇒ Normalization
constructor
A new instance of Normalization.
- #matches?(subject) ⇒ Boolean
- #to(value) ⇒ Object
Constructor Details
#initialize(attribute) ⇒ Normalization
Returns a new instance of Normalization.
11 12 13 14 |
# File 'lib/normalizr/rspec/matcher.rb', line 11 def initialize(attribute) @attribute = attribute @from = '' end |
Instance Method Details
#description ⇒ Object
16 17 18 |
# File 'lib/normalizr/rspec/matcher.rb', line 16 def description "normalize #{@attribute} from #{display(@from)} to #{display(@to)}" end |
#failure_message ⇒ Object
20 21 22 |
# File 'lib/normalizr/rspec/matcher.rb', line 20 def "#{@attribute} did not normalize as expected! #{display(@subject.send(@attribute))} != #{display(@to)}" end |
#failure_message_when_negated ⇒ Object Also known as: negative_failure_message
24 25 26 |
# File 'lib/normalizr/rspec/matcher.rb', line 24 def "expected #{@attribute} to not be normalized from #{display(@from)} to #{display(@to)}" end |
#from(value) ⇒ Object
30 31 32 33 |
# File 'lib/normalizr/rspec/matcher.rb', line 30 def from(value) @from = value self end |
#matches?(subject) ⇒ Boolean
40 41 42 43 44 |
# File 'lib/normalizr/rspec/matcher.rb', line 40 def matches?(subject) @subject = subject @subject.send("#{@attribute}=", @from) @subject.send(@attribute) == @to end |
#to(value) ⇒ Object
35 36 37 38 |
# File 'lib/normalizr/rspec/matcher.rb', line 35 def to(value) @to = value self end |