summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortyler-ball <tyleraball@gmail.com>2014-09-29 13:19:08 -0700
committertyler-ball <tyleraball@gmail.com>2014-10-07 16:41:47 -0700
commitf9b74b1bf1726dffa2674a363f06c4fb962bdb53 (patch)
treec29358df70fd7dcab82669ffab165bd79740a478
parent5835f2f955819aa1aa4e52e1d98e885be4aa9af8 (diff)
downloadchef-f9b74b1bf1726dffa2674a363f06c4fb962bdb53.tar.gz
My local gemset was including the `json` gem, causing these tests to be ineffective. Also made them more clear
-rw-r--r--spec/support/shared/shared_examples.rb6
-rw-r--r--spec/unit/api_client_spec.rb2
-rw-r--r--spec/unit/cookbook_version_spec.rb2
-rw-r--r--spec/unit/data_bag_item_spec.rb2
-rw-r--r--spec/unit/data_bag_spec.rb2
-rw-r--r--spec/unit/environment_spec.rb2
-rw-r--r--spec/unit/exceptions_spec.rb2
-rw-r--r--spec/unit/json_compat_spec.rb2
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb4
-rw-r--r--spec/unit/node_spec.rb5
-rw-r--r--spec/unit/resource_collection_spec.rb2
-rw-r--r--spec/unit/resource_spec.rb2
-rw-r--r--spec/unit/role_spec.rb2
-rw-r--r--spec/unit/run_list_spec.rb2
-rw-r--r--spec/unit/user_spec.rb2
15 files changed, 23 insertions, 16 deletions
diff --git a/spec/support/shared/shared_examples.rb b/spec/support/shared/shared_examples.rb
index ccdd8cf316..b20c65f8b6 100644
--- a/spec/support/shared/shared_examples.rb
+++ b/spec/support/shared/shared_examples.rb
@@ -3,8 +3,12 @@
# Any object which defines a .to_json should import this test
shared_examples "to_json equalivent to Chef::JSONCompat.to_json" do
+ let(:jsonable) {
+ raise "You must define the subject when including this test"
+ }
+
it "should allow consumers to call #to_json or Chef::JSONCompat.to_json" do
- expect(subject.to_json).to eq(Chef::JSONCompat.to_json(subject))
+ expect(jsonable.to_json).to eq(Chef::JSONCompat.to_json(jsonable))
end
end
diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb
index 7fb2b310f9..bd6c5ef7fd 100644
--- a/spec/unit/api_client_spec.rb
+++ b/spec/unit/api_client_spec.rb
@@ -125,7 +125,7 @@ describe Chef::ApiClient do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { @client }
+ let(:jsonable) { @client }
end
end
diff --git a/spec/unit/cookbook_version_spec.rb b/spec/unit/cookbook_version_spec.rb
index 18fb709e71..25bc936569 100644
--- a/spec/unit/cookbook_version_spec.rb
+++ b/spec/unit/cookbook_version_spec.rb
@@ -423,7 +423,7 @@ describe Chef::CookbookVersion do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { Chef::CookbookVersion.new("tatft", '/tmp/blah') }
+ let(:jsonable) { Chef::CookbookVersion.new("tatft", '/tmp/blah') }
end
end
diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb
index f28450ef72..5972d8a239 100644
--- a/spec/unit/data_bag_item_spec.rb
+++ b/spec/unit/data_bag_item_spec.rb
@@ -186,7 +186,7 @@ describe Chef::DataBagItem do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { @data_bag_item }
+ let(:jsonable) { @data_bag_item }
end
end
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index 55d2a30324..ff323902eb 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -74,7 +74,7 @@ describe Chef::DataBag do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { @data_bag }
+ let(:jsonable) { @data_bag }
end
end
diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb
index bb4ece0a47..ffb8fbfeaf 100644
--- a/spec/unit/environment_spec.rb
+++ b/spec/unit/environment_spec.rb
@@ -209,7 +209,7 @@ describe Chef::Environment do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { @environment }
+ let(:jsonable) { @environment }
end
end
diff --git a/spec/unit/exceptions_spec.rb b/spec/unit/exceptions_spec.rb
index c7bfc63e6b..21b0abb9bf 100644
--- a/spec/unit/exceptions_spec.rb
+++ b/spec/unit/exceptions_spec.rb
@@ -77,7 +77,7 @@ describe Chef::Exceptions do
if exception.methods.include?(:to_json)
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { exception }
+ let(:jsonable) { exception }
end
end
end
diff --git a/spec/unit/json_compat_spec.rb b/spec/unit/json_compat_spec.rb
index 5951f0cc47..17beba5492 100644
--- a/spec/unit/json_compat_spec.rb
+++ b/spec/unit/json_compat_spec.rb
@@ -68,7 +68,7 @@ describe Chef::JSONCompat do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { Foo.new }
+ let(:jsonable) { Foo.new }
end
end
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index 3d9bf69769..cd53088419 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -95,13 +95,13 @@ EXPECTED
describe "when JSON attributes are given" do
let(:config) { {:first_boot_attributes => {:baz => :quux}} }
it "adds the attributes to first_boot" do
- bootstrap_context.first_boot.to_json.should eq(Chef::JSONCompat.to_json({:baz => :quux, :run_list => run_list}))
+ Chef::JSONCompat.to_json(bootstrap_context.first_boot).should eq(Chef::JSONCompat.to_json({:baz => :quux, :run_list => run_list}))
end
end
describe "when JSON attributes are NOT given" do
it "sets first_boot equal to run_list" do
- bootstrap_context.first_boot.to_json.should eq(Chef::JSONCompat.to_json({:run_list => run_list}))
+ Chef::JSONCompat.to_json(bootstrap_context.first_boot).should eq(Chef::JSONCompat.to_json({:run_list => run_list}))
end
end
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index ccecfca2f0..00879dcb13 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -764,7 +764,10 @@ describe Chef::Node do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { node.from_file(File.expand_path("nodes/test.example.com.rb", CHEF_SPEC_DATA)) }
+ let(:jsonable) {
+ node.from_file(File.expand_path("nodes/test.example.com.rb", CHEF_SPEC_DATA))
+ node
+ }
end
end
diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb
index 30c7630ba1..cf119f1ab0 100644
--- a/spec/unit/resource_collection_spec.rb
+++ b/spec/unit/resource_collection_spec.rb
@@ -280,7 +280,7 @@ describe Chef::ResourceCollection do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { @rc }
+ let(:jsonable) { @rc }
end
end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 50136a673d..692345c943 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -338,7 +338,7 @@ describe Chef::Resource do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { @resource }
+ let(:jsonable) { @resource }
end
end
diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb
index 36f32eb87f..1a108c4247 100644
--- a/spec/unit/role_spec.rb
+++ b/spec/unit/role_spec.rb
@@ -218,7 +218,7 @@ describe Chef::Role do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { @role }
+ let(:jsonable) { @role }
end
end
diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb
index d2f0e01811..cc7e29af0f 100644
--- a/spec/unit/run_list_spec.rb
+++ b/spec/unit/run_list_spec.rb
@@ -308,7 +308,7 @@ describe Chef::RunList do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { @run_list }
+ let(:jsonable) { @run_list }
end
end
diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb
index 055512444b..2f2299c5bd 100644
--- a/spec/unit/user_spec.rb
+++ b/spec/unit/user_spec.rb
@@ -156,7 +156,7 @@ describe Chef::User do
end
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
- let(:subject) { @user }
+ let(:jsonable) { @user }
end
end