-
Notifications
You must be signed in to change notification settings - Fork 6
/
remote_model_spec.rb
35 lines (28 loc) · 949 Bytes
/
remote_model_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class CustomUrlModel < RemoteModule::RemoteModel
collection_url "collection"
member_url "collection/:id"
custom_urls :a_url => "custom", :format_url => "custom/:var",
:method_url => "custom/:a_method"
def id
8
end
def a_method
10
end
end
describe "URLs" do
it "should make visible urls at class and instance level" do
CustomUrlModel.a_url.should == "custom"
CustomUrlModel.collection_url.should == "collection"
CustomUrlModel.member_url.should == "collection/:id"
# NOTE that Class.member_url(params) won't work (it's the setter).
CustomUrlModel.member_url.format(:id => 9).should == "collection/9"
c = CustomUrlModel.new
c.collection_url.should == "collection"
c.member_url.should == "collection/8"
c.a_url.should == "custom"
CustomUrlModel.format_url.should == "custom/:var"
c.format_url(:var => 3).should == "custom/3"
c.method_url.should == "custom/10"
end
end