Class: Dommy::Rails::RSpec::Matchers::HaveSelect

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

Instance Method Summary collapse

Constructor Details

#initialize(name, label:, count:) ⇒ HaveSelect

Returns a new instance of HaveSelect.



391
392
393
394
395
# File 'lib/dommy/rails/rspec/matchers.rb', line 391

def initialize(name, label:, count:)
  @name = name
  @label = label
  @count = count
end

Instance Method Details

#descriptionObject



406
407
408
# File 'lib/dommy/rails/rspec/matchers.rb', line 406

def description
  "have select"
end

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


402
403
404
# File 'lib/dommy/rails/rspec/matchers.rb', line 402

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

#failure_messageObject



410
411
412
# File 'lib/dommy/rails/rspec/matchers.rb', line 410

def failure_message
  "expected to find select, found #{@matched.size}"
end

#failure_message_when_negatedObject



414
415
416
# File 'lib/dommy/rails/rspec/matchers.rb', line 414

def failure_message_when_negated
  "expected not to find select, found #{@matched.size}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


397
398
399
400
# File 'lib/dommy/rails/rspec/matchers.rb', line 397

def matches?(actual)
  @matched = Dommy::Rails::PageInspector.selects(MatchTarget.document(actual), name: @name, label: @label)
  Dommy::Internal::DomMatching.count_matches?(@matched.size, @count)
end