Age | Commit message (Collapse) | Author |
|
This is the idiomatic version of #634, and also addresses
the test failures.
Original-Fix-By: Michiel Brandenburg <michiel@silverstreet.com>
|
|
Tests in the new style produces the following documentation output:
abs
should not eq nil
should run abs() and raise an Puppet::ParseError
should run abs(-34) and return 34
should run abs("-34") and return 34
should run abs(34) and return 34
should run abs("34") and return 34
|
|
This conversion is done by Transpec 2.2.1 with the following command:
transpec spec/functions
* 345 conversions
from: obj.should
to: expect(obj).to
* 122 conversions
from: == expected
to: eq(expected)
* 85 conversions
from: lambda { }.should
to: expect { }.to
* 22 conversions
from: be_true
to: be_truthy
* 16 conversions
from: be_false
to: be_falsey
* 11 conversions
from: pending
to: skip
* 9 conversions
from: it { should ... }
to: it { is_expected.to ... }
* 5 conversions
from: =~ [1, 2]
to: match_array([1, 2])
* 2 conversions
from: =~ /pattern/
to: match(/pattern/)
* 2 conversions
from: obj.should_not
to: expect(obj).not_to
For more details: https://github.com/yujinakayama/transpec#supported-conversions
|
|
rspec-puppet matchers are defined for tests which exist in
spec/functions, but the function unit tests lived in
spec/unit/puppet/parser/functions. This moves them to the correct place
for using rspec-puppet
|
|
|
|
complaining loudly
|
|
This work updates a number of Gems to the latest versions (rspec,
rspec-puppet), and updates and tweaks a bunch of tests to work
with the updated gems.
|
|
As far as i know there's no other puppet-dsl-like way to get parameter of
defined resource, so that's why i implemented getparam function, which takes
resource reference and parameter name and returns parameter value.
Here's another example why this function is really useful:
define config($path, $config_param1, $config_param2) { }
define example_resource($config) {
$path = getparam($config, "path")
notice("Path is $path")
}
define example_resource2($example_resource, $config = getparam($example_resource, "config")) {
$config_param1 = getparam($config, "config_param1")
notice("Config parameter is $config_param1")
}
define example_resource3($example_resource, $config = getparam($example_resource, "config")) {
$config_param2 = getparam($config, "config_param2")
notice("Config parameter is $config_param2")
}
class test_getparam {
config { "config_instance":
path => "/some/config/path",
config_param1 => "someconfigtext1",
config_param2 => "someconfigtext2",
}
example_resource { "example_resource_instance":
config => Config["config_instance"]
}
example_resource2 { "example_resource_instance":
example_resource => Example_resource["example_resource_instance"]
}
example_resource3 { "example_resource_instance":
example_resource => Example_resource2["example_resource_instance"]
}
}
class { "test_getparam": }
|