Sha256: 90c2125720fe17b0247ea31d6f8e83d52c2b74cc58660c1e9fceb8ca9f9ff008

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe Smartdc::Api::Machines do
  
  let(:object) {Object.new}
  let(:request) {Smartdc::Request}
  let(:machines) {Smartdc::Api::Machines.new({})}

  describe ".create" do
    it "creates a machine" do
      object.stub(:content) {fixture('machines')[0]}
      machine = object.content
      request.stub_chain(:new, :post).with('my/machines/', machine) {object}

      expect(machines.create(machine).content['name']).to eq(machine['name'])
    end
  end

  describe ".read" do
    it "returns a machine" do
      object.stub(:content) {fixture('machines')[0]}
      name = object.content['name']
      request.stub_chain(:new, :get).with('my/machines/' + name) {object}

      expect(machines.read(name).content['name']).to eq(name)
    end
  end

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

      expect(machines.all.content.count).to be > 1
    end
  end

  describe ".destroy" do
    it "returns true when success" do
      machine = fixture('machines')[0]
      object.stub(:status) {204}
      request.stub_chain(:new, :del).with('my/machines/' + machine['name']) {object}

      expect(machines.destroy(machine['name']).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/machines_spec.rb