Sha256: 10966995ec9f537bc411ac5c14454d1f344bce8c33a78b59365df3ccc37230b1

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe BitBucket::Validations::Required do
  class SpecClass
    include BitBucket::Validations::Required
  end

  let(:spec_class) { SpecClass.new }
  let(:params_with_blank) do
    {
      'title' => "mock_title",
      'source' => {
        'branch' => {
          'name' => ""
        }
      }
    }
  end

  describe '#parse_values' do
    it 'parses a colon separated string to an array' do
      result = spec_class.parse_values('hello:world')
      expectation = ['hello', 'world']

      expect(result).to eq(expectation)
    end
  end

  describe '#assert_required_values_present' do
    it 'raises an instance of BitBucket::Error::BlankValue if a required string is left blank' do
      expect do
        spec_class.assert_required_values_present(
          params_with_blank,
          'title',
          'source:branch:name'
        )
      end.to raise_error(
        BitBucket::Error::BlankValue,
        "The value for: 'source:branch:name', cannot be blank :("
      )
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
zz_bitbucket_rest_api-0.1.11 spec/bitbucket_rest_api/validations/required_spec.rb
zz_bitbucket_rest_api-0.1.10 spec/bitbucket_rest_api/validations/required_spec.rb
zz_bitbucket_rest_api-0.1.9 spec/bitbucket_rest_api/validations/required_spec.rb
zz_bitbucket_rest_api-0.1.8 spec/bitbucket_rest_api/validations/required_spec.rb
bitbucket_rest_api2-0.9.5 spec/bitbucket_rest_api/validations/required_spec.rb
bitbucket_rest_api2-0.9.1 spec/bitbucket_rest_api/validations/required_spec.rb
bitbucket_rest_api2-0.2.2 spec/bitbucket_rest_api/validations/required_spec.rb
bitbucket_rest_api2-0.2.1 spec/bitbucket_rest_api/validations/required_spec.rb
bitbucket_rest_api2-0.2.0 spec/bitbucket_rest_api/validations/required_spec.rb