Sha256: 2edb8252bbe386e7c6c31e5661b404793d45f32640c4acd18dc76cba08d46247

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

require 'right_publish/stores/local'
require 'spec_helper'

describe RightPublish::LocalStorage do

  before(:each) do
    flexmock(RightPublish::Profile) do |obj|
      obj.should_receive(:log).and_return { |str,dbg|
      }

      obj.should_receive(:config).and_return {
        { :verbose=>false,
          :remote_storage=>{:provider=>'s3',:remote_path=>'foo/'},
          :local_storage=>{:provider=>'mocklocal',:cache_dir=>'bar/'}
        }
      }
    end

    fog = flexmock(Fog::Storage)
    fog.should_receive(:new).and_return do
      conn = flexmock('Connection')
      conn.should_receive(:directories).and_return do
        buckets = flexmock('Buckets')
        buckets.should_receive(:get).and_return do
          dir = flexmock('Directory')
          dir.should_receive(:key).and_return('/')
          dir.should_receive(:service).and_return do
            path = flexmock('Path') 
            path.should_receive(:path_to).and_return {|k|k}
            path
          end
          dir
        end
        buckets.should_receive(:create)
        buckets
      end
      conn
    end
  end

  context ".compute_md5" do
    it "uses Digest::MD5 to compute the MD5 sum" do
      file = flexmock('File') do |obj|
        obj.should_receive(:key).once.and_return("filename")
      end

      digest = flexmock(Digest::MD5)
      digest.should_receive(:file).once.and_return(digest)
      digest.should_receive(:hexdigest).once

      dir = RightPublish::LocalStorage.get_directories
      dir.compute_md5(file)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
right_publish-0.3.0 spec/stores/local_spec.rb
right_publish-0.2.1 spec/stores/local_spec.rb
right_publish-0.2.0 spec/stores/local_spec.rb