summaryrefslogtreecommitdiffstats
path: root/spec/unit/rails/resource.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-04-24 18:08:27 -0500
committerLuke Kanies <luke@madstop.com>2009-04-24 18:08:27 -0500
commitc0b119aac7fdc1306270bbe6d1279a4b8e61a99c (patch)
tree724fdf323641c673bcc4747dcadff59ae7396985 /spec/unit/rails/resource.rb
parent5ec4f66ba1e5dc8788636862d90d6521e0217e86 (diff)
downloadpuppet-c0b119aac7fdc1306270bbe6d1279a4b8e61a99c.tar.gz
puppet-c0b119aac7fdc1306270bbe6d1279a4b8e61a99c.tar.xz
puppet-c0b119aac7fdc1306270bbe6d1279a4b8e61a99c.zip
Fixing #2187 - Puppet::Resource is expected by Rails support
We previously used and expected Puppet::Parser::Resource instances, but 0.25 converts them all to Puppet::Resource instances before they're passed out of the compiler, so the Rails integration had to be changed to expect that. There's still some muddling, because the rails resources only generate parser resources, but that works for now because that's what we expect when collecting resources. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/rails/resource.rb')
-rwxr-xr-xspec/unit/rails/resource.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/unit/rails/resource.rb b/spec/unit/rails/resource.rb
new file mode 100755
index 000000000..eaead2e3d
--- /dev/null
+++ b/spec/unit/rails/resource.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe "Puppet::Rails::Resource" do
+ confine "Cannot test without ActiveRecord" => Puppet.features.rails?
+
+ def column(name, type)
+ ActiveRecord::ConnectionAdapters::Column.new(name, nil, type, false)
+ end
+
+ before do
+ require 'puppet/rails/resource'
+
+ # Stub this so we don't need access to the DB.
+ Puppet::Rails::Resource.stubs(:columns).returns([column("title", "string"), column("restype", "string"), column("exported", "boolean")])
+ end
+
+ describe "when creating initial resource arguments" do
+ it "should set the restype to the resource's type" do
+ Puppet::Rails::Resource.rails_resource_initial_args(Puppet::Resource.new(:file, "/file"))[:restype].should == "File"
+ end
+
+ it "should set the title to the resource's title" do
+ Puppet::Rails::Resource.rails_resource_initial_args(Puppet::Resource.new(:file, "/file"))[:title].should == "/file"
+ end
+
+ it "should set the line to the resource's line if one is available" do
+ resource = Puppet::Resource.new(:file, "/file")
+ resource.line = 50
+
+ Puppet::Rails::Resource.rails_resource_initial_args(resource)[:line].should == 50
+ end
+
+ it "should set 'exported' to true of the resource is exported" do
+ resource = Puppet::Resource.new(:file, "/file")
+ resource.exported = true
+
+ Puppet::Rails::Resource.rails_resource_initial_args(resource)[:exported].should be_true
+ end
+ end
+end