Class: Dommy::RSpec::CapyStyleMatchers::Base Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Direct Known Subclasses

HaveButton, HaveField, HaveLink, HaveSelector

Instance Method Summary collapse

Constructor Details

#initialize(selector, **opts) ⇒ Base

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Base.



83
84
85
86
87
88
89
90
91
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 83

def initialize(selector, **opts)
  @selector = selector
  @text = opts[:text] || opts[:content]
  @count = opts[:count]
  @exact = opts[:exact] || opts[:exact_text]
  @visible = opts.fetch(:visible, :visible)
  # :wait is accepted for Capybara compatibility but ignored
  # (Dommy is synchronous).
end

Instance Method Details

#descriptionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



109
110
111
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 109

def description
  "have #{describe_target}"
end

#does_not_match?(scope) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


99
100
101
102
103
104
105
106
107
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 99

def does_not_match?(scope)
  @scope = Internal::ScopeResolution.resolve(scope)
  @matched = find_matches(@scope)
  if @count
    !count_ok?(@matched.size)
  else
    @matched.empty?
  end
end

#failure_messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



113
114
115
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 113

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

#failure_message_when_negatedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



117
118
119
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 117

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

#matches?(scope) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


93
94
95
96
97
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 93

def matches?(scope)
  @scope = Internal::ScopeResolution.resolve(scope)
  @matched = find_matches(@scope)
  count_ok?(@matched.size)
end