Sha256: 35d17a21d85b0f446c5246eead2db56c8bcec6c8627e3f1638b574b28011b1ed

Contents?: true

Size: 1.37 KB

Versions: 148

Compression:

Stored size: 1.37 KB

Contents

describe KnapsackPro::Crypto::BranchEncryptor do
  let(:branch) { 'feature-branch' }
  let(:encryptor) { described_class.new(branch) }

  describe '.call' do
    subject { described_class.call(branch) }

    before do
      expect(KnapsackPro::Config::Env).to receive(:branch_encrypted?).and_return(branch_encrypted?)
    end

    context 'when branch encrypted flag enabled' do
      let(:branch_encrypted?) { true }
      let(:encryptor) { instance_double(described_class) }

      it do
        expect(described_class).to receive(:new).with(branch).and_return(encryptor)
        result = double
        expect(encryptor).to receive(:call).and_return(result)

        expect(subject).to eq result
      end
    end

    context 'when test files encrypted flag disabled' do
      let(:branch_encrypted?) { false }

      it { should eq branch }
    end
  end

  describe '#call' do
    subject { encryptor.call }

    context 'when encryptable branch name' do
      let(:branch) { 'feature-branch' }

      before do
        expect(KnapsackPro::Config::Env).to receive(:salt).at_least(1).and_return('123')
      end

      it { should eq '49e5bb1' }
    end

    described_class::NON_ENCRYPTABLE_BRANCHES.each do |branch_name|
      context "when non encryptable branch name: #{branch_name}" do
        let(:branch) { branch_name }

        it { should eq branch_name }
      end
    end
  end
end

Version data entries

148 entries across 148 versions & 1 rubygems

Version Path
knapsack_pro-2.1.1 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-2.1.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-2.0.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.22.3 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.22.2 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.22.1 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.22.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.21.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.20.2 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.20.1 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.20.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.19.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.18.2 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.18.1 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.18.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.17.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.16.1 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.16.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.15.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-1.14.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb