Sha256: 7cd0eca5f536de0c5097f1f1b330f70ae4560f176bccb801a4aa1016e0cc2937

Contents?: true

Size: 1.43 KB

Versions: 9

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe 'CapsuleCD::ValidationUtils' do
  subject{
    CapsuleCD::ValidationUtils
  }
  describe '#validate_repo_payload' do
    let(:payload){
      {
          'sha' => '0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c',
          'ref' => 'mybranch',
          'repo' => {
              'clone_url' => 'https://github.com/analogj/capsulecd.git',
              'name' => 'capsulecd'
          }
      }
    }
    it 'should run successfully when parsing correctly structured payload' do
      expect(subject.validate_repo_payload(payload)).to eql(nil)
    end

    it 'should raise an error when payload is missing sha' do
      payload.delete('sha')
      expect{subject.validate_repo_payload(payload)}.to raise_error(CapsuleCD::Error::SourcePayloadFormatError)
    end

    it 'should raise an error when payload is missing ref' do
      payload.delete('ref')
      expect{subject.validate_repo_payload(payload)}.to raise_error(CapsuleCD::Error::SourcePayloadFormatError)
    end

    it 'should raise an error when payload is missing clone_url' do
      payload['repo'].delete('clone_url')
      expect{subject.validate_repo_payload(payload)}.to raise_error(CapsuleCD::Error::SourcePayloadFormatError)
    end

    it 'should raise an error when payload is missing name' do
      payload['repo'].delete('name')
      expect{subject.validate_repo_payload(payload)}.to raise_error(CapsuleCD::Error::SourcePayloadFormatError)
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
capsulecd-1.0.11 spec/lib/capsulecd/base/common/validation_utils_spec.rb
capsulecd-1.0.10 spec/lib/capsulecd/base/common/validation_utils_spec.rb
capsulecd-1.0.9 spec/lib/capsulecd/base/common/validation_utils_spec.rb
capsulecd-1.0.8 spec/lib/capsulecd/base/common/validation_utils_spec.rb
capsulecd-1.0.7 spec/lib/capsulecd/base/common/validation_utils_spec.rb
capsulecd-1.0.6 spec/lib/capsulecd/base/common/validation_utils_spec.rb
capsulecd-1.0.5 spec/lib/capsulecd/base/common/validation_utils_spec.rb
capsulecd-1.0.4 spec/lib/capsulecd/base/common/validation_utils_spec.rb
capsulecd-1.0.3 spec/lib/capsulecd/base/common/validation_utils_spec.rb