Class: CapitalizeAttributes::Matchers::CapitalizeAttributeMatcher
- Inherits:
-
Object
- Object
- CapitalizeAttributes::Matchers::CapitalizeAttributeMatcher
- Defined in:
- lib/capitalize_attributes/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
-
#failure_message ⇒ Object
(also: #failure_message_for_should)
RSpec 3.x.
-
#failure_message_when_negated ⇒ Object
(also: #failure_message_for_should_not, #negative_failure_message)
RSpec 3.x.
-
#initialize(attributes) ⇒ CapitalizeAttributeMatcher
constructor
A new instance of CapitalizeAttributeMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attributes) ⇒ CapitalizeAttributeMatcher
Returns a new instance of CapitalizeAttributeMatcher.
17 18 19 20 |
# File 'lib/capitalize_attributes/matchers.rb', line 17 def initialize(attributes) @attributes = attributes @options = {} end |
Instance Method Details
#description ⇒ Object
44 45 46 |
# File 'lib/capitalize_attributes/matchers.rb', line 44 def description "capitalize #{@attributes.map { |el| "##{el}" }.to_sentence}" end |
#failure_message ⇒ Object Also known as: failure_message_for_should
RSpec 3.x
31 32 33 |
# File 'lib/capitalize_attributes/matchers.rb', line 31 def # RSpec 3.x "Expected #{@attribute} to be capitalized, but it was not" end |
#failure_message_when_negated ⇒ Object Also known as: failure_message_for_should_not, negative_failure_message
RSpec 3.x
37 38 39 |
# File 'lib/capitalize_attributes/matchers.rb', line 37 def # RSpec 3.x "Expected #{@attribute} not to be capitalized, but it was" end |
#matches?(subject) ⇒ Boolean
22 23 24 25 26 27 28 29 |
# File 'lib/capitalize_attributes/matchers.rb', line 22 def matches?(subject) @attributes.all? do |attribute| @attribute = attribute subject.send("#{@attribute}=", "string") subject.validate subject.send(@attribute) == "String" end end |