spec/unit/smartdc/api/analytics_spec.rb in smartdc-1.2.2 vs spec/unit/smartdc/api/analytics_spec.rb in smartdc-1.3.0

- old
+ new

@@ -1,53 +1,48 @@ require 'spec_helper' -describe "Smartdc::Api::Analytics" do - - before(:all) do - @object = Object.new - @request = Smartdc::Request - end +describe Smartdc::Api::Analytics do + let(:object) {Object.new} + let(:request) {Smartdc::Request} + let(:analytics) {Smartdc::Api::Analytics.new({})} + describe ".create" do - it "should return a instrumentation" do - @object.stub(:content) {fixture('analytics')[0]} - analytic = @object.content - @request.stub_chain(:new, :post).with('my/analytics/instrumentations/', analytic) {@object} + it "creates a instrumentation" do + object.stub(:content) {fixture('analytics')[0]} + analytic = object.content + request.stub_chain(:new, :post).with('my/analytics/instrumentations/', analytic) {object} - analytics = Smartdc::Api::Analytics.new({}) - analytics.create(analytic).content['id'].should == analytic['id'] + expect(analytics.create(analytic).content['id']).to eq(analytic['id']) end end describe ".read" do - it "should return a instrumentation" do - @object.stub(:content) {fixture('analytics')[0]} - id = @object.content['id'] - @request.stub_chain(:new, :get).with('my/analytics/instrumentations/' + id) {@object} + it "returns a instrumentation" do + object.stub(:content) {fixture('analytics')[0]} + id = object.content['id'] + request.stub_chain(:new, :get).with('my/analytics/instrumentations/' + id) {object} - analytics = Smartdc::Api::Analytics.new({}) - analytics.read(id).content['id'].should == id + expect(analytics.read(id).content['id']).to eq(id) end end describe ".all" do - it "should return some instrumentations" do - @object.stub(:content) {fixture('analytics')} - @request.stub_chain(:new, :get).with('my/analytics/instrumentations', {}) {@object} + it "returns some instrumentations" do + object.stub(:content) {fixture('analytics')} + request.stub_chain(:new, :get).with('my/analytics/instrumentations', {}) {object} - analytics = Smartdc::Api::Analytics.new({}) - analytics.all.content.count.should > 0 + expect(analytics.all.content.count).to be > 0 end end - describe ".delete" do - it "should return true when success" do + describe ".destroy" do + it "returns true when success" do analytic = fixture('analytics')[0] - @object.stub(:status) {204} - @request.stub_chain(:new, :del).with('my/analytics/instrumentations/' + analytic['id']) {@object} + object.stub(:status) {204} + request.stub_chain(:new, :del).with('my/analytics/instrumentations/' + analytic['id']) {object} - analytics = Smartdc::Api::Analytics.new({}) - analytics.destroy(analytic['id']).status.should == 204 + expect(analytics.destroy(analytic['id']).status).to eq(204) end end end