Class: Utensils::CustomMatchers::HaveModel

Inherits:
Object
  • Object
show all
Defined in:
lib/utensils/custom_matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ HaveModel

Returns a new instance of HaveModel.



4
5
6
# File 'lib/utensils/custom_matchers.rb', line 4

def initialize(model)
  @model_id = ApplicationController.helpers.dom_id(model)
end

Instance Method Details

#failure_messageObject



13
14
15
# File 'lib/utensils/custom_matchers.rb', line 13

def failure_message
  "expected #{@page.body} to contain element with id: #{@model_id}"
end

#failure_message_when_negatedObject



17
18
19
# File 'lib/utensils/custom_matchers.rb', line 17

def failure_message_when_negated
  "expected #{@page.body} to not contain element with id: #{@model_id}"
end

#matches?(page) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/utensils/custom_matchers.rb', line 8

def matches?(page)
  @page = page
  @page.has_css?("##{@model_id}")
end