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