Sha256: 8ec403ddea2a6d686308902359f9068fb8cf34fd2e653febd89f36b5f5fb80cb
Contents?: true
Size: 1.03 KB
Versions: 15
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true require 'capybara/selector/filter' module Capybara class Selector class FilterSet attr_reader :descriptions def initialize(name, &block) @name = name @descriptions = [] instance_eval(&block) end def filter(name, *types_and_options, &block) options = types_and_options.last.is_a?(Hash) ? types_and_options.pop.dup : {} types_and_options.each { |k| options[k] = true} filters[name] = Filter.new(name, block, options) end def describe(&block) descriptions.push block end def description(options={}) @descriptions.map {|desc| desc.call(options).to_s }.join end def filters @filters ||= {} end class << self def all @filter_sets ||= {} end def add(name, &block) all[name.to_sym] = FilterSet.new(name.to_sym, &block) end def remove(name) all.delete(name.to_sym) end end end end end
Version data entries
15 entries across 14 versions & 3 rubygems