-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webhooks): allow the http codes to be considered as "successful"…
… to be configured. * feat/239: Add new configuration 'webhook_http_code_whitelist' to allow webhook to be successful on defined HTTP codes. Default are: 200 (OK), 201 (CREATED) and 202 (ACCEPTED) * feat: 239 Pull Request proposals: * rename "webhook_http_code_whitelist" to "webhook_http_code_success" * Rollback test case descriptions * Add other 2xx status (203 - 206)
- Loading branch information
Showing
7 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module PactBroker | ||
module Config | ||
class SpaceDelimitedIntegerList < Array | ||
def initialize list | ||
super(list) | ||
end | ||
|
||
def self.integer?(string) | ||
(Integer(string) rescue nil) != nil | ||
end | ||
|
||
def self.parse(string) | ||
array = (string || '') | ||
.split(' ') | ||
.select { |word| integer?(word) } | ||
.collect(&:to_i) | ||
SpaceDelimitedIntegerList.new(array) | ||
end | ||
|
||
def to_s | ||
collect(&:to_s).join(' ') | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
spec/lib/pact_broker/config/space_delimited_integer_list_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require 'pact_broker/config/space_delimited_integer_list' | ||
|
||
module PactBroker | ||
module Config | ||
describe SpaceDelimitedIntegerList do | ||
describe "parse" do | ||
subject { SpaceDelimitedIntegerList.parse(input) } | ||
|
||
context "when input is ''" do | ||
let(:input) { "" } | ||
|
||
it { is_expected.to eq [] } | ||
it { is_expected.to be_a SpaceDelimitedIntegerList } | ||
|
||
its(:to_s) { is_expected.to eq input } | ||
end | ||
|
||
context "when input is 'off'" do | ||
let(:input) { "off" } | ||
|
||
it { is_expected.to eq [] } | ||
it { is_expected.to be_a SpaceDelimitedIntegerList } | ||
|
||
its(:to_s) { is_expected.to eq "" } | ||
end | ||
|
||
context "when input is '0 1 1 2 3 5 8 13 21 34'" do | ||
let(:input) { "0 1 1 2 3 5 8 13 21 34" } | ||
|
||
it { is_expected.to eq [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] } | ||
it { is_expected.to be_a SpaceDelimitedIntegerList } | ||
|
||
its(:to_s) { is_expected.to eq input } | ||
end | ||
|
||
context "when input is '13 17 foo 19'" do | ||
let(:input) { "13 17 foo 19" } | ||
|
||
it { is_expected.to eq [13, 17, 19] } | ||
it { is_expected.to be_a SpaceDelimitedIntegerList } | ||
|
||
its(:to_s) { is_expected.to eq "13 17 19" } | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters