Sha256: 15886ddf8d5ea00ec0a85c6a040f59c40141a4fa058db7e128c5b419617fccc8

Contents?: true

Size: 913 Bytes

Versions: 2

Compression:

Stored size: 913 Bytes

Contents

require File.dirname(__FILE__) + '/../spec_helper'
require 'page_cache'

class PageCache
  cattr_accessor :mock_file_deleter
  def delete_file(path)
    PageCache.mock_file_deleter.delete_file(path)
  end
end

context 'With the fixtures loaded' do
  fixtures :page_caches

  setup do
    @deleter = mock('fdeleter')
    PageCache.mock_file_deleter = @deleter
  end

  specify '#sweep_all catches_all the pages' do
    @deleter.should_receive(:delete_file).once.with(%r{/index\.html$})
    @deleter.should_receive(:delete_file).once.with(%r{/articles/2005/05/05/title$})

    PageCache.count.should == 2
    PageCache.sweep_all
    PageCache.count.should == 0
  end

  specify '#sweep_by_pattern does the right thing' do
    @deleter.should_receive(:delete_file).once.with(%r{/articles/2005/05/05/title$})

    PageCache.count.should == 2
    PageCache.sweep('articles%')
    PageCache.count.should == 1
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typo-4.1.1 spec/models/page_cache_spec.rb
typo-4.1 spec/models/page_cache_spec.rb