Sha256: 5d09370059c5308b83b13bf24df76eb9d1abd06c25ed457f32fbc376f95aa590

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper.rb'
require 'rack/amf'

describe Rack::AMF::Response do
  it "should serialize response when converted to string" do
    response = Rack::AMF::Response.new(create_rack_request('commandMessage.bin'))
    response.raw_response.should_receive(:serialize).and_return('serialized')
    response.to_s.should == 'serialized'
  end

  it "should respond to ping command" do
    response = Rack::AMF::Response.new(create_rack_request('commandMessage.bin'))
    response.each_method_call {|method, args| nil}

    r = response.raw_response
    r.messages.length.should == 1
    r.messages[0].data.should be_a(AMF::Values::AcknowledgeMessage)
  end

  it "should handle RemotingMessages properly" do
    response = Rack::AMF::Response.new(create_rack_request('remotingMessage.bin'))

    response.each_method_call do |method, args|
      method.should == 'WritesController.save'
      args.should == [true]
      true
    end

    r = response.raw_response
    r.messages.length.should == 1
    r.messages[0].data.should be_a(AMF::Values::AcknowledgeMessage)
    r.messages[0].data.body.should == true
  end

  it "should catch exceptions properly" do
    response = Rack::AMF::Response.new(create_rack_request('remotingMessage.bin'))
    response.each_method_call do |method, args|
      raise 'Error in call'
    end

    r = response.raw_response
    r.messages.length.should == 1
    r.messages[0].data.should be_a(AMF::Values::ErrorMessage)
    r.messages[0].target_uri.should =~ /onStatus$/
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-amf-0.0.3 spec/rack/response_spec.rb
rack-amf-0.0.2 spec/rack/response_spec.rb
rack-amf-0.0.1 spec/rack/response_spec.rb