Sha256: 426d904a85a23dd95278b033c71e7b55e60f3772779ccde645fcb61cd17a90c9

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 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 
        assert_nothing_raised {
            host = Puppet::Rails::Host.store(
                :resources => resources,
                :facts => facts,
                :name => facts["hostname"]
            )
        }        

        # Now save the whole thing
        host.save
    end
end

# $Id: railstesting.rb 2567 2007-06-12 00:38:03Z ballman $

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-0.23.0 test/lib/puppettest/railstesting.rb
puppet-0.23.1 test/lib/puppettest/railstesting.rb
puppet-0.23.2 test/lib/puppettest/railstesting.rb