Sha256: d738437b4f4eeafdf4b9a96e90f6162bd8cc7528000e4b7e2f4dcd25ab16ebfd

Contents?: true

Size: 1.26 KB

Versions: 26

Compression:

Stored size: 1.26 KB

Contents

require 'lib/filters/modified_filter'
require 'time'

describe ModifiedFilter do
  
  before do
    @path = '/path/to.file'  
    @file = mock('File class')
    @file.should_receive(:mtime).any_number_of_times.with(@path).and_return(Time.parse('2000/01/01'))
  end
  
  it 'should return true if no last modified date set' do
    filter = ModifiedFilter.new(@file)
    
    filter.filter(@path).should be_true
  end
  
  it 'should return false if file modified before given last modified date' do
    last_modified = Time.parse('2000/01/02')
    filter = ModifiedFilter.new(@file, last_modified)
    
    filter.filter(@path).should be_false 
  end
  
  it 'should remember the last modified date on complete method' do
    filter = ModifiedFilter.new(@file)
    filter.filter(@path)
    
    filter.complete
    
    filter.filter(@path).should be_false
  end
  
  it 'should remember the last modified date and recognise changed date on file' do
    @file = mock('File class')
    @file.should_receive(:mtime).with(@path).and_return(Time.parse('2000/01/01'))
    @file.should_receive(:mtime).with(@path).and_return(Time.parse('2000/01/03'))

    filter = ModifiedFilter.new(@file)
    filter.filter(@path)
    
    filter.complete
    
    filter.filter(@path).should be_true
  end
  
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
karl-loris-0.0.10 spec/filters/modified_filter_spec.rb
karl-loris-0.0.11 spec/filters/modified_filter_spec.rb
karl-loris-0.0.9 spec/filters/modified_filter_spec.rb
loris-0.5.2 spec/filters/modified_filter_spec.rb
loris-0.5.1 spec/filters/modified_filter_spec.rb
loris-0.5.0 spec/filters/modified_filter_spec.rb
loris-0.4.1 spec/filters/modified_filter_spec.rb
loris-0.4.0 spec/filters/modified_filter_spec.rb
loris-0.3.2 spec/filters/modified_filter_spec.rb
loris-0.3.1 spec/filters/modified_filter_spec.rb
loris-0.3.0 spec/filters/modified_filter_spec.rb
loris-0.2.3 spec/filters/modified_filter_spec.rb
loris-0.2.2 spec/filters/modified_filter_spec.rb
loris-0.2.1 spec/filters/modified_filter_spec.rb
loris-0.2.0 spec/filters/modified_filter_spec.rb
loris-0.1.7 spec/filters/modified_filter_spec.rb
loris-0.1.5 spec/filters/modified_filter_spec.rb
loris-0.1.4 spec/filters/modified_filter_spec.rb
loris-0.1.3 spec/filters/modified_filter_spec.rb
loris-0.1.2 spec/filters/modified_filter_spec.rb