summaryrefslogtreecommitdiffstats
path: root/test/rails
diff options
context:
space:
mode:
Diffstat (limited to 'test/rails')
-rwxr-xr-xtest/rails/railsparameter.rb55
1 files changed, 32 insertions, 23 deletions
diff --git a/test/rails/railsparameter.rb b/test/rails/railsparameter.rb
index f76939ac9..337f4cb3c 100755
--- a/test/rails/railsparameter.rb
+++ b/test/rails/railsparameter.rb
@@ -15,34 +15,43 @@ class TestRailsParameter < Test::Unit::TestCase
# Create a resource param from a rails parameter
def test_to_resourceparam
railsinit
- # First create our parameter
- #FIXME Need to re-add file/line support
- pname = { :name => "myname" }
- pvalue = { :value => "myval" }
- pn = Puppet::Rails::ParamName.new(:name => pname[:name])
- pv = Puppet::Rails::ParamValue.new(:value => pvalue[:value])
- assert_nothing_raised do
- pn.param_values << pv
- end
-
- assert(pn, "Did not create rails parameter")
-
- # The id doesn't get assigned until we save
- pn.save
# Now create a source
interp = mkinterp
source = interp.newclass "myclass"
+
+ #FIXME Need to re-add file/line support
- # And try to convert our parameter
- #FIXME Why does this assert prevent the block from executing?
- #assert_nothing_raised do
- pp = pn.to_resourceparam(source)
- #end
-
- assert_instance_of(Puppet::Parser::Resource::Param, pp)
- pname.each do |name, value|
- assert_equal(value.to_sym, pp.send(name), "%s was not equal" % name)
+ # Use array and non-array values, to make sure we get things back in
+ # the same form.
+ {"myname" => "myval", "multiple" => %w{one two three}}.each do |name, value|
+ param = Puppet::Rails::ParamName.new(:name => name)
+ if value.is_a? Array
+ values = value
+ else
+ values = [value]
+ end
+ valueobjects = values.collect do |v|
+ obj = Puppet::Rails::ParamValue.new(:value => v)
+ assert_nothing_raised do
+ param.param_values << obj
+ end
+ end
+
+ assert(param, "Did not create rails parameter")
+
+ # The id doesn't get assigned until we save
+ param.save
+
+ # And try to convert our parameter
+ pp = nil
+ assert_nothing_raised do
+ pp = param.to_resourceparam(source)
+ end
+
+ assert_instance_of(Puppet::Parser::Resource::Param, pp)
+ assert_equal(name.to_sym, pp.name, "parameter name was not equal")
+ assert_equal(value, pp.value, "value was not equal for %s" % value.inspect)
end
end
end