Sha256: 9d6d2ad27ee1edbf34e3216677d43aa4eed9cf27202d54a9f1927cd33414265e

Contents?: true

Size: 1.41 KB

Versions: 135

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'
require 'chef/cookbook_loader'
require 'chef/cookbook_uploader'
require 'chef/cookbook_site_streaming_uploader'
require 'dpl/provider/chef_supermarket'

describe DPL::Provider::ChefSupermarket do
  subject :provider do
    described_class.new(
      DummyContext.new,
      app: 'example',
      cookbook_category: 'Others',
      user_id: 'user',
      client_key: '/tmp/example.pem'
    )
  end

  let(:cookbook_uploader) do
    double('cookbook_uploader', validate_cookbooks: true)
  end

  let(:http_resp) do
    double('http_resp', body: '{}', code: '201')
  end

  describe "#check_auth" do
    example do
      ::File.stub(:exist?).and_return(true)
      expect(File).to receive(:exist?)
      provider.check_auth
    end
  end

  describe "#check_app" do
    example do
      ::Chef::CookbookLoader.any_instance.stub(:[]).and_return nil
      expect(::Chef::CookbookUploader).to receive(:new).and_return(cookbook_uploader)
      provider.check_app
    end
  end

  describe "#push_app" do
    example do
      expect(::Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return('/tmp/build_dir')
      expect(provider).to receive(:system).and_return(true)
      expect(::File).to receive(:open)
      expect(::Chef::CookbookSiteStreamingUploader).to receive(:post).and_return(http_resp)
      expect(::FileUtils).to receive(:rm_rf).with('/tmp/build_dir')
      provider.push_app
    end
  end
end

Version data entries

135 entries across 135 versions & 1 rubygems

Version Path
dpl-chef_supermarket-1.10.17.travis.6637.6 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.16 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.16.travis.6625.6 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.16.travis.6619.6 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.16.travis.5961.5 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.15 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.15.travis.5877.5 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.14 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.13 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.13.travis.4159.5 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.13.travis.4141.5 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.13.travis.4040.5 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.13.travis.4033.5 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.12 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.12.travis.4032.5 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.12.travis.3794.5 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.12.travis.3506.5 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.11.travis.3504.5 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.11 spec/provider/chef_supermarket_spec.rb
dpl-chef_supermarket-1.10.11.travis.3499.5 spec/provider/chef_supermarket_spec.rb