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