Sha256: 09f1227e11acf0490c6f780a4e411556740b1df0b05558817faafbd5f415e18e

Contents?: true

Size: 1.52 KB

Versions: 19

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'
require 'pry'

describe Alephant::Cache do
  let(:id)   { :id }
  let(:path) { :path }
  let(:data) { :data }
  subject { Alephant::Cache }

  describe "initialize(id, path)" do
    it "sets and exposes id, path instance variables " do
      instance = subject.new(id, path)
      expect(instance.id).to eq(id)
      expect(instance.path).to eq(path)
    end

    it "sets bucket instance variable as S3 bucket with id" do
      instance = subject.new(id, path)

      expect(instance.bucket).to be_an AWS::S3::Bucket
      expect(instance.bucket.name).to eq('id')
    end
  end

  describe "put(id, data)" do
    it "sets bucket path/id content data" do
      s3_object_collection = double()
      s3_object_collection.should_receive(:write).with(:data)

      s3_bucket = double()
      s3_bucket.should_receive(:objects).and_return(
        {
          "path/id" => s3_object_collection
        }
      )

      AWS::S3.any_instance.stub(:buckets).and_return({ id => s3_bucket })
      instance = subject.new(id, path)

      instance.put(id, data);
    end
  end

  describe "get(id)" do
    it "gets bucket path/id content data" do
      s3_object_collection = double()
      s3_object_collection.should_receive(:read)

      s3_bucket = double()
      s3_bucket.should_receive(:objects).and_return(
        {
          "path/id" => s3_object_collection
        }
      )

      AWS::S3.any_instance.stub(:buckets).and_return({ id => s3_bucket })

      instance = subject.new(id, path)
      instance.get(id);
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
alephant-0.0.9.9.1-java spec/cache_spec.rb
alephant-cache-0.0.2 spec/cache_spec.rb
alephant-cache-0.0.1 spec/cache_spec.rb
alephant-0.0.9.9-java spec/cache_spec.rb
alephant-0.0.9.8-java spec/cache_spec.rb
alephant-0.0.9.7-java spec/cache_spec.rb
alephant-0.0.9.6-java spec/cache_spec.rb
alephant-0.0.9.5-java spec/cache_spec.rb
alephant-0.0.9.4-java spec/cache_spec.rb
alephant-0.0.9.3-java spec/cache_spec.rb
alephant-0.0.9.2-java spec/cache_spec.rb
alephant-0.0.9.1-java spec/cache_spec.rb
alephant-0.0.9-java spec/cache_spec.rb
alephant-0.0.8.2-java spec/cache_spec.rb
alephant-0.0.8.1-java spec/cache_spec.rb
alephant-0.0.8-java spec/cache_spec.rb
alephant-0.0.7-java spec/cache_spec.rb
alephant-0.0.6-java spec/cache_spec.rb
alephant-0.0.5-java spec/cache_spec.rb