-
Notifications
You must be signed in to change notification settings - Fork 101
/
routing_spec.rb
59 lines (46 loc) · 2.39 KB
/
routing_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= controller_class_name %>Controller do
describe "route generation" do
it "should map #index" do
route_for(:controller => "<%= table_name %>", :action => "index").should == "/<%= table_name %>"
end
it "should map #new" do
route_for(:controller => "<%= table_name %>", :action => "new").should == "/<%= table_name %>/new"
end
it "should map #show" do
route_for(:controller => "<%= table_name %>", :action => "show", :id => 1).should == "/<%= table_name %>/1"
end
it "should map #edit" do
route_for(:controller => "<%= table_name %>", :action => "edit", :id => 1).should == "/<%= table_name %>/1<%= resource_edit_path %>"
end
it "should map #update" do
route_for(:controller => "<%= table_name %>", :action => "update", :id => 1).should == "/<%= table_name %>/1"
end
it "should map #destroy" do
route_for(:controller => "<%= table_name %>", :action => "destroy", :id => 1).should == "/<%= table_name %>/1"
end
end
describe "route recognition" do
it "should generate params for #index" do
params_from(:get, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "index"}
end
it "should generate params for #new" do
params_from(:get, "/<%= table_name %>/new").should == {:controller => "<%= table_name %>", :action => "new"}
end
it "should generate params for #create" do
params_from(:post, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "create"}
end
it "should generate params for #show" do
params_from(:get, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "show", :id => "1"}
end
it "should generate params for #edit" do
params_from(:get, "/<%= table_name %>/1<%= resource_edit_path %>").should == {:controller => "<%= table_name %>", :action => "edit", :id => "1"}
end
it "should generate params for #update" do
params_from(:put, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "update", :id => "1"}
end
it "should generate params for #destroy" do
params_from(:delete, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "destroy", :id => "1"}
end
end
end