Skip to content

Commit 4b6cc31

Browse files
Merge pull request #1132 from b4ldr/type_httpstatus
Stdlib::HttpStatus: add type for HTTP status codes as per rfc2616
2 parents 13eb80c + da51acb commit 4b6cc31

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

spec/type_aliases/httpstatus_spec.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require 'spec_helper'
2+
3+
if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
4+
describe 'Stdlib::HttpStatus' do
5+
describe 'valid HTTP Status' do
6+
[
7+
200,
8+
302,
9+
404,
10+
418,
11+
503,
12+
].each do |value|
13+
describe value.inspect do
14+
it { is_expected.to allow_value(value) }
15+
end
16+
end
17+
end
18+
19+
describe 'invalid path handling' do
20+
context 'garbage inputs' do
21+
[
22+
nil,
23+
[nil],
24+
[nil, nil],
25+
{ 'foo' => 'bar' },
26+
{},
27+
'',
28+
'https',
29+
'199',
30+
600,
31+
1_000,
32+
].each do |value|
33+
describe value.inspect do
34+
it { is_expected.not_to allow_value(value) }
35+
end
36+
end
37+
end
38+
end
39+
end
40+
end

types/httpstatus.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Stdlib::HttpStatus = Integer[100, 599]

0 commit comments

Comments
 (0)