Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F8395484
shared_examples_param_validation.rb
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
shared_examples_param_validation.rb
View Options
RSpec
.
configure
do
|
c
|
c
.
alias_it_should_behave_like_to
:it_validates_parameter
,
'validates parameter:'
end
shared_examples
'mirror_url'
do
domain_names
=
{
'foobar.com'
=>
true
,
'foo.bar.com'
=>
true
,
'999.bar.com'
=>
true
,
'foo-bar.com'
=>
true
,
'no-tld'
=>
false
,
'foo.longtld'
=>
false
}
prefixes
=
{
'http://'
=>
true
,
'https://'
=>
true
,
'random://'
=>
false
}
paths
=
{
''
=>
true
,
'/'
=>
true
,
'/package'
=>
true
,
'/package/'
=>
true
,
'/another/package'
=>
true
,
'/yet/another/package/'
=>
true
}
ports
=
{
''
=>
true
,
':9'
=>
false
,
':10'
=>
true
,
':99999'
=>
true
,
':100000'
=>
false
}
prefixes
.
each
do
|
prefix
,
valid_prefix
|
context
"with prefix <
#{
prefix
}
>"
do
domain_names
.
each
do
|
domain_name
,
valid_domain
|
context
"with domain name <
#{
domain_name
}
>"
do
paths
.
each
do
|
path
,
valid_path
|
context
"with path <
#{
path
}
>"
do
ports
.
each
do
|
port
,
valid_port
|
context
"with port <
#{
port
}
>"
do
mirror_url
=
"
#{
prefix
}#{
domain_name
}#{
port
}#{
path
}
"
context
"URL => <
#{
mirror_url
}
>"
do
let
:params
do
common_params
.
merge
(
mirror_url
:
mirror_url
)
end
it
{
is_expected
.
to
compile
}
if
valid_domain
&&
valid_prefix
&&
valid_path
&&
valid_port
end
end
end
end
end
end
end
end
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jun 4 2025, 7:39 PM (10 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3372226
Attached To
R143 puppet-puppet-kafka
Event Timeline
Log In to Comment