Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F8392686
spec_helper_local.rb
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
spec_helper_local.rb
View Options
# frozen_string_literal: true
if
ENV
[
'COVERAGE'
]
==
'yes'
require
'simplecov'
require
'simplecov-console'
require
'codecov'
SimpleCov
.
formatters
=
[
SimpleCov
::
Formatter
::
HTMLFormatter
,
SimpleCov
::
Formatter
::
Console
,
SimpleCov
::
Formatter
::
Codecov
,
]
SimpleCov
.
start
do
track_files
'lib/**/*.rb'
add_filter
'/spec'
# do not track vendored files
add_filter
'/vendor'
add_filter
'/.vendor'
# do not track gitignored files
# this adds about 4 seconds to the coverage check
# this could definitely be optimized
add_filter
do
|
f
|
# system returns true if exit status is 0, which with git-check-ignore means file is ignored
system
(
"git check-ignore --quiet
#{
f
.
filename
}
"
)
end
end
end
shared_examples
'Puppet::Parameter::Boolean'
do
|
parameter
|
[
true
,
:true
,
'true'
,
:yes
,
'yes'
].
each
do
|
value
|
it
"accepts
#{
value
}
(
#{
value
.
class
}
) as a value"
do
resource
[
parameter
]
=
value
expect
(
resource
[
parameter
]
)
.
to
eq
(
true
)
end
end
[
false
,
:false
,
'false'
,
:no
,
'no'
].
each
do
|
value
|
it
"accepts
#{
value
}
(
#{
value
.
class
}
) as a value"
do
resource
[
parameter
]
=
value
expect
(
resource
[
parameter
]
)
.
to
eq
(
false
)
end
end
it
'does not accept "foo" as a value'
do
expect
{
resource
[
parameter
]
=
'foo'
}
.
to
raise_error
(
%r{Invalid value "foo"}
)
end
end
shared_examples
'a parameter that accepts only string values'
do
|
parameter
|
it
'accepts a string value'
do
resource
[
parameter
]
=
'foo'
expect
(
resource
[
parameter
]
)
.
to
eq
(
'foo'
)
end
it
'does not accept an array value'
do
expect
{
resource
[
parameter
]
=
[
'foo'
,
'bar'
]
}
.
to
raise_error
(
%r{must be a String}
)
end
it
'does not accept a hash value'
do
expect
{
resource
[
parameter
]
=
{
foo
:
'bar'
}
}
.
to
raise_error
(
%r{must be a String}
)
end
it
'does not accept an integer value'
do
expect
{
resource
[
parameter
]
=
9001
}
.
to
raise_error
(
%r{must be a String}
)
end
it
'does not accept a boolean true value'
do
expect
{
resource
[
parameter
]
=
true
}
.
to
raise_error
(
%r{must be a String}
)
end
it
'does not accept a boolean false value'
do
expect
{
resource
[
parameter
]
=
false
}
.
to
raise_error
(
%r{must be a String}
)
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Jun 4 2025, 7:01 PM (10 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3307414
Attached To
rSPCAT puppet-puppetlabs-concat
Event Timeline
Log In to Comment