Sha256: 3326c70afac9e0eda418a10cccde3df2a4348082858dac74d10548dc7898c78d

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

describe GithubBitbucketDeployer do
  it { is_expected.to respond_to(:configuration) }
  it { is_expected.to respond_to(:configure) }
  it { is_expected.to respond_to(:deploy) }

  describe ".configuration" do
    subject(:config) { GithubBitbucketDeployer.configuration }

    it "should be the configuration object" do
      expect(config).to be_a_kind_of(GithubBitbucketDeployer::Configuration)
    end

    it "give a new instance if non defined" do
      GithubBitbucketDeployer.configuration = nil
      expect(config).to be_a_kind_of(GithubBitbucketDeployer::Configuration)
    end
  end

  describe ".configure" do
    it "should yield the configuration object" do
      GithubBitbucketDeployer.configure do |config|
        expect(config).to equal(GithubBitbucketDeployer.configuration)
      end
    end
  end

  describe "::deploy" do
    subject(:deploy) { GithubBitbucketDeployer.deploy }

    context "when unconfigured" do
      before :each do
        GithubBitbucketDeployer.configure do |config|
          config.id_rsa = nil
        end
      end

      it "requires github_repo to be set" do
        expect { deploy }.to raise_error(GithubBitbucketDeployer::ConfigurationException)
      end
    end

    # TODO: how can I test these better?
    context "when configured" do
      before :each do
        @deployer = double("github_bitbucket_deployer")
        allow(@deployer).to receive(:deploy).and_return(true)
      end

      it "overrides defaults" do
        GithubBitbucketDeployer.configure do |config|
          config.id_rsa = ""
        end

        override = 'override-value'
        expect(@deployer.deploy(id_rsa: override)).to be true
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
github_bitbucket_deployer-1.0.1 spec/lib/github_bitbucket_deployer_spec.rb
github_bitbucket_deployer-1.0.0 spec/lib/github_bitbucket_deployer_spec.rb