Sha256: ed89d0564f71a878353dade6bd2e44cbc55fbb25c72c7173296cb9f128c64447

Contents?: true

Size: 1.46 KB

Versions: 44

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Capybara::Selector::FilterSet do
  after do
    Capybara::Selector::FilterSet.remove(:test)
  end

  it 'allows node filters' do
    fs = Capybara::Selector::FilterSet.add(:test) do
      node_filter(:node_test, :boolean) { |_node, _value| true }
      expression_filter(:expression_test, :boolean) { |_expr, _value| true }
    end

    expect(fs.node_filters.keys).to include(:node_test)
    expect(fs.node_filters.keys).not_to include(:expression_test)
  end

  it 'allows expression filters' do
    fs = Capybara::Selector::FilterSet.add(:test) do
      node_filter(:node_test, :boolean) { |_node, _value| true }
      expression_filter(:expression_test, :boolean) { |_expr, _value| true }
    end

    expect(fs.expression_filters.keys).to include(:expression_test)
    expect(fs.expression_filters.keys).not_to include(:node_test)
  end

  it 'allows node filter and expression filter with the same name' do
    fs = Capybara::Selector::FilterSet.add(:test) do
      node_filter(:test, :boolean) { |_node, _value| true }
      expression_filter(:test, :boolean) { |_expr, _value| true }
    end

    expect(fs.expression_filters[:test]).not_to eq fs.node_filters[:test]
  end

  it 'allows `filter` as an alias of `node_filter`' do
    fs = Capybara::Selector::FilterSet.add(:test) do
      filter(:node_test, :boolean) { |_node, _value| true }
    end

    expect(fs.node_filters.keys).to include(:node_test)
  end
end

Version data entries

44 entries across 43 versions & 2 rubygems

Version Path
capybara-3.26.0 spec/filter_set_spec.rb
capybara-3.25.0 spec/filter_set_spec.rb
capybara-3.24.0 spec/filter_set_spec.rb
capybara-3.23.0 spec/filter_set_spec.rb
capybara-3.22.0 spec/filter_set_spec.rb
capybara-3.21.0 spec/filter_set_spec.rb
capybara-3.20.2 spec/filter_set_spec.rb
capybara-3.20.1 spec/filter_set_spec.rb
capybara-3.20.0 spec/filter_set_spec.rb
capybara-3.19.1 spec/filter_set_spec.rb
capybara-3.19.0 spec/filter_set_spec.rb
capybara-3.18.0 spec/filter_set_spec.rb
capybara-3.15.1 spec/filter_set_spec.rb
capybara-3.17.0 spec/filter_set_spec.rb
capybara-3.16.2 spec/filter_set_spec.rb
tdiary-5.0.13 vendor/bundle/gems/capybara-3.15.0/spec/filter_set_spec.rb
capybara-3.16.1 spec/filter_set_spec.rb
tdiary-5.0.12.1 vendor/bundle/gems/capybara-3.15.0/spec/filter_set_spec.rb
capybara-3.16.0 spec/filter_set_spec.rb
capybara-3.15.0 spec/filter_set_spec.rb