module Capybara::Compose
Internal: Global configuration for the library.
Constants
- Config
Internal: Struct for configuration.
- DEFAULT_CONFIGURATION
- METHODS_EXPECTING_A_HASH
Internal: Ruby 2.7 swallows keyword arguments, so for methods that take a Hash as the first argument as well as keyword arguments, we need to manually detect and move them to args if empty.
- RESERVED_METHODS
Internal: Methods that should not be overiden or used as locator aliases to avoid confusion while working on test helpers.
- SKIPPED_DSL_METHODS
Internal: Methods that are in the
Capybara
DSL but are so common that we don't want to issue a warning if they are used as selectors.- VERSION
Public Class Methods
config() { |config| ... }
click to toggle source
Public: Returns the current configuration for the test helpers.
# File lib/capybara/compose.rb, line 52 def self.config @config ||= Config.new(*DEFAULT_CONFIGURATION.values) yield @config if block_given? @config end
define_helper_method(klass, method_name, wrap: false, assertion: false, target: 'current_context', return_self: assertion, inject_test_helper: true)
click to toggle source
Internal: Allows to define methods that are a part of the Capybara
DSL, as well as RSpec matchers.
# File lib/capybara/compose.rb, line 60 def self.define_helper_method(klass, method_name, wrap: false, assertion: false, target: 'current_context', return_self: assertion, inject_test_helper: true) klass.class_eval <<~HELPER, __FILE__, __LINE__ + 1 def #{ method_name }(*args, **kwargs, &filter) #{ 'args.push(kwargs) && (kwargs = {}) if args.empty?' if METHODS_EXPECTING_A_HASH.include?(method_name) } #{ 'kwargs[:test_helper] = self' if inject_test_helper } #{ 'wrap_element ' if wrap }#{ assertion ? "expect(#{ target }).to_or not_to, test_context" : target }.#{ method_name }(*args, **kwargs, &filter) #{ 'self' if return_self } end HELPER end