test/casting_test.rb in datanoise-actionwebservice-2.2.2 vs test/casting_test.rb in datanoise-actionwebservice-2.3.2

- old
+ new

@@ -1,8 +1,10 @@ require File.dirname(__FILE__) + '/abstract_unit' module CastingTest + class A < ActionWebService::Struct; end + class B < A; end class API < ActionWebService::API::Base api_method :int, :expects => [:int] api_method :str, :expects => [:string] api_method :base64, :expects => [:base64] api_method :bool, :expects => [:bool] @@ -12,10 +14,12 @@ api_method :date, :expects => [:date] api_method :int_array, :expects => [[:int]] api_method :str_array, :expects => [[:string]] api_method :bool_array, :expects => [[:bool]] + + api_method :a, :expects => [A] end end class TC_Casting < Test::Unit::TestCase include CastingTest @@ -75,9 +79,13 @@ cast_expects(:bool_array, ['false', 'blahblah']) end assert_raises ArgumentError do cast_expects(:int_array, ['1', '2.021', '4']) end + end + + def test_structured_type_casting_with_polymorphism + assert cast_expects(:a, B.new)[0].is_a?(B) end private def cast_expects(method_name, *args) API.api_method_instance(method_name.to_sym).cast_expects([*args])