Sha256: 555cec1df3f8a78dadc031133b02f1988e84229b7de9a2f2a6585f7086e74f36

Contents?: true

Size: 1.96 KB

Versions: 8

Compression:

Stored size: 1.96 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
require 'linode'

describe Linode::Linode::Disk do
  before :each do
    @api_key = 'foo'
    @linode = Linode::Linode::Disk.new(:api_key => @api_key)
  end
  
  it 'should be a Linode instance' do
    @linode.class.should < Linode
  end
  
  %w(update create list createfromdistribution createfromstackscript duplicate delete resize).each do |action|
    it "should allow accessing the #{action} API" do
      @linode.should respond_to(action.to_sym)
    end
  
    describe "when accessing the #{action} API" do
      it 'should allow a data hash' do
        lambda { @linode.send(action.to_sym, {}) }.should_not raise_error(ArgumentError)
      end
    
      it 'should not require arguments' do
        lambda { @linode.send(action.to_sym) }.should_not raise_error(ArgumentError)      
      end
    
      it "should request the avail.#{action} action" do
        @linode.expects(:send_request).with {|api_action, data| api_action == "linode.disk.#{action}" }
        @linode.send(action.to_sym)
      end
    
      it 'should provide the data hash when making its request' do
        @linode.expects(:send_request).with {|api_action, data| data = { :foo => :bar } }
        @linode.send(action.to_sym, {:foo => :bar})
      end
    
      it 'should return the result of the request' do
        @linode.expects(:send_request).returns(:bar => :baz)      
        @linode.send(action.to_sym).should == { :bar => :baz }      
      end
      
      it "should consider the documentation to live at http://www.linode.com/api/linode/linode.disk.#{action}" do
        @linode.documentation_path(Linode.action_path(@linode.class.name, action)).should == "http://www.linode.com/api/linode/linode.disk.#{action}"
      end
    end
  end
  
  it 'should allow retrieving the disk type from disks in the "list" results' do
    @linode.stubs(:post).returns('DATA' => { 'TYPE' => 'foo' })
    @linode.list.type.should == 'foo'
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
linode-0.7.10 spec/linode/linode/disk_spec.rb
linode-0.7.9 spec/linode/linode/disk_spec.rb
linode-0.7.8 spec/linode/linode/disk_spec.rb
linode-0.7.7 spec/linode/linode/disk_spec.rb
linode-0.7.6 spec/linode/linode/disk_spec.rb
linode-0.7.5 spec/linode/linode/disk_spec.rb
linode-0.7.4 spec/linode/linode/disk_spec.rb
linode-0.7.3 spec/linode/linode/disk_spec.rb