Sha256: 4967658ea280b6ba63bbbdf5b8b71675027cdc37dc7f007d773009d0c6726209

Contents?: true

Size: 1.56 KB

Versions: 25

Compression:

Stored size: 1.56 KB

Contents

require 'rake'
require 'spec_helper'
require 'speckle/list/pattern_filter'
require 'securerandom'

module Speckle
  module List

    describe 'PatternFilter' do

      before :each do 
        @filter = PatternFilter.new('^lorem')
      end

      it 'can be run' do
        expect(@filter).to respond_to(:run)
      end

      it 'returns an array on run' do
        result = @filter.run('foobar')

        expect(result).to be_kind_of(Array)
      end

      it 'returns empty array for a mismatched pattern', :a => true do
        result = @filter.run('foobar')
        expect(result).to be_empty
      end

      it 'returns passed filename if it matches pattern', :b => true do
        @filter = PatternFilter.new('pattern_filter')
        result = @filter.run(__FILE__)
        expect(result).to eq([__FILE__])
      end

      it 'returns empty array if file does not match pattern' do
        @filter = PatternFilter.new('loremipsumdolorsitamet')
        result = @filter.run("#{Dir.pwd}/spec/spec_helper.rb")
        expect(result).to eq([])
      end

      it 'returns empty array if it has content with invert flag', :d => true do
        @filter = PatternFilter.new('pattern_filter', true)
        result = @filter.run(__FILE__)
        expect(result).to eq([])
      end

      it 'returns array with passed item if file does not match pattern with invert flag' do
        @filter = FileContentFilter.new('loremipsumdolorsitamet', true)
        file = "#{Dir.pwd}/spec/spec_helper.rb"
        result = @filter.run(file)
        expect(result).to eq([file])
      end

    end

  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
speckle-0.1.12 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.11 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.10 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.9 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.8 spec/speckle/list/pattern_filter_spec.rb