Sha256: d918651ea7597e64707f60406469cd49196250307f89ce32d8a1c66955355fbc

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

require "#{File.dirname(__FILE__)}/spec_helper"


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

  describe 'line match filters' do

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

      expected_results = test_data[:exact_line][:expected_results]

      expected_results.each do |matched_line, expected|
        result = gs.query do
          select name
          from target_type
          with line matched_line
        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_line, expected|
        result = gs.query do
          select name
          from target_type
          with line matched_line
        end

        expect(result).to eq(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 line 7
      end }.to raise_error(ArgumentError, /^Can only match a String or Regexp. Got (?:Fixnum|Integer)\.$/)

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cql-1.4.2 testing/rspec/spec/line_filterable_specs.rb
cql-1.4.1 testing/rspec/spec/line_filterable_specs.rb
cql-1.4.0 testing/rspec/spec/line_filterable_specs.rb