spec/amf/class_mapping_spec.rb in RocketAMF-0.0.7 vs spec/amf/class_mapping_spec.rb in RocketAMF-0.1.0

- old
+ new

@@ -1,16 +1,17 @@ require File.dirname(__FILE__) + '/../spec_helper.rb' -describe RocketAMF::ClassMapping do - before(:all) do - class ClassMappingTest - attr_accessor :prop_a - attr_accessor :prop_b - attr_accessor :prop_c - end - end +class ClassMappingTest + attr_accessor :prop_a + attr_accessor :prop_b + attr_accessor :prop_c +end +class ClassMappingTest2 < ClassMappingTest; end; +module ANamespace; class TestRubyClass; end; end + +describe RocketAMF::ClassMapping do before :each do @mapper = RocketAMF::ClassMapping.new @mapper.define do |m| m.map :as => 'ASClass', :ruby => 'ClassMappingTest' end @@ -32,11 +33,10 @@ it "should instantiate a ruby class" do @mapper.get_ruby_obj('ASClass').should be_a(ClassMappingTest) end it "should properly instantiate namespaced classes" do - module ANamespace; class TestRubyClass; end; end @mapper.define {|m| m.map :as => 'ASClass', :ruby => 'ANamespace::TestRubyClass'} @mapper.get_ruby_obj('ASClass').should be_a(ANamespace::TestRubyClass) end it "should return a hash with original type if not mapped" do @@ -108,11 +108,11 @@ end end describe "property extractor" do it "should extract hash properties" do - hash = {:a => 'test1', :b => 'test2'} + hash = {:a => 'test1', 'b' => 'test2'} props = @mapper.props_for_serialization(hash) props.should == {'a' => 'test1', 'b' => 'test2'} end it "should extract object properties" do @@ -123,11 +123,9 @@ hash = @mapper.props_for_serialization obj hash.should == {'prop_a' => 'Test A', 'prop_b' => 'Test B', 'prop_c' => nil} end it "should extract inherited object properties" do - class ClassMappingTest2 < ClassMappingTest - end obj = ClassMappingTest2.new obj.prop_a = 'Test A' obj.prop_b = 'Test B' hash = @mapper.props_for_serialization obj \ No newline at end of file