summaryrefslogtreecommitdiff
path: root/spec/unit/data_bag_item_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/data_bag_item_spec.rb')
-rw-r--r--spec/unit/data_bag_item_spec.rb28
1 files changed, 14 insertions, 14 deletions
diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb
index 497817ecf1..47042aa7ba 100644
--- a/spec/unit/data_bag_item_spec.rb
+++ b/spec/unit/data_bag_item_spec.rb
@@ -214,7 +214,7 @@ describe Chef::DataBagItem do
end
describe "save" do
- let(:server) { instance_double(Chef::REST) }
+ let(:server) { instance_double(Chef::ServerAPI) }
let(:data_bag_item) {
data_bag_item = Chef::DataBagItem.new
@@ -225,18 +225,18 @@ describe Chef::DataBagItem do
}
before do
- expect(Chef::REST).to receive(:new).and_return(server)
+ expect(Chef::ServerAPI).to receive(:new).and_return(server)
end
it "should update the item when it already exists" do
- expect(server).to receive(:put_rest).with("data/books/heart_of_darkness", data_bag_item)
+ expect(server).to receive(:put).with("data/books/heart_of_darkness", data_bag_item)
data_bag_item.save
end
it "should create if the item is not found" do
exception = double("404 error", :code => "404")
- expect(server).to receive(:put_rest).and_raise(Net::HTTPServerException.new("foo", exception))
- expect(server).to receive(:post_rest).with("data/books", data_bag_item)
+ expect(server).to receive(:put).and_raise(Net::HTTPServerException.new("foo", exception))
+ expect(server).to receive(:post).with("data/books", data_bag_item)
data_bag_item.save
end
@@ -249,8 +249,8 @@ describe Chef::DataBagItem do
end
it "should not save" do
- expect(server).not_to receive(:put_rest)
- expect(server).not_to receive(:post_rest)
+ expect(server).not_to receive(:put)
+ expect(server).not_to receive(:post)
data_bag_item.data_bag("books")
data_bag_item.save
end
@@ -259,7 +259,7 @@ describe Chef::DataBagItem do
end
describe "destroy" do
- let(:server) { instance_double(Chef::REST) }
+ let(:server) { instance_double(Chef::ServerAPI) }
let(:data_bag_item) {
data_bag_item = Chef::DataBagItem.new
@@ -269,8 +269,8 @@ describe Chef::DataBagItem do
}
it "should set default parameters" do
- expect(Chef::REST).to receive(:new).and_return(server)
- expect(server).to receive(:delete_rest).with("data/a_baggy_bag/data_bag_item_a_baggy_bag_some_id")
+ expect(Chef::ServerAPI).to receive(:new).and_return(server)
+ expect(server).to receive(:delete).with("data/a_baggy_bag/data_bag_item_a_baggy_bag_some_id")
data_bag_item.destroy
end
@@ -283,21 +283,21 @@ describe Chef::DataBagItem do
end
describe "from an API call" do
- let(:http_client) { double("Chef::REST") }
+ let(:http_client) { double("Chef::ServerAPI") }
before do
- allow(Chef::REST).to receive(:new).and_return(http_client)
+ allow(Chef::ServerAPI).to receive(:new).and_return(http_client)
end
it "converts raw data to a data bag item" do
- expect(http_client).to receive(:get_rest).with("data/users/charlie").and_return(data_bag_item.to_hash)
+ expect(http_client).to receive(:get).with("data/users/charlie").and_return(data_bag_item.to_hash)
item = Chef::DataBagItem.load(:users, "charlie")
expect(item).to be_a_kind_of(Chef::DataBagItem)
expect(item).to eq(data_bag_item)
end
it "does not convert when a DataBagItem is returned from the API call" do
- expect(http_client).to receive(:get_rest).with("data/users/charlie").and_return(data_bag_item)
+ expect(http_client).to receive(:get).with("data/users/charlie").and_return(data_bag_item)
item = Chef::DataBagItem.load(:users, "charlie")
expect(item).to be_a_kind_of(Chef::DataBagItem)
expect(item).to equal(data_bag_item)