summaryrefslogtreecommitdiff
path: root/spec/unit/resource_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/resource_spec.rb')
-rw-r--r--spec/unit/resource_spec.rb70
1 files changed, 70 insertions, 0 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
new file mode 100644
index 0000000000..b6bd113283
--- /dev/null
+++ b/spec/unit/resource_spec.rb
@@ -0,0 +1,70 @@
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: GNU General Public License version 2 or later
+#
+# This program and entire repository is free software; you can
+# redistribute it and/or modify it under the terms of the GNU
+# General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+require File.join(File.dirname(__FILE__), "..", "spec_helper")
+
+describe Marionette::Resource do
+ before(:each) do
+ @resource = Marionette::Resource.new("funk")
+ end
+
+ it "should have a name" do
+ @resource.name.should eql("funk")
+ end
+
+ it "should create a new Marionette::Resource" do
+ @resource.should be_a_kind_of(Marionette::Resource)
+ end
+
+ it "should not be valid without a name" do
+ lambda { @resource.name = nil }.should raise_error(ArgumentError)
+ end
+
+ it "should always have a string for name" do
+ lambda { @resource.name = Hash.new }.should raise_error(ArgumentError)
+ end
+
+ it "should have a string for alias" do
+ lambda { @resource.alias = nil }.should raise_error(ArgumentError)
+ lambda { @resource.alias = 'foo' }.should_not raise_error(ArgumentError)
+ @resource.alias.should eql("foo")
+ end
+
+ it "should accept true or false for noop" do
+ lambda { @resource.noop = true }.should_not raise_error(ArgumentError)
+ lambda { @resource.noop = false }.should_not raise_error(ArgumentError)
+ lambda { @resource.noop = "eat it" }.should raise_error(ArgumentError)
+ end
+
+ it "should serialize to yaml" do
+ yaml_output = <<-DESC
+--- !ruby/object:Marionette::Resource
+alias:
+before:
+name: funk
+noop:
+notify:
+require:
+subscribe:
+tag:
+DESC
+ @resource.to_yaml.should eql(yaml_output)
+ end
+
+end \ No newline at end of file