spec/amf/class_mapping_spec.rb in RocketAMF-0.0.5 vs spec/amf/class_mapping_spec.rb in RocketAMF-0.0.6
- old
+ new
@@ -14,23 +14,23 @@
@mapper.define do |m|
m.map :as => 'ASClass', :ruby => 'ClassMappingTest'
end
end
- it "should return AS class name for ruby objects" do
- @mapper.get_as_class_name(ClassMappingTest.new).should == 'ASClass'
- @mapper.get_as_class_name('ClassMappingTest').should == 'ASClass'
- end
+ describe "class name mapping" do
+ it "should allow resetting of mappings back to defaults" do
+ @mapper.reset
+ @mapper.get_as_class_name('ClassMappingTest').should be_nil
+ @mapper.get_as_class_name('RocketAMF::Values::AcknowledgeMessage').should_not be_nil
+ end
- it "should allow config modification" do
- @mapper.define do |m|
- m.map :as => 'SecondClass', :ruby => 'ClassMappingTest'
+ it "should return AS class name for ruby objects" do
+ @mapper.get_as_class_name(ClassMappingTest.new).should == 'ASClass'
+ @mapper.get_as_class_name('ClassMappingTest').should == 'ASClass'
+ @mapper.get_as_class_name('BadClass').should be_nil
end
- @mapper.get_as_class_name(ClassMappingTest.new).should == 'SecondClass'
- end
- describe "ruby object generator" do
it "should instantiate a ruby class" do
@mapper.get_ruby_obj('ASClass').should be_a(ClassMappingTest)
end
it "should properly instantiate namespaced classes" do
@@ -41,9 +41,41 @@
it "should return a hash with original type if not mapped" do
obj = @mapper.get_ruby_obj('UnmappedClass')
obj.should be_a(RocketAMF::Values::TypedHash)
obj.type.should == 'UnmappedClass'
+ end
+
+ it "should map special classes from AS by default" do
+ as_classes = [
+ 'flex.messaging.messages.AcknowledgeMessage',
+ 'flex.messaging.messages.CommandMessage',
+ 'flex.messaging.messages.RemotingMessage',
+ 'flex.messaging.io.ArrayCollection'
+ ]
+
+ as_classes.each do |as_class|
+ @mapper.get_ruby_obj(as_class).should_not be_a(RocketAMF::Values::TypedHash)
+ end
+ end
+
+ it "should map special classes from ruby by default" do
+ ruby_classes = [
+ 'RocketAMF::Values::AcknowledgeMessage',
+ 'RocketAMF::Values::ErrorMessage',
+ 'RocketAMF::Values::ArrayCollection'
+ ]
+
+ ruby_classes.each do |obj|
+ @mapper.get_as_class_name(obj).should_not be_nil
+ end
+ end
+
+ it "should allow config modification" do
+ @mapper.define do |m|
+ m.map :as => 'SecondClass', :ruby => 'ClassMappingTest'
+ end
+ @mapper.get_as_class_name(ClassMappingTest.new).should == 'SecondClass'
end
end
describe "ruby object populator" do
it "should populate a ruby class" do
\ No newline at end of file