Sha256: 533cce4283153cdb7618ebc3e7758b6de59fbfd137ca6c60597efda390212669

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'
require 'active_support/core_ext/string'
require 'uri'
require 'rack/utils'
require 'doorkeeper/oauth/authorization/uri_builder'

module Doorkeeper::OAuth::Authorization
  describe URIBuilder do

    subject { Object.new.class.send :include, URIBuilder }

    describe :uri_with_query do
      it 'returns the uri with query' do
        uri = subject.uri_with_query 'http://example.com/', parameter: 'value'
        expect(uri).to eq('http://example.com/?parameter=value')
      end

      it 'rejects nil values' do
        uri = subject.uri_with_query 'http://example.com/', parameter: ''
        expect(uri).to eq('http://example.com/?')
      end

      it 'preserves original query parameters' do
        uri = subject.uri_with_query 'http://example.com/?query1=value', parameter: 'value'
        expect(uri).to match(/query1=value/)
        expect(uri).to match(/parameter=value/)
      end
    end

    describe :uri_with_fragment do
      it 'returns uri with parameters as fragments' do
        uri = subject.uri_with_fragment 'http://example.com/', parameter: 'value'
        expect(uri).to eq('http://example.com/#parameter=value')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
doorkeeper-1.3.1 spec/lib/oauth/authorization/uri_builder_spec.rb
doorkeeper-1.3.0 spec/lib/oauth/authorization/uri_builder_spec.rb
doorkeeper-1.2.0 spec/lib/oauth/authorization/uri_builder_spec.rb