Sha256: 09c70ab0f24a28a1eadcb0a25f1efb060ea81aadeb1d937d105f640997b1204a

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true
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 = %w[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

1 entries across 1 versions & 1 rubygems

Version Path
bitbuckets-0.2.0 spec/bitbucket_rest_api/validations/required_spec.rb