Sha256: 693766ef4ae7cd5c6c1a9074145e43b5b31a2d41bc9788532180be1619bbf59d

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe Smartdc::Api::Analytics do

  let(:object) {Object.new}
  let(:request) {Smartdc::Request}
  let(:analytics) {Smartdc::Api::Analytics.new({})}

  describe ".create" do
    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}

      expect(analytics.create(analytic).content['id']).to eq(analytic['id'])
    end
  end

  describe ".read" do
    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}

      expect(analytics.read(id).content['id']).to eq(id)
    end
  end

  describe ".all" do
    it "returns some instrumentations" do
      object.stub(:content) {fixture('analytics')}
      request.stub_chain(:new, :get).with('my/analytics/instrumentations', {}) {object}

      expect(analytics.all.content.count).to be > 0
    end
  end

  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}

      expect(analytics.destroy(analytic['id']).status).to eq(204)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smartdc-1.3.0 spec/unit/smartdc/api/analytics_spec.rb