Sha256: a695d749af598e6166bf87d89f478595ac8d1a3a985e4bbc59a00bcc54e3b3cf

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe BitBucket::Utils::Url do
  before do
      @url_util = BitBucket::Utils::Url
    end

  describe '.build_query' do
    it 'builds a query string from a params hash' do
      expect(@url_util.build_query({key1: "val1", key2: "val2"})).to eq "key1=val1&key2=val2"
    end

    it 'builds a query string from a params hash when one value is an array' do
      expect(@url_util.build_query({key1: "val1", key2: ["val2", "val3"]})).to eq "key1=val1&key2=val2&key2=val3"
    end
  end

  describe '.parse_query' do
    it 'builds a params hash from a query string' do
      expect(@url_util.parse_query("key1=val1&key2=val2")).to eq({"key1" => "val1", "key2" => "val2"})
    end

    it 'builds a params hash from a query string when given multiple values for the same param' do
      expect(@url_util.parse_query("key1=val1&key2=val2&key2=val3&key2=val4")).to eq({"key1" => "val1", "key2" => ["val2", "val3", "val4"]})
    end
  end

  describe '.parse_query_for_param' do
    it 'returns a value a query string given the key' do
      expect(@url_util.parse_query_for_param("key1=val1&key2=val2", "key2")).to eq("val2")
    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/utils/url_spec.rb
zz_bitbucket_rest_api-0.1.10 spec/bitbucket_rest_api/utils/url_spec.rb
zz_bitbucket_rest_api-0.1.9 spec/bitbucket_rest_api/utils/url_spec.rb
zz_bitbucket_rest_api-0.1.8 spec/bitbucket_rest_api/utils/url_spec.rb
bitbucket_rest_api2-0.9.5 spec/bitbucket_rest_api/utils/url_spec.rb
bitbucket_rest_api2-0.9.1 spec/bitbucket_rest_api/utils/url_spec.rb
bitbucket_rest_api2-0.2.2 spec/bitbucket_rest_api/utils/url_spec.rb
bitbucket_rest_api2-0.2.1 spec/bitbucket_rest_api/utils/url_spec.rb
bitbucket_rest_api2-0.2.0 spec/bitbucket_rest_api/utils/url_spec.rb