Sha256: 82b5c080883c92b9902df3366caf5b8d6e1e609d5fc5def3b61b2c51d3791125

Contents?: true

Size: 1.41 KB

Versions: 8

Compression:

Stored size: 1.41 KB

Contents

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

describe Linode::Linode::Job do
  before :each do
    @api_key = 'foo'
    @linode = Linode::Linode::Job.new(:api_key => @api_key)
  end
  
  it 'should be a Linode instance' do
    @linode.class.should < Linode
  end
  
  %w(list).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.job.#{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
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
rick-linode-0.5.3 spec/linode/linode/job_spec.rb
linode-0.6.3 spec/linode/linode/job_spec.rb
linode-incandescent-0.6.2.SNAPSHOT spec/linode/linode/job_spec.rb
linode-incandescent-0.6.2 spec/linode/linode/job_spec.rb
linode-0.6.2 spec/linode/linode/job_spec.rb
linode-0.6.1 spec/linode/linode/job_spec.rb
linode-0.6.0 spec/linode/linode/job_spec.rb
linode-0.5.4 spec/linode/linode/job_spec.rb