Sha256: 24af32c0465c8ed0c4b07e4bbdc8e23f367bf5f8fb9c9c951850ea949b70e90f

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

require "#{File.dirname(__FILE__)}/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(CQL_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|Integer)\.$/)

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cql-1.7.0 testing/rspec/spec/name_filterable_specs.rb
cql-1.6.0 testing/rspec/spec/name_filterable_specs.rb
cql-1.5.1 testing/rspec/spec/name_filterable_specs.rb
cql-1.5.0 testing/rspec/spec/name_filterable_specs.rb