Sha256: fcade5e2353532e6ed4f6c7f0f971e0400b6c6f504c7cf4d0bafd14cee5d873a

Contents?: true

Size: 1.14 KB

Versions: 20

Compression:

Stored size: 1.14 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.
    ActiveRecord::Base.clear_active_connections! if Puppet.features.rails?
  end

  def railsinit
    Puppet::Rails.init
  end

  def railsteardown
    Puppet::Rails.teardown if Puppet[:dbadapter] != "sqlite3"
  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,

          :parameters => 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

20 entries across 20 versions & 1 rubygems

Version Path
puppet-2.6.18 test/lib/puppettest/railstesting.rb
puppet-2.6.17 test/lib/puppettest/railstesting.rb
puppet-2.6.16 test/lib/puppettest/railstesting.rb
puppet-2.6.15 test/lib/puppettest/railstesting.rb
puppet-2.6.14 test/lib/puppettest/railstesting.rb
puppet-2.6.13 test/lib/puppettest/railstesting.rb
puppet-2.6.12 test/lib/puppettest/railstesting.rb
puppet-2.6.11 test/lib/puppettest/railstesting.rb
puppet-2.6.10 test/lib/puppettest/railstesting.rb
puppet-2.7.1 test/lib/puppettest/railstesting.rb
puppet-2.6.9 test/lib/puppettest/railstesting.rb
puppet-2.6.8 test/lib/puppettest/railstesting.rb
puppet-2.6.7 test/lib/puppettest/railstesting.rb
puppet-2.6.6 test/lib/puppettest/railstesting.rb
puppet-2.6.5 test/lib/puppettest/railstesting.rb
puppet-2.6.4 test/lib/puppettest/railstesting.rb
puppet-2.6.3 test/lib/puppettest/railstesting.rb
puppet-2.6.2 test/lib/puppettest/railstesting.rb
puppet-2.6.1 test/lib/puppettest/railstesting.rb
puppet-2.6.0 test/lib/puppettest/railstesting.rb