Class: Dommy::Rails::RSpec::Matchers::HaveTitle

Inherits:
Object
  • Object
show all
Defined in:
lib/dommy/rails/rspec/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HaveTitle

Returns a new instance of HaveTitle.



192
193
194
# File 'lib/dommy/rails/rspec/matchers.rb', line 192

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



205
206
207
# File 'lib/dommy/rails/rspec/matchers.rb', line 205

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

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


201
202
203
# File 'lib/dommy/rails/rspec/matchers.rb', line 201

def does_not_match?(actual)
  !matches?(actual)
end

#failure_messageObject



209
210
211
# File 'lib/dommy/rails/rspec/matchers.rb', line 209

def failure_message
  "expected title to match #{@expected.inspect}, got #{@document.title.inspect}"
end

#failure_message_when_negatedObject



213
214
215
# File 'lib/dommy/rails/rspec/matchers.rb', line 213

def failure_message_when_negated
  "expected title not to match #{@expected.inspect}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


196
197
198
199
# File 'lib/dommy/rails/rspec/matchers.rb', line 196

def matches?(actual)
  @document = MatchTarget.document(actual)
  Dommy::Rails::PageInspector.title_matches?(@document, @expected)
end