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.2.0 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.31 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.30 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.29 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.28 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.27 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.26 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.25 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.24 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.23 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.22 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.21 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.20 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.19 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.18 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.17 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.16 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.15 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.14 spec/speckle/list/pattern_filter_spec.rb
speckle-0.1.13 spec/speckle/list/pattern_filter_spec.rb