Sha256: e443f0cfbcd0704f7fcf793ec63ee5bdb0546f9a5b07187cd2a9304ae4fe817b

Contents?: true

Size: 1.88 KB

Versions: 56

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'
require 'dpl/provider/cloud_files'
require 'fog'

describe DPL::Provider::CloudFiles do
  before :each do
    Fog.mock!
  end

  subject :provider do
    described_class.new(DummyContext.new, :username => 'username', :api_key => 'api key', :container => 'travis', :region => 'dfw')
  end

  describe :needs_key? do
    example do
      provider.needs_key?.should == false
    end
  end

  describe :api do
    example do
      Fog::Storage.should_receive(:new).with(:provider => 'Rackspace', :rackspace_username => 'username', :rackspace_api_key => 'api key', :rackspace_region => 'dfw')

      provider.api
    end
  end

  describe :check_auth do
    example do
      provider.should_receive(:log).with('Authenticated as username')

      provider.check_auth
    end
  end

  describe :push_app do
    let :files do
      files = double

      directory = double
      directory.stub(:files) { files }

      directories = double
      directories.should_receive(:get).with('travis').and_return(directory)

      service = double(:service)
      service.stub(:directories) { directories }
      provider.stub(:api) { service }

      files
    end

    example do
      files.should_receive(:create).with(:key => 'a', :body => 'a body')
      files.should_receive(:create).with(:key => 'b', :body => 'b body')
      files.should_receive(:create).with(:key => 'c', :body => 'c body')

      Dir.should_receive(:glob).with('**/*').and_return(['a', 'b', 'c'])
      File.stub(:open) { |name| "#{name} body" }

      provider.push_app
    end
  end

  describe :deploy do
    example 'Not Found' do
      directories = double
      directories.stub(:get) { nil }

      service = double(:service)
      service.stub(:directories) { directories }
      provider.stub(:api) { service }

      expect { provider.deploy }.to raise_error(DPL::Error, 'The specified container does not exist.')
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
dpl-1.6.1.travis.447.1 spec/provider/cloud_files_spec.rb
dpl-1.6.0 spec/provider/cloud_files_spec.rb
dpl-1.5.11.travis.445.1 spec/provider/cloud_files_spec.rb
dpl-1.5.11.travis.437.1 spec/provider/cloud_files_spec.rb
dpl-1.5.11.travis.436.1 spec/provider/cloud_files_spec.rb
dpl-1.5.11.travis.435.1 spec/provider/cloud_files_spec.rb
dpl-1.5.11.travis.432.1 spec/provider/cloud_files_spec.rb
dpl-1.5.11.travis.430.1 spec/provider/cloud_files_spec.rb
dpl-1.5.11.travis.414.1 spec/provider/cloud_files_spec.rb
dpl-1.5.10 spec/provider/cloud_files_spec.rb
dpl-1.5.10.travis.413.1 spec/provider/cloud_files_spec.rb
dpl-1.5.10.travis.402.1 spec/provider/cloud_files_spec.rb
dpl-1.6.0.travis.399.1 spec/provider/cloud_files_spec.rb
dpl-1.5.9 spec/provider/cloud_files_spec.rb
dpl-1.5.9.travis.397.1 spec/provider/cloud_files_spec.rb
dpl-1.5.9.travis.394.1 spec/provider/cloud_files_spec.rb
dpl-1.5.9.travis.393.1 spec/provider/cloud_files_spec.rb
dpl-1.5.9.travis.390.1 spec/provider/cloud_files_spec.rb
dpl-1.5.9.travis.373.1 spec/provider/cloud_files_spec.rb
dpl-1.5.9.travis.372.1 spec/provider/cloud_files_spec.rb