Skip to content

Commit

Permalink
feat(tagging): url escape tag names
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 7, 2017
1 parent 5f862fe commit 8335978
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--color
--format documentation
--require spec_helper
3 changes: 2 additions & 1 deletion lib/pact_broker/client/versions.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require_relative 'base_client'
require 'pact_broker/client/pacts'

module PactBroker
module Client
Expand Down Expand Up @@ -38,7 +39,7 @@ def pacts
private

def tag_url options
"#{version_base_url(options)}/tags/#{options.fetch(:tag)}"
"#{version_base_url(options)}/tags/#{encode_param(options.fetch(:tag))}"
end

def versions_base_url options
Expand Down
1 change: 1 addition & 0 deletions pact-broker-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'fakefs', '~> 0.4'
gem.add_development_dependency 'rspec-fire'
gem.add_development_dependency 'appraisal'
gem.add_development_dependency 'webmock', '~> 3.0'
end
20 changes: 18 additions & 2 deletions spec/lib/pact_broker/client/versions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,28 @@ module Client
let(:client_options) do
{ some_option: 'option value'}
end
let(:base_url) { 'https://blah' }
let(:base_url) { 'http://blah' }
let(:pacticipant_name) { 'Foo' }
let(:version_number) { '1.2.3' }

subject { Versions.new(base_url: base_url, client_options: client_options) }

describe 'pacts' do
it 'initializes versions with base url and client options' do
expect(PactBroker::Client::Pacts).to receive(:new).with(base_url: base_url, client_options: client_options)
Versions.new(base_url: base_url, client_options: client_options).pacts
subject.pacts
end
end

describe 'tag' do
context "when the tag has a / in it" do
let(:tag) { 'feat/foo' }
let!(:request) { stub_request(:put, "http://blah/pacticipants/Foo/versions/1.2.3/tags/feat%2Ffoo").to_return(status: 200) }

it "URL encodes the /" do
subject.tag(pacticipant: pacticipant_name, version: version_number, tag: tag)
expect(request).to have_been_made
end
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require 'rspec/fire'
require 'webmock/rspec'

WebMock.disable_net_connect!(allow_localhost: true)

RSpec.configure do | config |
config.include RSpec::Fire
Expand Down

0 comments on commit 8335978

Please sign in to comment.