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.



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

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.



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

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)


107
108
109
110
111
112
113
114
115
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 107

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.



121
122
123
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 121

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.



125
126
127
# File 'lib/dommy/rspec/capy_style_matchers.rb', line 125

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)


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

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