Class: StripAttributes::Matchers::StripAttributeMatcher
- Inherits:
-
Object
- Object
- StripAttributes::Matchers::StripAttributeMatcher
- Defined in:
- lib/strip_attributes/matchers.rb
Instance Method Summary collapse
- #collapse_spaces ⇒ Object
- #description ⇒ Object
- #failure_message_for_should ⇒ Object (also: #failure_message)
- #failure_message_for_should_not ⇒ Object (also: #negative_failure_message)
-
#initialize(attribute) ⇒ StripAttributeMatcher
constructor
A new instance of StripAttributeMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attribute) ⇒ StripAttributeMatcher
Returns a new instance of StripAttributeMatcher.
20 21 22 23 |
# File 'lib/strip_attributes/matchers.rb', line 20 def initialize(attribute) @attribute = attribute @options = {} end |
Instance Method Details
#collapse_spaces ⇒ Object
31 32 33 34 |
# File 'lib/strip_attributes/matchers.rb', line 31 def collapse_spaces @options[:collapse_spaces] = true self end |
#description ⇒ Object
46 47 48 |
# File 'lib/strip_attributes/matchers.rb', line 46 def description "#{expectation(false)} whitespace from ##{@attribute}" end |
#failure_message_for_should ⇒ Object Also known as: failure_message
36 37 38 |
# File 'lib/strip_attributes/matchers.rb', line 36 def "Expected whitespace to be #{expectation} from ##{@attribute}, but it was not" end |
#failure_message_for_should_not ⇒ Object Also known as: negative_failure_message
41 42 43 |
# File 'lib/strip_attributes/matchers.rb', line 41 def "Expected whitespace to remain on ##{@attribute}, but it was #{expectation}" end |
#matches?(subject) ⇒ Boolean
25 26 27 28 29 |
# File 'lib/strip_attributes/matchers.rb', line 25 def matches?(subject) subject.send("#{@attribute}=", " string ") subject.valid? subject.send(@attribute) == "string" and collapse_spaces?(subject) end |