Class: Capybara::RSpecMatchers::HaveTitle

Inherits:
Matcher
  • Object
show all
Defined in:
lib/capybara/rspec/matchers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Matcher

#wrap

Constructor Details

#initialize(title) ⇒ HaveTitle

Returns a new instance of HaveTitle.



81
82
83
# File 'lib/capybara/rspec/matchers.rb', line 81

def initialize(title)
  @title = title
end

Instance Attribute Details

#titleObject (readonly)

Returns the value of attribute title.



79
80
81
# File 'lib/capybara/rspec/matchers.rb', line 79

def title
  @title
end

Instance Method Details

#descriptionObject



107
108
109
# File 'lib/capybara/rspec/matchers.rb', line 107

def description
  "have title #{title.inspect}"
end

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
93
# File 'lib/capybara/rspec/matchers.rb', line 90

def does_not_match?(actual)
  @actual = wrap(actual)
  @actual.has_no_title?(title)
end

#failure_messageObject Also known as: failure_message_for_should



95
96
97
# File 'lib/capybara/rspec/matchers.rb', line 95

def failure_message
  "expected there to be title #{title.inspect} in #{@actual.title.inspect}"
end

#failure_message_when_negatedObject Also known as: failure_message_for_should_not



99
100
101
# File 'lib/capybara/rspec/matchers.rb', line 99

def failure_message_when_negated
  "expected there not to be title #{title.inspect} in #{@actual.title.inspect}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
88
# File 'lib/capybara/rspec/matchers.rb', line 85

def matches?(actual)
  @actual = wrap(actual)
  @actual.has_title?(title)
end