Sha256: de66c8fd6472228c9232f5e0f9ba7c7d4f0b1cc4ab637a4e16ca213e13aeb790

Contents?: true

Size: 1.27 KB

Versions: 10

Compression:

Stored size: 1.27 KB

Contents

RSpec.describe RuboCop::RSpec::Language::SelectorSet do
  subject(:selector_set) { described_class.new(%i[foo bar]) }

  it 'composes sets' do
    combined = selector_set + described_class.new(%i[baz])

    expect(combined).to eq(described_class.new(%i[foo bar baz]))
  end

  it 'compares by value' do
    expect(selector_set).not_to eq(described_class.new(%i[foo bar baz]))
  end

  describe '#include?' do
    it 'returns false for selectors not in the set' do
      expect(selector_set.include?(:baz)).to be(false)
    end

    it 'returns true for selectors in the set' do
      expect(selector_set.include?(:foo)).to be(true)
    end
  end

  describe '#node_pattern' do
    it 'builds a node pattern' do
      expect(selector_set.node_pattern).to eql(':foo :bar')
    end
  end

  describe '#node_pattern_union' do
    it 'builds a node pattern union' do
      expect(selector_set.node_pattern_union).to eql('{:foo :bar}')
    end
  end

  describe '#send_pattern' do
    it 'builds a send matching pattern' do
      expect(selector_set.send_pattern).to eql('(send _ {:foo :bar} ...)')
    end
  end

  describe '#block_pattern' do
    it 'builds a block matching pattern' do
      expect(selector_set.block_pattern).to eql(
        '(block (send _ {:foo :bar} ...) ...)'
      )
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rubocop-rspec-1.25.1 spec/rubocop/rspec/language/selector_set_spec.rb
rubocop-rspec-1.25.0 spec/rubocop/rspec/language/selector_set_spec.rb
rubocop-rspec-1.24.0 spec/rubocop/rspec/language/selector_set_spec.rb
rubocop-rspec-1.23.0 spec/rubocop/rspec/language/selector_set_spec.rb
rubocop-rspec-1.22.2 spec/rubocop/rspec/language/selector_set_spec.rb
rubocop-rspec-1.22.1 spec/rubocop/rspec/language/selector_set_spec.rb
rubocop-rspec-1.22.0 spec/rubocop/rspec/language/selector_set_spec.rb
rubocop-rspec-1.21.0 spec/rubocop/rspec/language/selector_set_spec.rb
rubocop-rspec-1.20.1 spec/rubocop/rspec/language/selector_set_spec.rb
rubocop-rspec-1.20.0 spec/rubocop/rspec/language/selector_set_spec.rb