Skip to content
Browse files

Tests for CamelCaseModels.

  • Loading branch information...
1 parent 3de27b4 commit da4737b261ee06cf1a663cd82e7b446ca36c6b27 @clayallsopp committed May 20, 2012
Showing with 34 additions and 0 deletions.
  1. +34 −0 spec/record_spec.rb
View
34 spec/record_spec.rb
@@ -21,6 +21,21 @@ def user_id
end
end
+class CamelCaseModel < RemoteModule::RemoteModel
+ has_one :another_camel_case_model
+ has_many :bunch_of_camel_case_models
+end
+
+class AnotherCamelCaseModel < RemoteModule::RemoteModel
+ attr_accessor :id
+
+ belongs_to :camel_case_model
+end
+
+class BunchOfCamelCaseModel < RemoteModule::RemoteModel
+ belongs_to :camel_case_model
+end
+
describe "The active record-esque stuff" do
it "creates object from hash" do
hash = {id: 5, question: "Hello my name is clay"}
@@ -76,4 +91,23 @@ def check_question_and_answers(q, answers)
end
}
end
+
+ it "works with camel cased models" do
+ c = CamelCaseModel.new({another_camel_case_model: {id: 7}, bunch_of_camel_case_models: [{}, {}]})
+ c.another_camel_case_model.class.should == AnotherCamelCaseModel
+ c.another_camel_case_model.id.should == 7
+ c.bunch_of_camel_case_models.count.should == 2
+ c.bunch_of_camel_case_models.each {|model|
+ model.class.should == BunchOfCamelCaseModel
+ }
+
+ c.setAnotherCamelCaseModel({id: 8})
+ c.another_camel_case_model.id.should == 8
+
+ c.setBunchOfCamelCaseModels([{}, {}, {}])
+ c.bunch_of_camel_case_models.count.should == 3
+ c.bunch_of_camel_case_models.each {|model|
+ model.class.should == BunchOfCamelCaseModel
+ }
+ end
end

0 comments on commit da4737b

Please sign in to comment.
Something went wrong with that request. Please try again.