Sha256: 3dea345e68771203b52ee2107de055f67245bfb64d5ef7b29d92382758394c48
Contents?: true
Size: 1.62 KB
Versions: 3
Compression:
Stored size: 1.62 KB
Contents
#encoding:utf-8 require 'spec_helper' describe WashOut::Dispatcher do class TestBody attr_accessor :read def initialize(read); @read = read; end end class TestRequest attr_accessor :body def initialize(body); @body = body; end end class Dispatcher < ApplicationController include WashOut::SOAP def self.mock(text="") dispatcher = self.new dispatcher.request = TestRequest.new(TestBody.new(text)) dispatcher end def params @_params end end it "finds nested hashes" do WashOut::Dispatcher.deep_select(:foo => 1){|k,v| k == :foo}.should == [1] WashOut::Dispatcher.deep_select({:foo => {:foo => 1}}){|k,v| k == :foo}.should == [{:foo => 1}, 1] end it "replaces nested hashed" do WashOut::Dispatcher.deep_replace_href({:foo => {:@href => 1}}, {1 => 2}).should == {:foo => 2} WashOut::Dispatcher.deep_replace_href({:bar => {:foo => {:@href => 1}}}, {1 => 2}).should == {:bar => {:foo => 2}} end it "parses typical request" do dispatcher = Dispatcher.mock("<foo>1</foo>") dispatcher._parse_soap_parameters dispatcher.params.should == {:foo => "1"} end it "parses href request" do dispatcher = Dispatcher.mock <<-XML <request> <entities href="#id1"> </entities> </request> <entity id="id1"> <foo><bar>1</bar></foo> <sub href="#id2" /> </entity> <ololo id="id2"> <foo>1</foo> </ololo> XML dispatcher._parse_soap_parameters dispatcher.params[:request][:entities].should == {:foo=>{:bar=>"1"}, :sub=>{:foo=>"1", :@id=>"id2"}, :@id=>"id1"} end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wash_out-0.5.6 | spec/lib/wash_out/dispatcher_spec.rb |
wash_out-0.5.4 | spec/lib/wash_out/dispatcher_spec.rb |
wash_out-0.5.3 | spec/lib/wash_out/dispatcher_spec.rb |