File: railsparameter.rb

package info (click to toggle)
puppet 0.20.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,072 kB
  • ctags: 3,365
  • sloc: ruby: 47,009; sh: 496; lisp: 143; xml: 122; makefile: 67
file content (52 lines) | stat: -rwxr-xr-x 1,447 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env ruby

$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/

require 'puppet'
require 'puppet/rails'
require 'puppettest'
require 'puppettest/railstesting'

# Don't do any tests w/out this class
if defined? ActiveRecord::Base
class TestRailsParameter < Test::Unit::TestCase
    include PuppetTest::RailsTesting
    
    # Create a resource param from a rails parameter
    def test_to_resourceparam
        railsinit
        # First create our parameter
        rparam = nil
        hash = { :name => :myparam, :value => "myval",
                :file => __FILE__, :line => __LINE__}
        assert_nothing_raised do
            rparam = Puppet::Rails::RailsParameter.new(hash)
        end

        assert(rparam, "Did not create rails parameter")

        # The id doesn't get assigned until we save
        rparam.save

        # Now create a source
        interp = mkinterp
        source = interp.newclass "myclass"

        # And try to convert our parameter
        pparam = nil
        assert_nothing_raised do
            pparam = rparam.to_resourceparam(source)
        end


        assert_instance_of(Puppet::Parser::Resource::Param, pparam)
        hash.each do |name, value|
            assert_equal(value,  pparam.send(name), "%s was not equal" % name)
        end
    end
end
else
    $stderr.puts "Install Rails for Rails and Caching tests"
end

# $Id: railsparameter.rb 1873 2006-11-13 07:49:48Z luke $