Sha256: 09b80d6eb2db5d72bd175d2733b89ea3582d02a4a316d648d2ba0f39c42c685b

Contents?: true

Size: 966 Bytes

Versions: 9

Compression:

Stored size: 966 Bytes

Contents

require 'spec_helper'

describe BitBucket::Validations::Format do
  let(:format) { Class.new.extend(described_class) }
  before do
    @permitted = {"param1" => ["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{
        format.assert_valid_values(@permitted, params)
        }.to raise_error BitBucket::Error::UnknownValue

      params = {"param2" => "unpermitted_value"}
      expect{
        format.assert_valid_values(@permitted, params)
        }.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

9 entries across 9 versions & 2 rubygems

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