Sha256: 649bbf80cff1240f89d6f32cb0dcee1433a3014e40e106c2a1a2d5c2649cbbde
Contents?: true
Size: 1.62 KB
Versions: 2
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
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
nogara-wash_out-0.5.2 | spec/wash_out/dispatcher_spec.rb |
wash_out-0.5.2 | spec/wash_out/dispatcher_spec.rb |