Sha256: 345e1558910e79d01fc99d4373bf985bb7f2dacc0665ccded76d212414b546f8

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

shared_examples_for 'a name filterable target set' do |target_type, test_data|

  describe 'name filters' do

    it 'should filter by exact name' do
      gs = CQL::Repository.new(test_data[:exact_name][:fixture_location])

      expected_results = test_data[:exact_name][:expected_results]

      expected_results.each do |matched_name, expected|
        result = gs.query do
          select name
          from target_type
          with name matched_name
        end

        expect(result).to eq(expected)
      end
    end

    it 'should filter by regexp' do
      gs = CQL::Repository.new(test_data[:regexp][:fixture_location])

      expected_results = test_data[:regexp][:expected_results]

      expected_results.each do |matched_name, expected|
        result = gs.query do
          select name
          from target_type
          with name matched_name
        end

        expect(result).to match_array(expected)
      end
    end

    it 'can only handle a string or regular expression' do
      gs = CQL::Repository.new(@feature_fixtures_directory)

      expect { gs.query do
        select name
        from scenarios
        with name 7
      end }.to raise_error(ArgumentError, "Can only match a String or Regexp. Got Fixnum.")

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cql-1.2.0 spec/name_filterable_specs.rb
cql-1.1.0 spec/name_filterable_specs.rb
cql-1.0.1 spec/name_filterable_specs.rb