public
Description: Custom controller spec macros, with an included 'custom_scaffold' generator.
Clone URL: git://github.com/technoweenie/rspec_on_rails_on_crack.git
Search Repo:
update generator
technoweenie (author)
Wed Jan 09 19:28:41 -0800 2008
commit  87ffae3a8720d56f47f2ff954ab97b042793c981
tree    5475d81cbbc4a31d940db4272bce329eba4ed315
parent  0d0d28a0ea857d18017bd535c2c2fef6b91c9543
...
29
30
31
32
33
34
35
36
37
38
...
48
49
50
 
 
 
 
51
52
53
...
29
30
31
 
 
 
 
32
33
34
...
44
45
46
47
48
49
50
51
52
53
0
@@ -29,10 +29,6 @@
0
     end
0
   end
0
 
0
- def edit
0
- @<%= file_name %> = <%= class_name %>.find(params[:id])
0
- end
0
-
0
   def create
0
     @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
0
 
0
@@ -48,6 +44,10 @@
0
         format.json { render :json => @<%= file_name %>.errors, :status => :unprocessable_entity }
0
       end
0
     end
0
+ end
0
+
0
+ def edit
0
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
0
   end
0
 
0
   def update
...
10
11
12
13
14
 
 
15
16
17
...
19
20
21
22
23
 
 
24
25
26
...
36
37
38
39
40
 
 
41
42
43
...
45
46
47
48
 
49
50
51
52
53
...
63
64
65
66
 
67
68
69
70
71
72
73
 
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
...
104
105
106
107
108
 
 
109
110
111
...
116
117
118
119
120
 
 
121
122
123
...
130
131
132
133
134
 
 
135
136
137
138
...
142
143
144
145
146
 
 
147
148
149
150
 
 
 
 
 
 
 
 
 
 
 
 
 
151
152
153
...
163
164
165
166
167
 
 
168
169
170
...
175
176
177
178
179
 
 
180
181
182
...
188
189
190
191
192
 
 
193
194
195
...
200
201
202
203
204
 
 
205
206
207
208
...
216
217
218
219
220
 
 
221
222
223
224
225
226
227
228
 
 
229
230
231
...
10
11
12
 
 
13
14
15
16
17
...
19
20
21
 
 
22
23
24
25
26
...
36
37
38
 
 
39
40
41
42
43
...
45
46
47
 
48
49
50
51
52
53
...
63
64
65
 
66
67
68
69
70
71
72
 
73
74
75
76
77
78
 
 
 
 
 
 
 
 
 
 
 
 
 
79
80
81
...
91
92
93
 
 
94
95
96
97
98
...
103
104
105
 
 
106
107
108
109
110
...
117
118
119
 
 
120
121
122
123
124
125
...
129
130
131
 
 
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
...
163
164
165
 
 
166
167
168
169
170
...
175
176
177
 
 
178
179
180
181
182
...
188
189
190
 
 
191
192
193
194
195
...
200
201
202
 
 
203
204
205
206
207
208
...
216
217
218
 
 
219
220
221
222
223
224
225
226
 
 
227
228
229
230
231
0
@@ -10,8 +10,8 @@
0
     <%= class_name %>.stub!(:find).with(:all).and_return(@<%= table_name %>)
0
   end
0
   
0
- it.assigns :<%= table_name %>
0
- it.renders :template, :index
0
+ it_assigns :<%= table_name %>
0
+ it_renders :template, :index
0
 
0
 <% %w(xml json).each do |format|
0
 %> describe <%= controller_class_name %>Controller, "(<%= format %>)" do
0
@@ -19,8 +19,8 @@
0
     
0
     act! { get :index, :format => '<%= format %>' }
0
 
0
- it.assigns :<%= table_name %>
0
- it.renders :<%= format %>, :<%= table_name %>
0
+ it_assigns :<%= table_name %>
0
+ it_renders :<%= format %>, :<%= table_name %>
0
   end
0
 
0
 <% end %>
0
@@ -36,8 +36,8 @@
0
     <%= class_name %>.stub!(:find).with('1').and_return(@<%= file_name %>)
0
   end
0
   
0
- it.assigns :<%= file_name %>
0
- it.renders :template, :show
0
+ it_assigns :<%= file_name %>
0
+ it_renders :template, :show
0
   
0
 <% %w(xml json).each do |format|
0
 %> describe <%= controller_class_name %>Controller, "(<%= format %>)" do
0
@@ -45,7 +45,7 @@
0
     
0
     act! { get :show, :id => 1, :format => '<%= format %>' }
0
 
0
- it.renders :<%= format %>, :<%= file_name %>
0
+ it_renders :<%= format %>, :<%= file_name %>
0
   end
0
 
0
 <% end %>
0
0
0
@@ -63,32 +63,19 @@
0
     assigns[:<%= file_name %>].should be_new_record
0
   end
0
   
0
- it.renders :template, :new
0
+ it_renders :template, :new
0
   
0
 <% %w(xml json).each do |format|
0
 %> describe <%= controller_class_name %>Controller, "(<%= format %>)" do
0
     # fixture definition
0
     act! { get :new, :format => '<%= format %>' }
0
 
0
- it.renders :<%= format %>, :<%= file_name %>
0
+ it_renders :<%= format %>, :<%= file_name %>
0
   end
0
 
0
 <% end %>
0
 end
0
 
0
-describe <%= controller_class_name %>Controller, "GET #edit" do
0
- # fixture definition
0
- act! { get :edit, :id => 1 }
0
-
0
- before do
0
- @<%= file_name %> = <%= table_name %>(:default)
0
- <%= class_name %>.stub!(:find).with('1').and_return(@<%= file_name %>)
0
- end
0
-
0
- it.assigns :<%= file_name %>
0
- it.renders :template, :edit
0
-end
0
-
0
 describe <%= controller_class_name %>Controller, "POST #create" do
0
   before do
0
     @attributes = {}
0
@@ -104,8 +91,8 @@
0
       @<%= file_name %>.stub!(:save).and_return(true)
0
     end
0
     
0
- it.assigns :<%= file_name %>, :flash => { :notice => :not_nil }
0
- it.redirects_to { <%= file_name %>_path(@<%= file_name %>) }
0
+ it_assigns :<%= file_name %>, :flash => { :notice => :not_nil }
0
+ it_redirects_to { <%= file_name %>_path(@<%= file_name %>) }
0
   end
0
 
0
   describe <%= controller_class_name %>Controller, "(unsuccessful creation)" do
0
@@ -116,8 +103,8 @@
0
       @<%= file_name %>.stub!(:save).and_return(false)
0
     end
0
     
0
- it.assigns :<%= file_name %>
0
- it.renders :template, :new
0
+ it_assigns :<%= file_name %>
0
+ it_renders :template, :new
0
   end
0
   
0
 <% %w(xml json).each do |format|
0
@@ -130,8 +117,8 @@
0
       @<%= file_name %>.stub!(:to_<%= format %>).and_return("mocked content")
0
     end
0
     
0
- it.assigns :<%= file_name %>, :headers => { :Location => lambda { <%= file_name %>_url(@<%= file_name %>) } }
0
- it.renders :<%= format %>, :<%= file_name %>, :status => :created
0
+ it_assigns :<%= file_name %>, :headers => { :Location => lambda { <%= file_name %>_url(@<%= file_name %>) } }
0
+ it_renders :<%= format %>, :<%= file_name %>, :status => :created
0
   end
0
   
0
   describe <%= controller_class_name %>Controller, "(unsuccessful creation, <%= format %>)" do
0
0
@@ -142,12 +129,25 @@
0
       @<%= file_name %>.stub!(:save).and_return(false)
0
     end
0
     
0
- it.assigns :<%= file_name %>
0
- it.renders :<%= format %>, "<%= file_name %>.errors", :status => :unprocessable_entity
0
+ it_assigns :<%= file_name %>
0
+ it_renders :<%= format %>, "<%= file_name %>.errors", :status => :unprocessable_entity
0
   end
0
 
0
 <% end %>end
0
 
0
+describe <%= controller_class_name %>Controller, "GET #edit" do
0
+ # fixture definition
0
+ act! { get :edit, :id => 1 }
0
+
0
+ before do
0
+ @<%= file_name %> = <%= table_name %>(:default)
0
+ <%= class_name %>.stub!(:find).with('1').and_return(@<%= file_name %>)
0
+ end
0
+
0
+ it_assigns :<%= file_name %>
0
+ it_renders :template, :edit
0
+end
0
+
0
 describe <%= controller_class_name %>Controller, "PUT #update" do
0
   before do
0
     @attributes = {}
0
@@ -163,8 +163,8 @@
0
       @<%= file_name %>.stub!(:save).and_return(true)
0
     end
0
     
0
- it.assigns :<%= file_name %>, :flash => { :notice => :not_nil }
0
- it.redirects_to { <%= file_name %>_path(@<%= file_name %>) }
0
+ it_assigns :<%= file_name %>, :flash => { :notice => :not_nil }
0
+ it_redirects_to { <%= file_name %>_path(@<%= file_name %>) }
0
   end
0
 
0
   describe <%= controller_class_name %>Controller, "(unsuccessful save)" do
0
@@ -175,8 +175,8 @@
0
       @<%= file_name %>.stub!(:save).and_return(false)
0
     end
0
     
0
- it.assigns :<%= file_name %>
0
- it.renders :template, :edit
0
+ it_assigns :<%= file_name %>
0
+ it_renders :template, :edit
0
   end
0
   
0
 <% %w(xml json).each do |format|
0
@@ -188,8 +188,8 @@
0
       @<%= file_name %>.stub!(:save).and_return(true)
0
     end
0
     
0
- it.assigns :<%= file_name %>
0
- it.renders :blank
0
+ it_assigns :<%= file_name %>
0
+ it_renders :blank
0
   end
0
   
0
   describe <%= controller_class_name %>Controller, "(unsuccessful save, <%= format %>)" do
0
@@ -200,8 +200,8 @@
0
       @<%= file_name %>.stub!(:save).and_return(false)
0
     end
0
     
0
- it.assigns :<%= file_name %>
0
- it.renders :<%= format %>, "<%= file_name %>.errors", :status => :unprocessable_entity
0
+ it_assigns :<%= file_name %>
0
+ it_renders :<%= format %>, "<%= file_name %>.errors", :status => :unprocessable_entity
0
   end
0
 
0
 <% end %>end
0
0
@@ -216,16 +216,16 @@
0
     <%= class_name %>.stub!(:find).with('1').and_return(@<%= file_name %>)
0
   end
0
 
0
- it.assigns :<%= file_name %>
0
- it.redirects_to { <%= table_name %>_path }
0
+ it_assigns :<%= file_name %>
0
+ it_redirects_to { <%= table_name %>_path }
0
   
0
 <% %w(xml json).each do |format|
0
 %> describe <%= controller_class_name %>Controller, "(<%= format %>)" do
0
     # fixture definition
0
     act! { delete :destroy, :id => 1, :format => '<%= format %>' }
0
 
0
- it.assigns :<%= file_name %>
0
- it.renders :blank
0
+ it_assigns :<%= file_name %>
0
+ it_renders :blank
0
   end
0
 
0
 <% end %>

Comments

    No one has commented yet.