Sha256: ae510d172634e4dcd46c3811d8456f836e93120595f849ce67dcd695b587f3b5

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

module PuppetTest::RailsTesting
    Parser = Puppet::Parser
    AST = Puppet::Parser::AST
    include PuppetTest::ParserTesting

    def teardown
        super

        # If we don't clean up the connection list, then the rails
        # lib will still think it's connected.
        if Puppet.features.rails?
            ActiveRecord::Base.clear_active_connections!
        end
    end

    def railsinit
        Puppet::Rails.init
    end

    def railsteardown
        if Puppet[:dbadapter] != "sqlite3"
            Puppet::Rails.teardown
        end
    end

    def railsresource(type = "file", title = "/tmp/testing", params = {})
        railsteardown
        railsinit
        
        # We need a host for resources
        #host = Puppet::Rails::Host.new(:name => Facter.value("hostname"))

        # Now build a resource
        resources = []
        resources << mkresource(:type => type, :title => title, :exported => true,
                   :params => params)

        # Now collect our facts
        facts = Facter.to_hash

        # Now try storing our crap
        host = nil 
        node = mknode(facts["hostname"])
        node.parameters = facts
        assert_nothing_raised {
            host = Puppet::Rails::Host.store(node, resources)
        }        

        # Now save the whole thing
        host.save
    end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
puppet-0.24.9 test/lib/puppettest/railstesting.rb
puppet-0.24.0 test/lib/puppettest/railstesting.rb
puppet-0.24.3 test/lib/puppettest/railstesting.rb
puppet-0.24.4 test/lib/puppettest/railstesting.rb
puppet-0.24.1 test/lib/puppettest/railstesting.rb
puppet-0.24.2 test/lib/puppettest/railstesting.rb
puppet-0.24.6 test/lib/puppettest/railstesting.rb
puppet-0.24.7 test/lib/puppettest/railstesting.rb
puppet-0.24.5 test/lib/puppettest/railstesting.rb
puppet-0.24.8 test/lib/puppettest/railstesting.rb