/
timesheets_routing_spec.rb
39 lines (31 loc) · 1.42 KB
/
timesheets_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
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe TimesheetsController do
describe "route generation" do
it "maps #index" do
route_for(:controller => "timesheets", :action => "index").should == "/timesheets"
end
it "maps #create" do
route_for(:controller => "timesheets", :action => "create").should == {:path => "/timesheets", :method => :post}
end
it "maps #update" do
route_for(:controller => "timesheets", :action => "update", :id => "1").should == {:path =>"/timesheets/1", :method => :put}
end
end
describe "route recognition" do
it "recognizes '/' as #index" do
params_from(:get, '/').should == {:controller => "timesheets", :action => "index"}
end
it "generates params for #index" do
params_from(:get, '/timesheets').should == {:controller => "timesheets", :action => "index"}
end
it "generates params for #edit given date" do
params_from(:get, '/timesheets/2009/4/13').should == {:controller => "timesheets", :action => "edit", :year => "2009", :month => "4", :day => "13"}
end
it "generates params for #create" do
params_from(:post, "/timesheets").should == {:controller => "timesheets", :action => "create"}
end
it "generates params for #update" do
params_from(:put, '/timesheets/1').should == {:controller => "timesheets", :action => "update", :id => "1"}
end
end
end