spec/unit/smartdc/api/keys_spec.rb in smartdc-1.2.2 vs spec/unit/smartdc/api/keys_spec.rb in smartdc-1.3.0
- old
+ new
@@ -1,53 +1,48 @@
require 'spec_helper'
-describe "Smartdc::Api::Keys" do
+describe Smartdc::Api::Keys do
- before(:all) do
- @object = Object.new
- @request = Smartdc::Request
- end
+ let(:object) {Object.new}
+ let(:request) {Smartdc::Request}
+ let(:keys) {Smartdc::Api::Keys.new({})}
describe ".create" do
- it "should return a key" do
- @object.stub(:content) {fixture('keys')[0]}
- key = @object.content
- @request.stub_chain(:new, :post).with('my/keys/', key) {@object}
+ it "creates a key" do
+ object.stub(:content) {fixture('keys')[0]}
+ key = object.content
+ request.stub_chain(:new, :post).with('my/keys/', key) {object}
- keys = Smartdc::Api::Keys.new({})
- keys.create(key).content['name'].should == key['name']
+ expect(keys.create(key).content['name']).to eq(key['name'])
end
end
describe ".read" do
- it "should return a key" do
- @object.stub(:content) {fixture('keys')[0]}
- name = @object.content['name']
- @request.stub_chain(:new, :get).with('my/keys/' + name) {@object}
+ it "returns a key" do
+ object.stub(:content) {fixture('keys')[0]}
+ name = object.content['name']
+ request.stub_chain(:new, :get).with('my/keys/' + name) {object}
- keys = Smartdc::Api::Keys.new({})
- keys.read(name).content['name'].should == name
+ expect(keys.read(name).content['name']).to eq(name)
end
end
describe ".all" do
- it "should return some keys" do
- @object.stub(:content) {fixture('keys')}
- @request.stub_chain(:new, :get).with('my/keys', {}) {@object}
+ it "returns some keys" do
+ object.stub(:content) {fixture('keys')}
+ request.stub_chain(:new, :get).with('my/keys', {}) {object}
- keys = Smartdc::Api::Keys.new({})
- keys.all.content.count.should > 0
+ expect(keys.all.content.count).to be > 1
end
end
- describe ".delete" do
- it "should return true when success" do
+ describe ".destroy" do
+ it "returns true when success" do
key = fixture('keys')[0]
- @object.stub(:status) {204}
- @request.stub_chain(:new, :del).with('my/keys/' + key['name']) {@object}
+ object.stub(:status) {204}
+ request.stub_chain(:new, :del).with('my/keys/' + key['name']) {object}
- keys = Smartdc::Api::Keys.new({})
- keys.destroy(key['name']).status.should == 204
+ expect(keys.destroy(key['name']).status).to eq(204)
end
end
-end
\ No newline at end of file
+end