summaryrefslogtreecommitdiff
path: root/spec/unit/mixin
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/mixin')
-rw-r--r--spec/unit/mixin/checksum_spec.rb8
-rw-r--r--spec/unit/mixin/convert_to_class_name_spec.rb14
-rw-r--r--spec/unit/mixin/deprecation_spec.rb4
-rw-r--r--spec/unit/mixin/params_validate_spec.rb144
-rw-r--r--spec/unit/mixin/windows_architecture_helper_spec.rb10
-rw-r--r--spec/unit/mixin/xml_escape_spec.rb4
6 files changed, 92 insertions, 92 deletions
diff --git a/spec/unit/mixin/checksum_spec.rb b/spec/unit/mixin/checksum_spec.rb
index 19af1c7d2b..cb31df828d 100644
--- a/spec/unit/mixin/checksum_spec.rb
+++ b/spec/unit/mixin/checksum_spec.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +20,7 @@ require 'spec_helper'
require 'chef/mixin/checksum'
require 'stringio'
-class Chef::CMCCheck
+class Chef::CMCCheck
include Chef::Mixin::Checksum
end
@@ -34,7 +34,7 @@ describe Chef::Mixin::Checksum do
end
it "gets the checksum of a file" do
- @checksum_user.checksum(@file).should == "09ee9c8cc70501763563bcf9c218d71b2fbf4186bf8e1e0da07f0f42c80a3394"
+ @checksum_user.checksum(@file).should == "dc6665c18676f5f30fdaa420343960edf1883790f83f51f437dbfa0ff678499d"
end
end
diff --git a/spec/unit/mixin/convert_to_class_name_spec.rb b/spec/unit/mixin/convert_to_class_name_spec.rb
index b78d3f9101..240decc6da 100644
--- a/spec/unit/mixin/convert_to_class_name_spec.rb
+++ b/spec/unit/mixin/convert_to_class_name_spec.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,23 +23,23 @@ class ConvertToClassTestHarness
end
describe Chef::Mixin::ConvertToClassName do
-
+
before do
@convert = ConvertToClassTestHarness.new
end
-
+
it "converts a_snake_case_word to a CamelCaseWord" do
@convert.convert_to_class_name("now_camelized").should == "NowCamelized"
end
-
+
it "converts a CamelCaseWord to a snake_case_word" do
@convert.convert_to_snake_case("NowImASnake").should == "now_im_a_snake"
end
-
+
it "removes the base classes before snake casing" do
@convert.convert_to_snake_case("NameSpaced::Class::ThisIsWin", "NameSpaced::Class").should == "this_is_win"
end
-
+
it "removes the base classes without explicitly naming them and returns snake case" do
@convert.snake_case_basename("NameSpaced::Class::ExtraWin").should == "extra_win"
end
diff --git a/spec/unit/mixin/deprecation_spec.rb b/spec/unit/mixin/deprecation_spec.rb
index c3170007de..3ebf06e830 100644
--- a/spec/unit/mixin/deprecation_spec.rb
+++ b/spec/unit/mixin/deprecation_spec.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb
index aa37362dc3..2947ebea4a 100644
--- a/spec/unit/mixin/params_validate_spec.rb
+++ b/spec/unit/mixin/params_validate_spec.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +20,7 @@ require 'spec_helper'
class TinyClass
include Chef::Mixin::ParamsValidate
-
+
def music(is_good=true)
is_good
end
@@ -30,136 +30,136 @@ describe Chef::Mixin::ParamsValidate do
before(:each) do
@vo = TinyClass.new()
end
-
+
it "should allow a hash and a hash as arguments to validate" do
lambda { @vo.validate({:one => "two"}, {}) }.should_not raise_error(ArgumentError)
end
-
+
it "should raise an argument error if validate is called incorrectly" do
lambda { @vo.validate("one", "two") }.should raise_error(ArgumentError)
end
-
+
it "should require validation map keys to be symbols or strings" do
lambda { @vo.validate({:one => "two"}, { :one => true }) }.should_not raise_error(ArgumentError)
lambda { @vo.validate({:one => "two"}, { "one" => true }) }.should_not raise_error(ArgumentError)
lambda { @vo.validate({:one => "two"}, { Hash.new => true }) }.should raise_error(ArgumentError)
end
-
+
it "should allow options to be required with true" do
lambda { @vo.validate({:one => "two"}, { :one => true }) }.should_not raise_error(ArgumentError)
end
-
+
it "should allow options to be optional with false" do
lambda { @vo.validate({}, {:one => false})}.should_not raise_error(ArgumentError)
- end
-
+ end
+
it "should allow you to check what kind_of? thing an argument is with kind_of" do
- lambda {
+ lambda {
@vo.validate(
- {:one => "string"},
+ {:one => "string"},
{
:one => {
:kind_of => String
}
}
- )
+ )
}.should_not raise_error(ArgumentError)
-
- lambda {
+
+ lambda {
@vo.validate(
- {:one => "string"},
+ {:one => "string"},
{
:one => {
:kind_of => Array
}
}
- )
+ )
}.should raise_error(ArgumentError)
end
-
+
it "should allow you to specify an argument is required with required" do
- lambda {
+ lambda {
@vo.validate(
- {:one => "string"},
+ {:one => "string"},
{
:one => {
:required => true
}
}
- )
+ )
}.should_not raise_error(ArgumentError)
-
- lambda {
+
+ lambda {
@vo.validate(
- {:two => "string"},
+ {:two => "string"},
{
:one => {
:required => true
}
}
- )
+ )
}.should raise_error(ArgumentError)
-
- lambda {
+
+ lambda {
@vo.validate(
- {:two => "string"},
+ {:two => "string"},
{
:one => {
:required => false
}
}
- )
+ )
}.should_not raise_error(ArgumentError)
end
-
+
it "should allow you to specify whether an object has a method with respond_to" do
- lambda {
+ lambda {
@vo.validate(
- {:one => @vo},
+ {:one => @vo},
{
:one => {
:respond_to => "validate"
}
}
- )
+ )
}.should_not raise_error(ArgumentError)
-
- lambda {
+
+ lambda {
@vo.validate(
- {:one => @vo},
+ {:one => @vo},
{
:one => {
:respond_to => "monkey"
}
}
- )
+ )
}.should raise_error(ArgumentError)
end
-
+
it "should allow you to specify whether an object has all the given methods with respond_to and an array" do
- lambda {
+ lambda {
@vo.validate(
- {:one => @vo},
+ {:one => @vo},
{
:one => {
:respond_to => ["validate", "music"]
}
}
- )
+ )
}.should_not raise_error(ArgumentError)
-
- lambda {
+
+ lambda {
@vo.validate(
- {:one => @vo},
+ {:one => @vo},
{
:one => {
:respond_to => ["monkey", "validate"]
}
}
- )
+ )
}.should raise_error(ArgumentError)
end
-
+
it "should let you set a default value with default => value" do
arguments = Hash.new
@vo.validate(arguments, {
@@ -169,9 +169,9 @@ describe Chef::Mixin::ParamsValidate do
})
arguments[:one].should == "is the loneliest number"
end
-
+
it "should let you check regular expressions" do
- lambda {
+ lambda {
@vo.validate(
{ :one => "is good" },
{
@@ -181,8 +181,8 @@ describe Chef::Mixin::ParamsValidate do
}
)
}.should_not raise_error(ArgumentError)
-
- lambda {
+
+ lambda {
@vo.validate(
{ :one => "is good" },
{
@@ -193,9 +193,9 @@ describe Chef::Mixin::ParamsValidate do
)
}.should raise_error(ArgumentError)
end
-
+
it "should let you specify your own callbacks" do
- lambda {
+ lambda {
@vo.validate(
{ :one => "is good" },
{
@@ -208,9 +208,9 @@ describe Chef::Mixin::ParamsValidate do
}
}
)
- }.should_not raise_error(ArgumentError)
-
- lambda {
+ }.should_not raise_error(ArgumentError)
+
+ lambda {
@vo.validate(
{ :one => "is bad" },
{
@@ -223,12 +223,12 @@ describe Chef::Mixin::ParamsValidate do
}
}
)
- }.should raise_error(ArgumentError)
+ }.should raise_error(ArgumentError)
end
-
+
it "should let you combine checks" do
args = { :one => "is good", :two => "is bad" }
- lambda {
+ lambda {
@vo.validate(
args,
{
@@ -276,7 +276,7 @@ describe Chef::Mixin::ParamsValidate do
)
}.should raise_error(ArgumentError)
end
-
+
it "should raise an ArgumentError if the validation map has an unknown check" do
lambda { @vo.validate(
{ :one => "two" },
@@ -288,43 +288,43 @@ describe Chef::Mixin::ParamsValidate do
)
}.should raise_error(ArgumentError)
end
-
+
it "should accept keys that are strings in the options" do
lambda {
- @vo.validate({ "one" => "two" }, { :one => { :regex => /^two$/ }})
+ @vo.validate({ "one" => "two" }, { :one => { :regex => /^two$/ }})
}.should_not raise_error(ArgumentError)
end
-
+
it "should allow an array to kind_of" do
- lambda {
+ lambda {
@vo.validate(
- {:one => "string"},
+ {:one => "string"},
{
:one => {
:kind_of => [ String, Array ]
}
}
- )
+ )
}.should_not raise_error(ArgumentError)
- lambda {
+ lambda {
@vo.validate(
- {:one => ["string"]},
+ {:one => ["string"]},
{
:one => {
:kind_of => [ String, Array ]
}
}
- )
+ )
}.should_not raise_error(ArgumentError)
- lambda {
+ lambda {
@vo.validate(
- {:one => Hash.new},
+ {:one => Hash.new},
{
:one => {
:kind_of => [ String, Array ]
}
}
- )
+ )
}.should raise_error(ArgumentError)
end
@@ -403,5 +403,5 @@ describe Chef::Mixin::ParamsValidate do
@vo.set_or_return(:test, nil, {}).object_id.should == value.object_id
@vo.set_or_return(:test, nil, {}).should be_a(Proc)
end
-
+
end
diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb
index c7813a5efc..f59602d716 100644
--- a/spec/unit/mixin/windows_architecture_helper_spec.rb
+++ b/spec/unit/mixin/windows_architecture_helper_spec.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,7 @@ describe Chef::Mixin::WindowsArchitectureHelper do
@node_i386 = Chef::Node.new
@node_x86_64 = Chef::Node.new
end
-
+
it "returns true when valid architectures are passed to valid_windows_architecture?" do
@valid_architectures.each do | architecture |
valid_windows_architecture?(architecture).should == true
@@ -67,7 +67,7 @@ describe Chef::Mixin::WindowsArchitectureHelper do
it "returns false for each unsupported desired architecture for all nodes with each valid architecture passed to node_supports_windows_architecture?" do
enumerate_architecture_node_combinations(true)
end
-
+
def enumerate_architecture_node_combinations(only_valid_combinations)
@valid_architectures.each do | node_architecture |
new_node = Chef::Node.new
@@ -76,7 +76,7 @@ describe Chef::Mixin::WindowsArchitectureHelper do
@valid_architectures.each do | supported_architecture |
node_supports_windows_architecture?(new_node, supported_architecture).should == true if only_valid_combinations && (supported_architecture != :x86_64 && node_architecture != :i386 )
- node_supports_windows_architecture?(new_node, supported_architecture).should == false if ! only_valid_combinations && (supported_architecture == :x86_64 && node_architecture == :i386 )
+ node_supports_windows_architecture?(new_node, supported_architecture).should == false if ! only_valid_combinations && (supported_architecture == :x86_64 && node_architecture == :i386 )
end
end
end
diff --git a/spec/unit/mixin/xml_escape_spec.rb b/spec/unit/mixin/xml_escape_spec.rb
index d05854ade4..83debb5907 100644
--- a/spec/unit/mixin/xml_escape_spec.rb
+++ b/spec/unit/mixin/xml_escape_spec.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.