spec/motion-resource/urls_spec.rb in motion-resource-0.1.2 vs spec/motion-resource/urls_spec.rb in motion-resource-0.1.3

- old
+ new

@@ -17,10 +17,22 @@ it "should default to json for extension" do MotionResource::Base.extension.should == '.json' end + it "should have a default collection URL" do + Rectangle.collection_url_or_default.should == "rectangles" + end + + it "should have a default member URL" do + Rectangle.member_url_or_default.should == "rectangles/:id" + end + + it "should have a default member URL with custom primary key" do + Membership.member_url_or_default.should == "memberships/:membership_id" + end + it "should define custom url method" do comment = Comment.new comment.should.respond_to :by_user_url comment.by_user_url.should.is_a String end @@ -41,12 +53,27 @@ comment.should.respond_to :collection_url comment.collection_url.should.is_a String comment.collection_url.should == 'comments' end + it "should fall back to default URL in collection_url method" do + rectangle = Rectangle.new + rectangle.collection_url.should == 'rectangles' + end + it "should define convenience member_url method" do comment = Comment.new comment.should.respond_to :member_url comment.member_url.should.is_a String comment.member_url(id: 10).should == 'comments/10' + end + + it "should fall back to default URL in collection_url method" do + rectangle = Rectangle.new + rectangle.member_url(:id => 10).should == 'rectangles/10' + end + + it "should fall back to default URL in collection_url method with custom primary key" do + membership = Membership.new + membership.member_url(:membership_id => 10).should == 'memberships/10' end end