cache_information_spec.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:1k
源码类别:

Ajax

开发平台:

Others

  1. require File.dirname(__FILE__) + '/../spec_helper'
  2. describe CacheInformation do
  3.   def cache_information(options={})
  4.     CacheInformation.new({:path => '/index.html'}.merge(options))
  5.   end
  6.   it 'should have path attribute' do
  7.     CacheInformation.new.should respond_to(:path)
  8.   end
  9.   it 'should be valid' do
  10.     cache_information.should be_valid
  11.   end
  12.   it 'should not save without path' do
  13.     cache_information(:path => nil).should_not be_valid
  14.   end
  15.   it 'should have path unique' do
  16.     cache_information.save
  17.     cache_information.should_not be_valid
  18.   end
  19.   it 'should destroy file in path when destroy' do
  20.     file_path = create_file_in_spec_public_cache_directory('index.html')
  21.     CacheInformation.create!(:path => '/index.html').destroy
  22.     File.should_not be_exist(file_path)
  23.   end
  24.   it "should destroy himself if path doesn't exist" do
  25.     CacheInformation.create!(:path => '/index.html').destroy
  26.     CacheInformation.find_by_path('/index.html').should be_nil
  27.   end
  28.   it "should logged in warning the path if path doesn't exist" do
  29.     Rails.logger.should_receive(:warn).with("path : /index.html no more exist")
  30.     CacheInformation.create!(:path => '/index.html').destroy
  31.   end
  32. end