akitaonrails-dry_scaffold 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/CHANGELOG.textile +43 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.textile +445 -0
  4. data/Rakefile +48 -0
  5. data/TODO.textile +40 -0
  6. data/bin/dmodel +3 -0
  7. data/bin/dry_model +3 -0
  8. data/bin/dry_scaffold +3 -0
  9. data/bin/dscaffold +3 -0
  10. data/config/scaffold.yml +31 -0
  11. data/generators/dmodel/dmodel_generator.rb +15 -0
  12. data/generators/dry_model/USAGE +9 -0
  13. data/generators/dry_model/dry_model_generator.rb +134 -0
  14. data/generators/dry_model/prototypes/active_record_migration.rb +17 -0
  15. data/generators/dry_model/prototypes/active_record_model.rb +9 -0
  16. data/generators/dry_model/prototypes/fixture_data/active_record_fixtures.yml +3 -0
  17. data/generators/dry_model/prototypes/fixture_data/factory_girl_factories.rb +4 -0
  18. data/generators/dry_model/prototypes/fixture_data/machinist_blueprints.rb +8 -0
  19. data/generators/dry_model/prototypes/tests/rspec/unit_test.rb +9 -0
  20. data/generators/dry_model/prototypes/tests/shoulda/unit_test.rb +20 -0
  21. data/generators/dry_model/prototypes/tests/test_unit/unit_test.rb +15 -0
  22. data/generators/dry_model/templates/models/active_record_migration.rb +23 -0
  23. data/generators/dry_model/templates/models/active_record_model.rb +15 -0
  24. data/generators/dry_model/templates/models/fixture_data/active_record_fixtures.yml +6 -0
  25. data/generators/dry_model/templates/models/fixture_data/factory_girl_factories.rb +5 -0
  26. data/generators/dry_model/templates/models/fixture_data/machinist_blueprints.rb +9 -0
  27. data/generators/dry_model/templates/models/tests/rspec/unit_test.rb +11 -0
  28. data/generators/dry_model/templates/models/tests/shoulda/unit_test.rb +23 -0
  29. data/generators/dry_model/templates/models/tests/test_unit/unit_test.rb +17 -0
  30. data/generators/dry_scaffold/USAGE +11 -0
  31. data/generators/dry_scaffold/dry_scaffold_generator.rb +401 -0
  32. data/generators/dry_scaffold/prototypes/controllers/action_controller.rb +135 -0
  33. data/generators/dry_scaffold/prototypes/controllers/inherited_resources_controller.rb +25 -0
  34. data/generators/dry_scaffold/prototypes/controllers/tests/rspec/functional_test.rb +56 -0
  35. data/generators/dry_scaffold/prototypes/controllers/tests/shoulda/functional_test.rb +67 -0
  36. data/generators/dry_scaffold/prototypes/controllers/tests/test_unit/functional_test.rb +70 -0
  37. data/generators/dry_scaffold/prototypes/helpers/helper.rb +3 -0
  38. data/generators/dry_scaffold/prototypes/helpers/tests/rspec/unit_test.rb +9 -0
  39. data/generators/dry_scaffold/prototypes/helpers/tests/shoulda/unit_test.rb +9 -0
  40. data/generators/dry_scaffold/prototypes/helpers/tests/test_unit/unit_test.rb +9 -0
  41. data/generators/dry_scaffold/prototypes/views/builder/index.atom.builder +20 -0
  42. data/generators/dry_scaffold/prototypes/views/builder/index.rss.builder +21 -0
  43. data/generators/dry_scaffold/prototypes/views/haml/_form.html.haml +3 -0
  44. data/generators/dry_scaffold/prototypes/views/haml/_item.html.haml +9 -0
  45. data/generators/dry_scaffold/prototypes/views/haml/edit.html.haml +10 -0
  46. data/generators/dry_scaffold/prototypes/views/haml/index.html.haml +17 -0
  47. data/generators/dry_scaffold/prototypes/views/haml/layout.html.haml +18 -0
  48. data/generators/dry_scaffold/prototypes/views/haml/new.html.haml +10 -0
  49. data/generators/dry_scaffold/prototypes/views/haml/show.html.haml +13 -0
  50. data/generators/dry_scaffold/templates/controllers/action_controller.rb +250 -0
  51. data/generators/dry_scaffold/templates/controllers/inherited_resources_controller.rb +26 -0
  52. data/generators/dry_scaffold/templates/controllers/tests/rspec/functional_test.rb +58 -0
  53. data/generators/dry_scaffold/templates/controllers/tests/shoulda/functional_test.rb +90 -0
  54. data/generators/dry_scaffold/templates/controllers/tests/test_unit/functional_test.rb +87 -0
  55. data/generators/dry_scaffold/templates/helpers/helper.rb +3 -0
  56. data/generators/dry_scaffold/templates/helpers/tests/rspec/unit_test.rb +9 -0
  57. data/generators/dry_scaffold/templates/helpers/tests/shoulda/unit_test.rb +9 -0
  58. data/generators/dry_scaffold/templates/helpers/tests/test_unit/unit_test.rb +9 -0
  59. data/generators/dry_scaffold/templates/views/builder/index.atom.builder +20 -0
  60. data/generators/dry_scaffold/templates/views/builder/index.rss.builder +21 -0
  61. data/generators/dry_scaffold/templates/views/haml/_form.html.haml +13 -0
  62. data/generators/dry_scaffold/templates/views/haml/_item.html.haml +10 -0
  63. data/generators/dry_scaffold/templates/views/haml/edit.html.haml +18 -0
  64. data/generators/dry_scaffold/templates/views/haml/index.html.haml +20 -0
  65. data/generators/dry_scaffold/templates/views/haml/layout.html.haml +19 -0
  66. data/generators/dry_scaffold/templates/views/haml/new.html.haml +18 -0
  67. data/generators/dry_scaffold/templates/views/haml/show.html.haml +13 -0
  68. data/generators/dscaffold/dscaffold_generator.rb +15 -0
  69. data/lib/dry_generator.rb +192 -0
  70. data/lib/setup_helper.rb +36 -0
  71. data/rails/init.rb +3 -0
  72. data/tasks/dry_scaffold.rake +95 -0
  73. metadata +129 -0
@@ -0,0 +1,9 @@
1
+ - content_tag_for(:tr, duck) do
2
+ %td.title= h duck.try(:title)
3
+ %td.description= h duck.try(:description)
4
+ %td.actions
5
+ = link_to 'Show', duck_url(duck)
6
+ |
7
+ = link_to 'Edit', edit_duck_url(duck)
8
+ |
9
+ = link_to 'Destroy', duck_url(duck), :confirm => 'Are you sure?', :method => :delete
@@ -0,0 +1,10 @@
1
+ %h1.heading
2
+ = "Editing duck %s" % @duck.id
3
+
4
+ - semantic_form_for(@duck) do |form|
5
+ = render 'form', :form => form
6
+ - form.buttons do
7
+ = form.commit_button 'Update'
8
+
9
+ %p.actions
10
+ = link_to 'Cancel', ducks_url
@@ -0,0 +1,17 @@
1
+ %h1.heading
2
+ = 'Ducks'
3
+
4
+ %p.actions
5
+ = link_to 'New duck', new_duck_url
6
+
7
+ %table
8
+ %thead.header
9
+ %tr
10
+ %th.title= 'Title'
11
+ %th.description= 'Description'
12
+ %th.actions= 'Actions'
13
+ %tbody.items.resources
14
+ - @ducks.each do |duck|
15
+ = render 'item', :duck => duck
16
+
17
+ = will_paginate(@ducks)
@@ -0,0 +1,18 @@
1
+ !!! 1.1
2
+ %html{html_attrs(I18n.locale).update(:lang => nil)}
3
+ %head
4
+ %title= "#{controller_class_name}: #{controller.action_name}"
5
+
6
+ = stylesheet_link_tag 'screen', :media => 'screen, projection'
7
+ = stylesheet_link_tag 'print', :media => 'print'
8
+ /[if IE]
9
+ = stylesheet_link_tag 'ie', :media => 'screen, projection'
10
+ = stylesheet_link_tag 'scaffold'
11
+
12
+ = javascript_link_tag :defaults
13
+
14
+ %body{:id => "#{controller.controller_name}_#{controller.action_name}", :class => "#{controller.controller_name}_controller #{controller.action_name}_action"}
15
+
16
+ %p.flash{:style => 'color: green'}= flash[:notice]
17
+
18
+ = yield
@@ -0,0 +1,10 @@
1
+ %h1.heading
2
+ = 'New duck'
3
+
4
+ - semantic_form_for(@duck) do |form|
5
+ = render 'form', :form => form
6
+ - form.buttons do
7
+ = form.commit_button 'Create'
8
+
9
+ %p.actions
10
+ = link_to 'Cancel', ducks_url
@@ -0,0 +1,13 @@
1
+ %h1.heading
2
+ = "Duck %s" % @duck.id
3
+
4
+ - content_tag_for(:dl, @duck) do
5
+ %dt.label= 'Title'
6
+ %dd.title= h @duck.try(:title)
7
+ %dt.label= 'Description'
8
+ %dd.description= h @duck.try(:description)
9
+
10
+ %p.actions
11
+ = link_to 'Edit', edit_duck_url(@duck)
12
+ |
13
+ = link_to 'Index', ducks_url
@@ -0,0 +1,250 @@
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+
3
+ <% if actions -%>
4
+ before_filter :load_resource, :only => [<%= symbol_array_to_expression(actions & DryScaffoldGenerator::DEFAULT_MEMBER_AUTOLOAD_ACTIONS) %>]
5
+ <% end -%>
6
+ <% if actions -%>
7
+ before_filter :load_and_paginate_resources, :only => [<%= symbol_array_to_expression(actions & DryScaffoldGenerator::DEFAULT_COLLECTION_AUTOLOAD_ACTIONS) %>]
8
+
9
+ <% end -%>
10
+ <% if actions.include?(:index) -%>
11
+ <% formats.each do |_format| -%>
12
+ # GET /<%= plural_name %><%= ".#{_format}" unless _format == :html %>
13
+ <% end -%>
14
+ def index
15
+ respond_to do |format|
16
+ <% formats.each do |_format| -%>
17
+ <% case _format when :html then -%>
18
+ format.html # index.html.haml
19
+ <% when :js then -%>
20
+ format.js # index.js.rjs
21
+ <% when :xml, :json then -%>
22
+ format.<%= _format %> { render :<%= _format %> => @<%= plural_name %> }
23
+ <% when :yml, :yaml then -%>
24
+ format.yaml { render :text => @<%= plural_name %>.to_yaml, :content_type => :'text/yaml' }
25
+ <% when :txt, :text then -%>
26
+ format.txt { render :text => @<%= plural_name %>.to_s, :content_type => :text }
27
+ <% when :atom, :rss then -%>
28
+ <% unless options[:skip_builders] -%>
29
+ format.<%= _format %> # index.<%= _format %>.builder
30
+ <% else -%>
31
+ format.<%= _format %> { }
32
+ <% end -%>
33
+ <% else -%>
34
+ format.<%= _format %> { }
35
+ <% end -%>
36
+ <% end -%>
37
+ end
38
+ end
39
+
40
+ <% end -%>
41
+ <% if actions.include?(:show) -%>
42
+ <% formats.each do |_format| -%>
43
+ # GET /<%= plural_name %>/:id<%= ".#{_format}" unless _format == :html %>
44
+ <% end -%>
45
+ def show
46
+ respond_to do |format|
47
+ <% formats.each do |_format| -%>
48
+ <% case _format when :html then -%>
49
+ format.html # show.html.haml
50
+ <% when :js then -%>
51
+ format.js # show.js.rjs
52
+ <% when :xml, :json then -%>
53
+ format.<%= _format %> { render :<%= _format %> => @<%= plural_name %> }
54
+ <% when :yml, :yaml then -%>
55
+ format.yaml { render :text => @<%= plural_name %>.to_yaml, :content_type => :'text/yaml' }
56
+ <% when :txt, :text then -%>
57
+ format.txt { render :text => @<%= plural_name %>.to_s, :content_type => :text }
58
+ <% else -%>
59
+ format.<%= _format %> { }
60
+ <% end -%>
61
+ <% end -%>
62
+ end
63
+ end
64
+
65
+ <% end -%>
66
+ <% if actions.include?(:new) -%>
67
+ <% formats.each do |_format| -%>
68
+ # GET /<%= plural_name %>/new<%= ".#{_format}" unless _format == :html %>
69
+ <% end -%>
70
+ def new
71
+ <%= resource_instance %> = <%= class_name %>.new
72
+
73
+ respond_to do |format|
74
+ <% formats.each do |_format| -%>
75
+ <% case _format when :html then -%>
76
+ format.html # new.html.haml
77
+ <% when :js then -%>
78
+ format.js # new.js.rjs
79
+ <% when :xml, :json then -%>
80
+ format.<%= _format %> { render :<%= _format %> => <%= resource_instance %> }
81
+ <% when :yml, :yaml then -%>
82
+ format.yaml { render :text => <%= resource_instance %>.to_yaml, :content_type => :'text/yaml' }
83
+ <% when :txt, :text then -%>
84
+ format.txt { render :text => <%= resource_instance %>.to_s, :content_type => :text }
85
+ <% else -%>
86
+ format.<%= _format %> { }
87
+ <% end -%>
88
+ <% end -%>
89
+ end
90
+ end
91
+
92
+ <% end -%>
93
+ <% if actions.include?(:edit) -%>
94
+ # GET /<%= plural_name %>/:id/edit
95
+ def edit
96
+ end
97
+
98
+ <% end -%>
99
+ <% if actions.include?(:create) -%>
100
+ <% formats.each do |_format| -%>
101
+ # POST /<%= plural_name %><%= ".#{_format}" unless _format == :html %>
102
+ <% end -%>
103
+ def create
104
+ <%= resource_instance %> = <%= class_name %>.new(params[:<%= singular_name %>])
105
+
106
+ respond_to do |format|
107
+ if <%= resource_instance %>.save
108
+ flash[:notice] = "<%= singular_name.humanize %> was successfully created."
109
+ <% formats.each do |_format| -%>
110
+ <% case _format when :html then -%>
111
+ format.html { redirect_to(<%= resource_instance %>) }
112
+ <% when :js then -%>
113
+ format.js # create.js.rjs
114
+ <% when :xml, :json then -%>
115
+ format.<%= _format %> { render :<%= _format %> => <%= resource_instance %>, :status => :created, :location => <%= resource_instance %> }
116
+ <% when :yml, :yaml then -%>
117
+ format.yaml { render :text => <%= resource_instance %>.to_yaml, :content_type => :'text/yaml', :status => :created, :location => <%= resource_instance %> }
118
+ <% when :txt, :text then -%>
119
+ format.txt { render :text => <%= resource_instance %>.to_s, :content_type => :text, :status => :created, :location => <%= resource_instance %> }
120
+ <% else -%>
121
+ format.<%= _format %> { }
122
+ <% end -%>
123
+ <% end -%>
124
+ else
125
+ flash[:error] = "<%= singular_name.humanize %> could not be created."
126
+ <% formats.each do |_format| -%>
127
+ <% case _format when :html then -%>
128
+ format.html { render 'new' }
129
+ <% when :js then -%>
130
+ format.js # create.js.rjs
131
+ <% when :xml, :json then -%>
132
+ format.<%= _format %> { render :<%= _format %> => <%= resource_instance %>.errors, :status => :unprocessable_entity }
133
+ <% when :yml, :yaml then -%>
134
+ format.yaml { render :text => <%= resource_instance %>.errors.to_yaml, :content_type => :'text/yaml', :status => :unprocessable_entity }
135
+ <% when :txt, :text then -%>
136
+ format.txt { render :text => <%= resource_instance %>.errors.to_s, :content_type => :text, :status => :unprocessable_entity }
137
+ <% else -%>
138
+ format.<%= _format %> { }
139
+ <% end -%>
140
+ <% end -%>
141
+ end
142
+ end
143
+ end
144
+
145
+ <% end -%>
146
+ <% if actions.include?(:update) -%>
147
+ <% formats.each do |_format| -%>
148
+ # PUT /<%= plural_name %>/:id<%= ".#{_format}" unless _format == :html %>
149
+ <% end -%>
150
+ def update
151
+ respond_to do |format|
152
+ if <%= resource_instance %>.update_attributes(params[:<%= singular_name %>])
153
+ flash[:notice] = "<%= singular_name.humanize %> was successfully updated."
154
+ <% formats.each do |_format| -%>
155
+ <% case _format when :html then -%>
156
+ format.html { redirect_to(<%= resource_instance %>) }
157
+ <% when :js then -%>
158
+ format.js # update.js.rjs
159
+ <% when :xml, :json, :yml, :yaml, :txt, :text then -%>
160
+ format.<%= _format %> { head :ok }
161
+ <% else -%>
162
+ format.<%= _format %> { head :ok }
163
+ <% end -%>
164
+ <% end -%>
165
+ else
166
+ flash[:error] = "<%= singular_name.humanize %> could not be updated."
167
+ <% formats.each do |_format| -%>
168
+ <% case _format when :html then -%>
169
+ format.html { render 'edit' }
170
+ <% when :js then -%>
171
+ format.js # update.js.rjs
172
+ <% when :xml, :json then -%>
173
+ format.<%= _format %> { render :<%= _format %> => <%= resource_instance %>.errors, :status => :unprocessable_entity }
174
+ <% when :yml, :yaml then -%>
175
+ format.yaml { render :text => <%= resource_instance %>.errors.to_yaml, :status => :unprocessable_entity }
176
+ <% when :txt, :text then -%>
177
+ format.txt { render :text => <%= resource_instance %>.errors.to_s, :status => :unprocessable_entity }
178
+ <% else -%>
179
+ format.<%= _format %> { head :unprocessable_entity }
180
+ <% end -%>
181
+ <% end -%>
182
+ end
183
+ end
184
+ end
185
+
186
+ <% end -%>
187
+ <% if actions.include?(:destroy) -%>
188
+ <% formats.each do |_format| -%>
189
+ # DELETE /<%= plural_name %>/:id<%= ".#{_format}" unless _format == :html %>
190
+ <% end -%>
191
+ def destroy
192
+ respond_to do |format|
193
+ if <%= resource_instance %>.destroy
194
+ flash[:notice] = "<%= singular_name.humanize %> was successfully destroyed."
195
+ <% formats.each do |_format| -%>
196
+ <% case _format when :html then -%>
197
+ format.html { redirect_to(<%= plural_name %>_url) }
198
+ <% when :js then -%>
199
+ format.js # destroy.js.rjs
200
+ <% when :xml, :json, :yml, :yaml, :txt, :text then -%>
201
+ format.<%= _format %> { head :ok }
202
+ <% else -%>
203
+ format.<%= _format %> { head :ok }
204
+ <% end -%>
205
+ <% end -%>
206
+ else
207
+ flash[:error] = "<%= singular_name.humanize %> could not be destroyed."
208
+ <% formats.each do |_format| -%>
209
+ <% case _format when :html then -%>
210
+ format.html { redirect_to(<%= singular_name %>_url(<%= resource_instance %>)) }
211
+ <% when :js then -%>
212
+ format.js # destroy.js.rjs
213
+ <% when :xml, :json, :yml, :yaml, :txt, :text then -%>
214
+ format.<%= _format %> { head :unprocessable_entity }
215
+ <% else -%>
216
+ format.<%= _format %> { head :unprocessable_entity }
217
+ <% end -%>
218
+ <% end -%>
219
+ end
220
+ end
221
+ end
222
+
223
+ <% end -%>
224
+ <% (actions - DryScaffoldGenerator::DEFAULT_CONTROLLER_ACTIONS).each do |action| -%>
225
+ # GET /<%= plural_name %>/<%= action.to_s %>
226
+ def <%= action.to_s %>
227
+
228
+ end
229
+
230
+ <% end -%>
231
+ protected
232
+
233
+ def collection
234
+ <% if options[:pagination] -%>
235
+ paginate_options ||= {}
236
+ paginate_options[:page] ||= (params[:page] || 1)
237
+ paginate_options[:per_page] ||= (params[:per_page] || 20)
238
+ @collection = @<%= plural_name %> ||= <%= class_name %>.paginate(paginate_options)
239
+ <% else -%>
240
+ @collection = @<%= plural_name %> ||= <%= class_name %>.all
241
+ <% end -%>
242
+ end
243
+ alias :load_and_paginate_resources :collection
244
+
245
+ def resource
246
+ @resource = <%= resource_instance %> ||= <%= class_name %>.find(params[:id])
247
+ end
248
+ alias :load_resource :resource
249
+
250
+ end
@@ -0,0 +1,26 @@
1
+ class <%= controller_class_name %>Controller < InheritedResources::Base
2
+
3
+ <% if actions -%>
4
+ actions <%= symbol_array_to_expression(actions) %>
5
+ <% end -%>
6
+ <% if formats -%>
7
+ respond_to <%= symbol_array_to_expression(formats) %>
8
+
9
+ <% end -%>
10
+ <% (actions - DryScaffoldGenerator::DEFAULT_CONTROLLER_ACTIONS).each do |action| -%>
11
+ # GET /<%= plural_name %>/<%= action.to_s %>
12
+ def <%= action.to_s %>
13
+ end
14
+
15
+ <% end -%>
16
+ <% if options[:pagination] -%>
17
+ protected
18
+
19
+ def collection
20
+ paginate_options ||= {}
21
+ paginate_options[:page] ||= (params[:page] || 1)
22
+ paginate_options[:per_page] ||= (params[:per_page] || 20)
23
+ @<%= model_plural_name %> ||= end_of_association_chain.paginate(paginate_options)
24
+ end
25
+ <% end %>
26
+ end
@@ -0,0 +1,58 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe <%= controller_class_name %>Controller do
4
+ <% if options[:fixtures] -%>
5
+ fixtures :all
6
+ <% end %>
7
+ integrate_views
8
+
9
+ it "index action should render index template" do
10
+ get :index
11
+ response.should render_template(:index)
12
+ end
13
+
14
+ it "show action should render show template" do
15
+ get :show, :id => <%= class_name %>.first
16
+ response.should render_template(:show)
17
+ end
18
+
19
+ it "new action should render new template" do
20
+ get :new
21
+ response.should render_template(:new)
22
+ end
23
+
24
+ it "create action should render new template when model is invalid" do
25
+ <%= resource_instance %> = <%= class_name %>.new
26
+ <%= resource_instance %>.stub!(:valid?).and_return(false)
27
+ <%= class_name %>.stub!(:new).and_return(<%= resource_instance %>)
28
+ lambda {
29
+ post :create, :<%= singular_name %> => {}
30
+ }.should change(<%= class_name %>, :count).by(0)
31
+ end
32
+
33
+ it "create action should redirect when model is valid" do
34
+ <%= resource_instance %> = <%= class_name %>.new
35
+ <%= resource_instance %>.stub!(:valid?).and_return(true)
36
+ <%= class_name %>.stub!(:new).and_return(<%= resource_instance %>)
37
+ lambda {
38
+ post :create, :<%= singular_name %> => {}
39
+ }.should change(<%= class_name %>, :count).by(1)
40
+ end
41
+
42
+ it "edit action should render edit template" do
43
+ get :edit, :id => <%= class_name %>.first
44
+ response.should render_template(:edit)
45
+ end
46
+
47
+ it "update action should redirect when model is valid" do
48
+ put :update, :id => <%= class_name %>.first, :<%= singular_name %> => {}
49
+ response.should redirect_to(<%= singular_name %>_url(assigns[:<%= singular_name %>]))
50
+ end
51
+
52
+ it "destroy action should destroy model and redirect to index action" do
53
+ lambda {
54
+ delete :destroy, :id => <%= class_name %>.first
55
+ }.should change(<%= class_name %>, :count).by(-1)
56
+ response.should redirect_to(<%= plural_name %>_url)
57
+ end
58
+ end
@@ -0,0 +1,90 @@
1
+ require 'test_helper'
2
+
3
+ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
4
+
5
+ <% if actions.include?(:create) -%>
6
+ context 'create' do
7
+ setup do
8
+ <%= resource_instance %> = <%= build_object %>
9
+ post :create, :<%= singular_name %> => <%= resource_instance %>.attributes
10
+ <%= resource_instance %> = <%= class_name %>.find(:all).last
11
+ end
12
+ should_redirect_to '<%= show_path %>'
13
+ end
14
+
15
+ <% end -%>
16
+ <% if actions.include?(:update) -%>
17
+ context 'update' do
18
+ setup do
19
+ <%= resource_instance %> = <%= build_object %>
20
+ put :update, :id => <%= resource_instance %>.to_param, :<%= singular_name %> => <%= resource_instance %>.attributes
21
+ end
22
+ should_redirect_to '<%= show_path %>'
23
+ end
24
+
25
+ <% end -%>
26
+ <% if actions.include?(:destroy) -%>
27
+ context 'destroy' do
28
+ setup do
29
+ <%= resource_instance %> = <%= build_object %>
30
+ delete :destroy, :id => <%= resource_instance %>.to_param
31
+ end
32
+ should_redirect_to '<%= index_path %>'
33
+ end
34
+
35
+ <% end -%>
36
+ <% if actions.include?(:new) -%>
37
+ context 'new' do
38
+ setup do
39
+ get :new
40
+ end
41
+ should_respond_with :success
42
+ should_render_template :new
43
+ should_assign_to :<%= singular_name %>
44
+ end
45
+
46
+ <% end -%>
47
+ <% if actions.include?(:edit) -%>
48
+ context 'edit' do
49
+ setup do
50
+ <%= resource_instance %> = <%= build_object %>
51
+ get :edit, :id => <%= resource_instance %>.to_param
52
+ end
53
+ should_respond_with :success
54
+ should_render_template :edit
55
+ should_assign_to :<%= singular_name %>
56
+ end
57
+
58
+ <% end -%>
59
+ <% if actions.include?(:show) -%>
60
+ context 'show' do
61
+ setup do
62
+ <%= resource_instance %> = <%= build_object %>
63
+ get :show, :id => <%= resource_instance %>.to_param
64
+ end
65
+ should_respond_with :success
66
+ should_render_template :show
67
+ should_assign_to :<%= singular_name %>
68
+ end
69
+
70
+ <% end -%>
71
+ <% if actions.include?(:index) -%>
72
+ context 'index' do
73
+ setup do
74
+ get :index
75
+ end
76
+ should_respond_with :success
77
+ should_assign_to :<%= plural_name %>
78
+ end
79
+
80
+ <% end -%>
81
+ <% (actions - DryScaffoldGenerator::DEFAULT_CONTROLLER_ACTIONS).each do |action| -%>
82
+ context '<%= action.to_s %>' do
83
+ setup do
84
+ get :<%= action.to_s %>
85
+ end
86
+ should_respond_with :success
87
+ end
88
+
89
+ <% end -%>
90
+ end