diff options
author | Leon Breedt <bitserf@gmail.com> | 2005-04-02 21:03:36 +0000 |
---|---|---|
committer | Leon Breedt <bitserf@gmail.com> | 2005-04-02 21:03:36 +0000 |
commit | aaea48fe9826b9e5d2d5b92795a297b8f238c58d (patch) | |
tree | e7c01c7f95d467f837c1f96d58dac74c3c902610 /actionwebservice/test/struct_test.rb | |
parent | aa09c770e9b5400683be11952673017295246de7 (diff) | |
download | rails-aaea48fe9826b9e5d2d5b92795a297b8f238c58d.tar.gz rails-aaea48fe9826b9e5d2d5b92795a297b8f238c58d.tar.bz2 rails-aaea48fe9826b9e5d2d5b92795a297b8f238c58d.zip |
* collapse 'ws' back into protocols, it just added complexity and indirection, and was hard to extend.
* extract casting into seperate support file
* ensure casting always does the right thing for return values, should fix interoperability issues with Ecto and possibly other XML-RPC clients
* add functional unit tests for scaffolding
* represent signature items with classes instead of symbols/Class objects, much more flexible
* tweak logging to always show casted versions of parameters and return values, if possible.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1072 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionwebservice/test/struct_test.rb')
-rw-r--r-- | actionwebservice/test/struct_test.rb | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/actionwebservice/test/struct_test.rb b/actionwebservice/test/struct_test.rb index e6f1603c73..838cc2569c 100644 --- a/actionwebservice/test/struct_test.rb +++ b/actionwebservice/test/struct_test.rb @@ -11,30 +11,44 @@ module StructTest end class TC_Struct < Test::Unit::TestCase + include StructTest + + def setup + @struct = Struct.new(:id => 5, + :name => 'hello', + :items => ['one', 'two'], + :deleted => true, + :emails => ['test@test.com']) + end + def test_members - assert_equal(5, StructTest::Struct.members.size) - assert_equal(Integer, StructTest::Struct.members[:id]) - assert_equal(String, StructTest::Struct.members[:name]) - assert_equal([String], StructTest::Struct.members[:items]) - assert_equal(TrueClass, StructTest::Struct.members[:deleted]) - assert_equal([String], StructTest::Struct.members[:emails]) + assert_equal(5, Struct.members.size) + assert_equal(Integer, Struct.members[:id].type_class) + assert_equal(String, Struct.members[:name].type_class) + assert_equal(String, Struct.members[:items].element_type.type_class) + assert_equal(TrueClass, Struct.members[:deleted].type_class) + assert_equal(String, Struct.members[:emails].element_type.type_class) end def test_initializer_and_lookup - s = StructTest::Struct.new(:id => 5, - :name => 'hello', - :items => ['one', 'two'], - :deleted => true, - :emails => ['test@test.com']) - assert_equal(5, s.id) - assert_equal('hello', s.name) - assert_equal(['one', 'two'], s.items) - assert_equal(true, s.deleted) - assert_equal(['test@test.com'], s.emails) - assert_equal(5, s['id']) - assert_equal('hello', s['name']) - assert_equal(['one', 'two'], s['items']) - assert_equal(true, s['deleted']) - assert_equal(['test@test.com'], s['emails']) + assert_equal(5, @struct.id) + assert_equal('hello', @struct.name) + assert_equal(['one', 'two'], @struct.items) + assert_equal(true, @struct.deleted) + assert_equal(['test@test.com'], @struct.emails) + assert_equal(5, @struct['id']) + assert_equal('hello', @struct['name']) + assert_equal(['one', 'two'], @struct['items']) + assert_equal(true, @struct['deleted']) + assert_equal(['test@test.com'], @struct['emails']) + end + + def test_each_pair + members = {} + @struct.each_pair do |name, type| + members[name] = type + assert ActionWebService::BaseType === type + end + assert_equal members, Struct.members end end |