Sha256: 9ebb1f54467d59b5ec4cf1ae83cbcaac8b180c068b389e840abeedb2bdb7397b

Contents?: true

Size: 969 Bytes

Versions: 4

Compression:

Stored size: 969 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe RailsI18nterface::Cache do
  include RailsI18nterface::Cache

  before :each do
    @cachefile = File.expand_path(File.join('..', 'files', 'cache_test'), __FILE__)
  end

  after :each do
    FileUtils.rm @cachefile if File.exists? @cachefile
  end

  it 'stores cache of an object' do
    a = { a: 'a' }
    cache_save a, @cachefile
    File.exists?(@cachefile).should be_true
  end

  it 'reads cache from marshalled file' do
    a = { a: 'a' }
    cache_save a, @cachefile
    b = cache_load @cachefile
    b.should == a
  end

  it 'creates the cache if not present' do
    b = cache_load @cachefile do
      20
    end
    File.exists?(@cachefile).should be_true
    b.should == 20
  end

  it 'creates the cache if not present, using an argument' do
    b = cache_load @cachefile, 'something' do |options|
      options
    end
    File.exists?(@cachefile).should be_true
    b.should == 'something'
  end



end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails-i18nterface-0.2.4 spec/lib/cache_spec.rb
rails-i18nterface-0.2.3 spec/lib/cache_spec.rb
rails-i18nterface-0.2.2 spec/lib/cache_spec.rb
rails-i18nterface-0.2.1 spec/lib/cache_spec.rb