summaryrefslogtreecommitdiffstats
path: root/test/rails/rails.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-04 18:24:24 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-10-04 18:24:24 +0000
commit28cee40689440388994a4768bd301ae32c8ecc05 (patch)
treec865ab44f4c9247052cf83de16ffc8ebe8b15e54 /test/rails/rails.rb
parente0e291332bd4676962a28c7b220ae5c5e9651c0a (diff)
downloadpuppet-28cee40689440388994a4768bd301ae32c8ecc05.tar.gz
puppet-28cee40689440388994a4768bd301ae32c8ecc05.tar.xz
puppet-28cee40689440388994a4768bd301ae32c8ecc05.zip
Merging the changes from the override-refactor branch. This is a significant rewrite of the parser, but it has little affect on the rest of the code tree.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1726 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/rails/rails.rb')
-rwxr-xr-xtest/rails/rails.rb87
1 files changed, 87 insertions, 0 deletions
diff --git a/test/rails/rails.rb b/test/rails/rails.rb
new file mode 100755
index 000000000..c780d7698
--- /dev/null
+++ b/test/rails/rails.rb
@@ -0,0 +1,87 @@
+#!/usr/bin/ruby
+
+require 'puppet'
+require 'puppet/rails'
+require 'puppet/parser/interpreter'
+require 'puppet/parser/parser'
+require 'puppet/client'
+require 'puppettest'
+require 'puppettest/parsertesting'
+require 'puppettest/resourcetesting'
+require 'puppettest/railstesting'
+
+class TestRails < Test::Unit::TestCase
+ include PuppetTest::ParserTesting
+ include PuppetTest::ResourceTesting
+ include PuppetTest::RailsTesting
+
+ def test_includerails
+ assert_nothing_raised {
+ require 'puppet/rails'
+ }
+ end
+
+ # Don't do any tests w/out this class
+ if defined? ActiveRecord::Base
+ def test_hostcache
+ @interp, @scope, @source = mkclassframing
+ # First make some objects
+ resources = []
+ 20.times { |i|
+ resources << mkresource(:type => "file", :title => "/tmp/file#{i.to_s}",
+ :params => {:owner => "user#{i}"})
+ }
+
+ # Now collect our facts
+ facts = Facter.to_hash
+
+ assert_nothing_raised {
+ Puppet::Rails.init
+ }
+
+ # Now try storing our crap
+ host = nil
+ assert_nothing_raised {
+ host = Puppet::Rails::Host.store(
+ :resources => resources,
+ :facts => facts,
+ :name => facts["hostname"],
+ :classes => ["one", "two::three", "four"]
+ )
+ }
+
+ assert(host, "Did not create host")
+
+ host = nil
+ assert_nothing_raised {
+ host = Puppet::Rails::Host.find_by_name(facts["hostname"])
+ }
+ assert(host, "Could not find host object")
+
+ assert(host.rails_resources, "No objects on host")
+
+ assert_equal(facts["hostname"], host.facts["hostname"],
+ "Did not retrieve facts")
+
+ count = 0
+ host.rails_resources.each do |resource|
+ count += 1
+ i = nil
+ if resource[:title] =~ /file([0-9]+)/
+ i = $1
+ else
+ raise "Got weird resource %s" % resource.inspect
+ end
+
+ assert_equal("user#{i}",
+ resource.rails_parameters.find_by_name("owner")[:value])
+ end
+
+ assert_equal(20, count, "Did not get enough resources")
+ end
+ else
+ $stderr.puts "Install Rails for Rails and Caching tests"
+ end
+end
+
+# $Id$