Sha256: e8e68de4e9badf93473f20946c6fdb20592894d73d68d7b21da34a354d14396e
Contents?: true
Size: 1.58 KB
Versions: 14
Compression:
Stored size: 1.58 KB
Contents
require 'spec_helper' require "bootic_client/whiny_uri" describe BooticClient::WhinyURI do describe '#expand' do let(:uri) { described_class.new('http://www.host.com/shops/{id}/{?foo}') } it 'complains if missing a path segment' do expect{ uri.expand(foo: 1) }.to raise_error BooticClient::InvalidURLError end it 'understand different path segment syntax' do uri = described_class.new('http://www.host.com/shops{/id}/{?foo}') expect{ uri.expand(foo: 1) }.to raise_error BooticClient::InvalidURLError end it 'expands if all path variables provided' do expect(uri.expand(id: 123)) .to eql 'http://www.host.com/shops/123/' end it 'complains if passing undeclared params' do expect{ uri.expand(id: 123, nope: 'nope') }.to raise_error BooticClient::InvalidURLError end it 'understand variable lists in query' do uri = described_class.new('http://www.host.com/shops{/id}/{?foo,bar}') expect{ uri.expand(id: 123, foo: 'foo', bar: 'bar', nope: 'nope') }.to raise_error BooticClient::InvalidURLError end it 'expands if passing declared query variables' do expect(uri.expand(id: 123, foo: 'yes')) .to eql 'http://www.host.com/shops/123/?foo=yes' end it 'expands if passing declared query variables defined as list' do uri = described_class.new('http://www.host.com/shops{/id}/{?foo,bar}') expect(uri.expand(id: 123, foo: 'yes', bar: 'no')) .to eql 'http://www.host.com/shops/123/?foo=yes&bar=no' end end end
Version data entries
14 entries across 14 versions & 1 rubygems