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(*args) ⇒ HaveTitle

Returns a new instance of HaveTitle.



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

def initialize(*args)
  @args = args

  # are set just for backwards compatability
  @title = args.first
end

Instance Attribute Details

#failure_messageObject (readonly) Also known as: failure_message_for_should

Returns the value of attribute failure_message.



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

def failure_message
  @failure_message
end

#failure_message_when_negatedObject (readonly) Also known as: failure_message_for_should_not

Returns the value of attribute failure_message_when_negated.



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

def failure_message_when_negated
  @failure_message_when_negated
end

#titleObject (readonly)

Returns the value of attribute title.



93
94
95
# File 'lib/capybara/rspec/matchers.rb', line 93

def title
  @title
end

Instance Method Details

#descriptionObject



118
119
120
# File 'lib/capybara/rspec/matchers.rb', line 118

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

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
114
115
116
# File 'lib/capybara/rspec/matchers.rb', line 111

def does_not_match?(actual)
  wrap(actual).assert_no_title(*@args)
rescue Capybara::ExpectationNotMet => e
  @failure_message_when_negated = e.message
  return false
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


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

def matches?(actual)
  wrap(actual).assert_title(*@args)
rescue Capybara::ExpectationNotMet => e
  @failure_message = e.message
  return false
end