Sha256: ae15111cf3dc2a8193ca7e7cb1766cec4684cb8174bbd2554f32b7c41c81e094

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe "Exchange::Cache::Base" do
  subject { Exchange::Cache::Base.instance }
  describe "key generation" do
    before(:each) do
      time = Time.gm 2012, 03, 01, 23, 23, 23
      Time.stub! :now => time
    end
    context "with a daily cache" do
      it "should build a timestamped key with the class given, the yearday and the year" do
        subject.send(:key, :xavier_media).should == 'exchange_xavier_media_2012_61'
        subject.send(:key, :currency_bot).should == 'exchange_currency_bot_2012_61'
      end
    end
    context "with an hourly cache" do
      before(:each) do
        Exchange.configuration.cache.expire = :hourly
      end
      after(:each) do
        Exchange.configuration.cache.expire = :daily
      end
      it "should build a timestamped key with the class given, the yearday, the year and the hour" do
        subject.send(:key, :xavier_media).should == 'exchange_xavier_media_2012_61_23'
        subject.send(:key, :currency_bot).should == 'exchange_currency_bot_2012_61_23'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
exchange-0.8.0 spec/exchange/cache/base_spec.rb
exchange-0.6.0 spec/exchange/cache/base_spec.rb