Sha256: c91270d037db15705ea24e9adc02b31b5721b37a70b3df03aa202928162c1210

Contents?: true

Size: 1.81 KB

Versions: 5

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'
require 'server_helper'

require 'kangaroo/util/proxy'

module Kangaroo
  module Util
    describe Proxy do
      include TestServerHelper

      it 'proxies method calls' do
        proxy = Proxy.new client('common')

        common_service.should_receive(:xmlrpc_call).with('some_method')
        proxy.some_method
      end

      it 'curries predefined arguments' do
        proxy = Proxy.new client('common'), 'a', 'b'

        common_service.should_receive(:xmlrpc_call).with('some_method', 'a', 'b', 'd')
        proxy.some_method 'd'
      end

      describe Proxy::Object do
        it 'sends method calls via #execute to object service' do
          proxy = Proxy::Object.new client('object'), 'model'

          object_service.should_receive(:xmlrpc_call).with('execute', 'model', 'some_method', 'a')
          proxy.some_method 'a'
        end

        it 'curries database authentication' do
          proxy = Proxy::Object.new client('object'), 'some_db', 'a_user', 'my_password', 'model'

          object_service.should_receive(:xmlrpc_call).with('execute', 'some_db', 'a_user', 'my_password',
                                                            'model', 'some_method', 'a')
          proxy.some_method 'a'
        end
      end

      describe Proxy::Db do
        it 'sends method calls to db service' do
          proxy = Proxy::Db.new client('db')

          db_service.should_receive(:xmlrpc_call).with('list')
          proxy.list
        end
      end

      describe Proxy::Superadmin do
        it 'curries pre-set superadmin password on method calls' do
          proxy = Proxy::Superadmin.new client('db'), 'superpw'

          db_service.should_receive(:xmlrpc_call).with('rename', 'superpw', 'oldname', 'newname')
          proxy.rename 'oldname', 'newname'
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kangaroo-0.1.0.alpha1 spec/util/proxy_spec.rb
kangaroo-0.0.3 spec/util/proxy_spec.rb
kangaroo-0.0.2 spec/util/proxy_spec.rb
kangaroo-0.0.1.pre2 spec/util/proxy_spec.rb
kangaroo-0.0.1.pre spec/util/proxy_spec.rb