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.



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

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.



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

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.



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

def failure_message_when_negated
  @failure_message_when_negated
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#descriptionObject



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

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

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


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

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)


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

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