Sha256: f4d241fa50743f62b13e835036a7a8c80e4fdfa1b8fe94264d11efc7f5076051

Contents?: true

Size: 1001 Bytes

Versions: 1

Compression:

Stored size: 1001 Bytes

Contents

# frozen_string_literal: true
require 'spec_helper'

describe BitBucket::Validations::Format do
  let(:format) { Class.new.extend(described_class) }
  before do
    @permitted = { 'param1' => %w[val1 val2], 'param2' => /^regexp$/ }
  end

  describe '.assert_valid_values' do
    it 'raises an UnknownValue error when provided an unpermitted parameter' do
      params = { 'param1' => 'unpermitted_value' }
      expect do
        format.assert_valid_values(@permitted, params)
      end.to raise_error BitBucket::Error::UnknownValue

      params = { 'param2' => 'unpermitted_value' }
      expect do
        format.assert_valid_values(@permitted, params)
      end.to raise_error BitBucket::Error::UnknownValue
    end

    it 'returns the params when provided with only permitted parameters' do
      params = { 'param1' => 'val1', 'param2' => 'regexp' }
      expect(
        format.assert_valid_values(@permitted, params)
      ).to eq('param1' => 'val1', 'param2' => 'regexp')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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