Class: Bbq::RSpec::Matchers::See::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/bbq/rspec/matchers/see.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Matcher

Returns a new instance of Matcher.



8
9
10
11
# File 'lib/bbq/rspec/matchers/see.rb', line 8

def initialize(text)
  @text = text
  @scope = nil
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



6
7
8
# File 'lib/bbq/rspec/matchers/see.rb', line 6

def scope
  @scope
end

#textObject (readonly)

Returns the value of attribute text.



6
7
8
# File 'lib/bbq/rspec/matchers/see.rb', line 6

def text
  @text
end

Instance Method Details

#descriptionObject



13
14
15
16
17
18
19
# File 'lib/bbq/rspec/matchers/see.rb', line 13

def description
  if scope
    "see #{text} within #{scope}"
  else
    "see #{text}"
  end
end

#does_not_match?(actor) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/bbq/rspec/matchers/see.rb', line 26

def does_not_match?(actor)
  @actual = page_fragment(actor)
  @actual.has_no_text?(text)
end

#failure_message_for_shouldObject Also known as: failure_message



31
32
33
# File 'lib/bbq/rspec/matchers/see.rb', line 31

def failure_message_for_should
  "expected to see \"#{text}\" in #{format(@actual.text)}"
end

#failure_message_for_should_notObject Also known as: failure_message_when_negated



36
37
38
# File 'lib/bbq/rspec/matchers/see.rb', line 36

def failure_message_for_should_not
  "expected not to see \"#{text}\" in #{format(@actual.text)}"
end

#matches?(actor) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/bbq/rspec/matchers/see.rb', line 21

def matches?(actor)
  @actual = page_fragment(actor)
  @actual.has_text?(text)
end

#within(scope) ⇒ Object



41
42
43
44
# File 'lib/bbq/rspec/matchers/see.rb', line 41

def within(scope)
  @scope = scope
  self
end