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-0.39.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-0.38.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-0.37.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-0.36.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-0.35.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-0.34.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-0.33.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb
knapsack_pro-0.32.0 spec/knapsack_pro/crypto/branch_encryptor_spec.rb