|
5 | 5 | # case that we can autogenerate. You should add more examples below!
|
6 | 6 | it { is_expected.not_to eq(nil) }
|
7 | 7 |
|
8 |
| -################################# |
9 |
| -# Below are some example test cases. You may uncomment and modify them to match |
10 |
| -# your needs. Notice that they all expect the base error class of `StandardError`. |
11 |
| -# This is because the autogenerated function uses an untyped array for parameters |
12 |
| -# and relies on your implementation to do the validation. As you convert your |
13 |
| -# function to proper dispatches and typed signatures, you should change the |
14 |
| -# expected error of the argument validation examples to `ArgumentError`. |
15 |
| -# |
16 |
| -# Other error types you might encounter include |
17 |
| -# |
18 |
| -# * StandardError |
19 |
| -# * ArgumentError |
20 |
| -# * Puppet::ParseError |
21 |
| -# |
22 |
| -# Read more about writing function unit tests at https://rspec-puppet.com/documentation/functions/ |
23 |
| -# |
24 |
| -# it 'raises an error if called with no argument' do |
25 |
| -# is_expected.to run.with_params.and_raise_error(StandardError) |
26 |
| -# end |
27 |
| -# |
28 |
| -# it 'raises an error if there is more than 1 arguments' do |
29 |
| -# is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(StandardError) |
30 |
| -# end |
31 |
| -# |
32 |
| -# it 'raises an error if argument is not the proper type' do |
33 |
| -# is_expected.to run.with_params('foo').and_raise_error(StandardError) |
34 |
| -# end |
35 |
| -# |
36 |
| -# it 'returns the proper output' do |
37 |
| -# is_expected.to run.with_params(123).and_return('the expected output') |
38 |
| -# end |
39 |
| -################################# |
40 |
| - |
| 8 | + ################################# |
| 9 | + # Below are some example test cases. You may uncomment and modify them to match |
| 10 | + # your needs. Notice that they all expect the base error class of `StandardError`. |
| 11 | + # This is because the autogenerated function uses an untyped array for parameters |
| 12 | + # and relies on your implementation to do the validation. As you convert your |
| 13 | + # function to proper dispatches and typed signatures, you should change the |
| 14 | + # expected error of the argument validation examples to `ArgumentError`. |
| 15 | + # |
| 16 | + # Other error types you might encounter include |
| 17 | + # |
| 18 | + # * StandardError |
| 19 | + # * ArgumentError |
| 20 | + # * Puppet::ParseError |
| 21 | + # |
| 22 | + # Read more about writing function unit tests at https://rspec-puppet.com/documentation/functions/ |
| 23 | + # |
| 24 | + # it 'raises an error if called with no argument' do |
| 25 | + # is_expected.to run.with_params.and_raise_error(StandardError) |
| 26 | + # end |
| 27 | + # |
| 28 | + # it 'raises an error if there is more than 1 arguments' do |
| 29 | + # is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(StandardError) |
| 30 | + # end |
| 31 | + # |
| 32 | + # it 'raises an error if argument is not the proper type' do |
| 33 | + # is_expected.to run.with_params('foo').and_raise_error(StandardError) |
| 34 | + # end |
| 35 | + # |
| 36 | + # it 'returns the proper output' do |
| 37 | + # is_expected.to run.with_params(123).and_return('the expected output') |
| 38 | + # end |
| 39 | + ################################# |
41 | 40 | end
|
0 commit comments