Module: RSpecHTML::Matchers::Base
- Included in:
- ContainTag, MatchText
- Defined in:
- lib/rspec_html/matchers/base.rb
Overview
Mix-in class to provide a uniform interface and message templating for all matchers.
Instance Attribute Summary collapse
-
#rspec_actual ⇒ Object
readonly
Returns the value of attribute rspec_actual.
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #initialize(expected, options) ⇒ Object
- #pluralize(number, string) ⇒ Object
- #reconstituted(element, options) ⇒ Object
- #save_actual(actual) ⇒ Object
Instance Attribute Details
#rspec_actual ⇒ Object (readonly)
Returns the value of attribute rspec_actual.
21 22 23 |
# File 'lib/rspec_html/matchers/base.rb', line 21 def rspec_actual @rspec_actual end |
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rspec_html/matchers/base.rb', line 7 def self.included(base) base.class_eval do class << self def diffable @diffable = true end def diffable? @diffable end end end end |
Instance Method Details
#description ⇒ Object
28 29 30 |
# File 'lib/rspec_html/matchers/base.rb', line 28 def description template(:description, , @expected) end |
#failure_message ⇒ Object
32 33 34 |
# File 'lib/rspec_html/matchers/base.rb', line 32 def template(:failure, , @expected, @actual) end |
#initialize(expected, options) ⇒ Object
23 24 25 26 |
# File 'lib/rspec_html/matchers/base.rb', line 23 def initialize(expected, ) @expected = expected = end |
#pluralize(number, string) ⇒ Object
45 46 47 48 49 |
# File 'lib/rspec_html/matchers/base.rb', line 45 def pluralize(number, string) return "#{number} #{string}" if number == 1 "#{number} #{string}s" end |
#reconstituted(element, options) ⇒ Object
41 42 43 |
# File 'lib/rspec_html/matchers/base.rb', line 41 def reconstituted(element, ) RSpecHTML::Element.reconstituted(element, ) end |
#save_actual(actual) ⇒ Object
36 37 38 39 |
# File 'lib/rspec_html/matchers/base.rb', line 36 def save_actual(actual) @actual = actual self end |