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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rspec_actualObject (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

#descriptionObject



28
29
30
# File 'lib/rspec_html/matchers/base.rb', line 28

def description
  template(:description, @options, @expected)
end

#failure_messageObject



32
33
34
# File 'lib/rspec_html/matchers/base.rb', line 32

def failure_message
  template(:failure, @options, @expected, @actual)
end

#initialize(expected, options) ⇒ Object



23
24
25
26
# File 'lib/rspec_html/matchers/base.rb', line 23

def initialize(expected, options)
  @expected = expected
  @options = options
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, options)
  RSpecHTML::Element.reconstituted(element, options)
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