class Normalizr::RSpec::Matcher::Normalization
Public Class Methods
new(attribute)
click to toggle source
# File lib/normalizr/rspec/matcher.rb, line 11 def initialize(attribute) @attribute = attribute @from = '' end
Public Instance Methods
description()
click to toggle source
# File lib/normalizr/rspec/matcher.rb, line 16 def description "normalize #{@attribute} from #{display(@from)} to #{display(@to)}" end
failure_message()
click to toggle source
# File lib/normalizr/rspec/matcher.rb, line 20 def failure_message "#{@attribute} did not normalize as expected! #{display(@subject.send(@attribute))} != #{display(@to)}" end
failure_message_when_negated()
click to toggle source
# File lib/normalizr/rspec/matcher.rb, line 24 def failure_message_when_negated "expected #{@attribute} to not be normalized from #{display(@from)} to #{display(@to)}" end
Also aliased as: negative_failure_message
from(value)
click to toggle source
# File lib/normalizr/rspec/matcher.rb, line 30 def from(value) @from = value self end
matches?(subject)
click to toggle source
# File lib/normalizr/rspec/matcher.rb, line 40 def matches?(subject) @subject = subject @subject.send("#{@attribute}=", @from) @subject.send(@attribute) == @to end
to(value)
click to toggle source
# File lib/normalizr/rspec/matcher.rb, line 35 def to(value) @to = value self end
Protected Instance Methods
display(value)
click to toggle source
# File lib/normalizr/rspec/matcher.rb, line 48 def display(value) value.nil? ? 'nil' : "\"#{value}\"" end