Sha256: 81ef636506aef46fc9d1f67b297de4a9d9aabc241d3c738c52464364231292ba

Contents?: true

Size: 1.76 KB

Versions: 20

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'
require 'spec/support/test/resource_service'

describe 'Functional EventMachine Client' do
  before(:each) do
    load 'protobuf/evented.rb'
  end

  it 'runs fine when required fields are set' do
    expect {
      EventMachine.fiber_run do
        StubServer.new do |server|
          client = ::Test::ResourceService.client(:timeout => 5)

          client.find(:name => 'Test Name', :active => true) do |c|
            c.on_success do |succ|
              succ.name.should eq("Test Name")
              succ.status.should eq(::Test::StatusType::ENABLED)
            end

            c.on_failure do |err|
              raise err.inspect
            end
          end
        end
        EM.stop
      end
    }.to_not raise_error
  end

  it 'calls the on_failure callback when a message is malformed' do
    error = nil
    EventMachine.fiber_run do
      StubServer.new do |server|
        request = ::Test::ResourceFindRequest.new(:active => true)
        client = ::Test::ResourceService.client

        client.find(request) do |c|
          c.on_success { raise "shouldn't pass"}
          c.on_failure {|e| error = e}
        end
      end
      EM.stop
    end
    error.message.should =~ /ResourceFindRequest.*fields.*improperly set/
  end

  it 'calls the on_failure callback when the request type is wrong' do
    error = nil
    EventMachine.fiber_run do
      StubServer.new do |server|
        request = ::Test::Resource.new(:name => 'Test Name')
        client = ::Test::ResourceService.client

        client.find(request) do |c|
          c.on_success { raise "shouldn't pass"}
          c.on_failure {|e| error = e}
        end
      end
      EM.stop
    end
    error.message.should =~ /expected request.*ResourceFindRequest.*Resource instead/i
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
protobuf-2.3.2-java spec/functional/evented_server_spec.rb
protobuf-2.3.2 spec/functional/evented_server_spec.rb
protobuf-2.3.1-java spec/functional/evented_server_spec.rb
protobuf-2.3.1 spec/functional/evented_server_spec.rb
protobuf-2.3.0-java spec/functional/evented_server_spec.rb
protobuf-2.3.0 spec/functional/evented_server_spec.rb
protobuf-2.2.7-java spec/functional/evented_server_spec.rb
protobuf-2.2.7 spec/functional/evented_server_spec.rb
protobuf-2.2.6-java spec/functional/evented_server_spec.rb
protobuf-2.2.6 spec/functional/evented_server_spec.rb
protobuf-2.2.5-java spec/functional/evented_server_spec.rb
protobuf-2.2.5 spec/functional/evented_server_spec.rb
protobuf-2.2.4 spec/functional/evented_server_spec.rb
protobuf-2.2.3 spec/functional/evented_server_spec.rb
protobuf-2.2.2 spec/functional/evented_server_spec.rb
protobuf-2.2.1 spec/functional/evented_server_spec.rb
protobuf-2.2.0 spec/functional/evented_server_spec.rb
protobuf-2.1.3 spec/functional/evented_server_spec.rb
protobuf-2.1.2 spec/functional/evented_server_spec.rb
protobuf-2.1.1 spec/functional/evented_server_spec.rb