Skip to content
Browse files

starting the test for relationships API dsl

  • Loading branch information...
1 parent 6f54bfb commit 8832f567334196e9572f52942c46634446e73936 @clayallsopp committed Sep 21, 2012
Showing with 28 additions and 0 deletions.
  1. +28 −0 spec/model/resource_dsl_spec.rb
View
28 spec/model/resource_dsl_spec.rb
@@ -0,0 +1,28 @@
+class Friend < Maglev::Model
+ collection_path "/friends"
+ member_path "/friends/:id"
+end
+
+class User < Maglev::Model
+ has_many :friends
+ has_many :dsl_friends, class_name: "Friend", collection_path: "/my_friends", member_path: "/my_friends/:id"
+end
+
+describe "Nested resource DSL" do
+ it "should work" do
+ true.should == true
+ u = User.new
+
+ u.friends.collection_path.should == '/friends'
+ u.friends.member_path.format(id: 5).should == '/friends/5'
+
+ u.dsl_friends.collection_path.should == '/my_friends'
+ u.dsl_friends.member_path.format(id: 5).should == '/my_friends/5'
+
+ #u.friends.find(10) do |friends|
+ #end
+
+ #u.dsl_friends.find(10) do |friends|
+ #end
+ end
+end

0 comments on commit 8832f56

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