changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb

changeset 16: 01fd3f10ae84
author: moriq@moriq.com
date: Mon Mar 10 10:13:18 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec_on_rails
1require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
2
3describe <%= controller_class_name %>Controller do
4 describe "route generation" do
5
6 it "should map { :controller => '<%= table_name %>', :action => 'index' } to /<%= table_name %>" do
7 route_for(:controller => "<%= table_name %>", :action => "index").should == "/<%= table_name %>"
8 end
9
10 it "should map { :controller => '<%= table_name %>', :action => 'new' } to /<%= table_name %>/new" do
11 route_for(:controller => "<%= table_name %>", :action => "new").should == "/<%= table_name %>/new"
12 end
13
14 it "should map { :controller => '<%= table_name %>', :action => 'show', :id => 1 } to /<%= table_name %>/1" do
15 route_for(:controller => "<%= table_name %>", :action => "show", :id => 1).should == "/<%= table_name %>/1"
16 end
17
18 it "should map { :controller => '<%= table_name %>', :action => 'edit', :id => 1 } to /<%= table_name %>/1<%= resource_edit_path %>" do
19 route_for(:controller => "<%= table_name %>", :action => "edit", :id => 1).should == "/<%= table_name %>/1<%= resource_edit_path %>"
20 end
21
22 it "should map { :controller => '<%= table_name %>', :action => 'update', :id => 1} to /<%= table_name %>/1" do
23 route_for(:controller => "<%= table_name %>", :action => "update", :id => 1).should == "/<%= table_name %>/1"
24 end
25
26 it "should map { :controller => '<%= table_name %>', :action => 'destroy', :id => 1} to /<%= table_name %>/1" do
27 route_for(:controller => "<%= table_name %>", :action => "destroy", :id => 1).should == "/<%= table_name %>/1"
28 end
29 end
30
31 describe "route recognition" do
32
33 it "should generate params { :controller => '<%= table_name %>', action => 'index' } from GET /<%= table_name %>" do
34 params_from(:get, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "index"}
35 end
36
37 it "should generate params { :controller => '<%= table_name %>', action => 'new' } from GET /<%= table_name %>/new" do
38 params_from(:get, "/<%= table_name %>/new").should == {:controller => "<%= table_name %>", :action => "new"}
39 end
40
41 it "should generate params { :controller => '<%= table_name %>', action => 'create' } from POST /<%= table_name %>" do
42 params_from(:post, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "create"}
43 end
44
45 it "should generate params { :controller => '<%= table_name %>', action => 'show', id => '1' } from GET /<%= table_name %>/1" do
46 params_from(:get, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "show", :id => "1"}
47 end
48
49 it "should generate params { :controller => '<%= table_name %>', action => 'edit', id => '1' } from GET /<%= table_name %>/1;edit" do
50 params_from(:get, "/<%= table_name %>/1<%= resource_edit_path %>").should == {:controller => "<%= table_name %>", :action => "edit", :id => "1"}
51 end
52
53 it "should generate params { :controller => '<%= table_name %>', action => 'update', id => '1' } from PUT /<%= table_name %>/1" do
54 params_from(:put, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "update", :id => "1"}
55 end
56
57 it "should generate params { :controller => '<%= table_name %>', action => 'destroy', id => '1' } from DELETE /<%= table_name %>/1" do
58 params_from(:delete, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "destroy", :id => "1"}
59 end
60 end
61end