objective_spec 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. data/.gitignore +2 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +13 -0
  4. data/Rakefile +59 -0
  5. data/TODO +6 -0
  6. data/VERSION +1 -0
  7. data/generators/objective_controller/USAGE +33 -0
  8. data/generators/objective_controller/objective_controller_generator.rb +45 -0
  9. data/generators/objective_controller/templates/controller_spec.rb +25 -0
  10. data/generators/objective_controller/templates/helper_spec.rb +11 -0
  11. data/generators/objective_controller/templates/view.html.haml +3 -0
  12. data/generators/objective_controller/templates/view_spec.rb +10 -0
  13. data/generators/objective_model/objective_model_generator.rb +40 -0
  14. data/generators/objective_model/templates/model_spec.rb +13 -0
  15. data/generators/objective_observer/objective_observer_generator.rb +16 -0
  16. data/generators/objective_observer/templates/observer.rb +2 -0
  17. data/generators/objective_observer/templates/observer_spec.rb +11 -0
  18. data/generators/objective_resource/.DS_Store +0 -0
  19. data/generators/objective_resource/objective_resource_generator.rb +172 -0
  20. data/generators/objective_resource/templates/.DS_Store +0 -0
  21. data/generators/objective_resource/templates/controller.rb +2 -0
  22. data/generators/objective_resource/templates/helper.rb +2 -0
  23. data/generators/objective_resource/templates/migration.rb +15 -0
  24. data/generators/objective_resource/templates/model.rb +2 -0
  25. data/generators/objective_resource/templates/rspec/functional_spec.rb +247 -0
  26. data/generators/objective_resource/templates/rspec/helper_spec.rb +11 -0
  27. data/generators/objective_resource/templates/rspec/routing_spec.rb +61 -0
  28. data/generators/objective_resource/templates/rspec/unit_spec.rb +10 -0
  29. data/generators/objective_resource/templates/rspec/views/edit_spec.rb +23 -0
  30. data/generators/objective_resource/templates/rspec/views/index_spec.rb +21 -0
  31. data/generators/objective_resource/templates/rspec/views/new_spec.rb +23 -0
  32. data/generators/objective_resource/templates/rspec/views/show_spec.rb +19 -0
  33. data/generators/objective_resource/templates/view__form.haml +5 -0
  34. data/generators/objective_resource/templates/view_edit.haml +11 -0
  35. data/generators/objective_resource/templates/view_index.haml +19 -0
  36. data/generators/objective_resource/templates/view_new.haml +9 -0
  37. data/generators/objective_resource/templates/view_show.haml +9 -0
  38. data/generators/objective_service/objective_service_generator.rb +22 -0
  39. data/generators/objective_service/templates/controller.rb +2 -0
  40. data/generators/objective_service/templates/controller_spec.rb +175 -0
  41. data/generators/objective_spec/objective_spec_generator.rb +33 -0
  42. data/generators/objective_spec/templates/support/common.rb +3 -0
  43. data/generators/objective_spec/templates/support/controller_spec_helper.rb +3 -0
  44. data/generators/objective_spec/templates/support/model_spec_helper.rb +3 -0
  45. data/generators/objective_spec/templates/support/shared_examples.rb +1 -0
  46. data/generators/objective_spec/templates/support/view_spec_helper.rb +3 -0
  47. data/generators/rspec_default_values.rb +28 -0
  48. data/init.rb +2 -0
  49. data/lib/objective_spec/assets.rb +2 -0
  50. data/lib/objective_spec/mailer_example_group.rb +14 -0
  51. data/lib/objective_spec/matchers/use_layout_matcher.rb +25 -0
  52. data/lib/objective_spec/matchers.rb +26 -0
  53. data/lib/objective_spec.rb +2 -0
  54. data/objective_spec.gemspec +95 -0
  55. data/spec/objective_spec_spec.rb +7 -0
  56. data/spec/spec_helper.rb +9 -0
  57. metadata +112 -0
@@ -0,0 +1,247 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../spec_helper')
2
+
3
+ describe <%= controller_class_name %>Controller do
4
+ describe "handling GET /<%= table_name %>" do
5
+
6
+ it "should be successful" do
7
+ <%= file_name %> = Factory(:<%= file_name %>)
8
+ <%= controller_class_name.singularize %>.stub!(:find).and_return([<%= file_name %>])
9
+ get :index
10
+ response.should be_success
11
+ end
12
+
13
+ it "should render index template" do
14
+ <%= file_name %> = Factory(:<%= file_name %>)
15
+ <%= controller_class_name.singularize %>.stub!(:find).and_return([<%= file_name %>])
16
+ get :index
17
+ response.should render_template('index')
18
+ end
19
+
20
+ it "should find all <%= table_name %>" do
21
+ <%= file_name %> = Factory(:<%= file_name %>)
22
+ <%= controller_class_name.singularize %>.should_receive(:find).with(:all).and_return([<%= file_name %>])
23
+ get :index
24
+ end
25
+
26
+ it "should assign the found <%= table_name %> for the view" do
27
+ <%= file_name %> = Factory(:<%= file_name %>)
28
+ <%= controller_class_name.singularize %>.stub!(:find).and_return([<%= file_name %>])
29
+ get :index
30
+ assigns[:<%= table_name %>].should == [<%= file_name %>]
31
+ end
32
+ end
33
+
34
+ describe "handling GET /<%= table_name %>/1" do
35
+
36
+ it "should be successful" do
37
+ <%= file_name %> = Factory(:<%= file_name %>)
38
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
39
+ get :show, :id => "1"
40
+ response.should be_success
41
+ end
42
+
43
+ it "should render show template" do
44
+ <%= file_name %> = Factory(:<%= file_name %>)
45
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
46
+ get :show, :id => "1"
47
+ response.should render_template('show')
48
+ end
49
+
50
+ it "should find the <%= file_name %> requested" do
51
+ <%= file_name %> = Factory(:<%= file_name %>)
52
+ <%= controller_class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
53
+ get :show, :id => "1"
54
+ end
55
+
56
+ it "should assign the found <%= file_name %> for the view" do
57
+ <%= file_name %> = Factory(:<%= file_name %>)
58
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
59
+ get :show, :id => "1"
60
+ assigns[:<%= file_name %>].should equal(<%= file_name %>)
61
+ end
62
+ end
63
+
64
+ describe "handling GET /<%= table_name %>/new" do
65
+
66
+ it "should be successful" do
67
+ <%= file_name %> = Factory(:<%= file_name %>)
68
+ <%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
69
+ get :new
70
+ response.should be_success
71
+ end
72
+
73
+ it "should render new template" do
74
+ <%= file_name %> = Factory(:<%= file_name %>)
75
+ <%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
76
+ get :new
77
+ response.should render_template('new')
78
+ end
79
+
80
+ it "should create an new <%= file_name %>" do
81
+ <%= file_name %> = Factory(:<%= file_name %>)
82
+ <%= controller_class_name.singularize %>.should_receive(:new).and_return(<%= file_name %>)
83
+ get :new
84
+ end
85
+
86
+ it "should not save the new <%= file_name %>" do
87
+ <%= file_name %> = Factory(:<%= file_name %>)
88
+ <%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
89
+ <%= file_name %>.should_not_receive(:save)
90
+ get :new
91
+ end
92
+
93
+ it "should assign the new <%= file_name %> for the view" do
94
+ <%= file_name %> = Factory(:<%= file_name %>)
95
+ <%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
96
+ get :new
97
+ assigns[:<%= file_name %>].should equal(<%= file_name %>)
98
+ end
99
+ end
100
+
101
+ describe "handling GET /<%= table_name %>/1/edit" do
102
+
103
+ it "should be successful" do
104
+ <%= file_name %> = Factory(:<%= file_name %>)
105
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
106
+ get :edit, :id => "1"
107
+ response.should be_success
108
+ end
109
+
110
+ it "should render edit template" do
111
+ <%= file_name %> = Factory(:<%= file_name %>)
112
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
113
+ get :edit, :id => "1"
114
+ response.should render_template('edit')
115
+ end
116
+
117
+ it "should find the <%= file_name %> requested" do
118
+ <%= file_name %> = Factory(:<%= file_name %>)
119
+ <%= controller_class_name.singularize %>.should_receive(:find).and_return(<%= file_name %>)
120
+ get :edit, :id => "1"
121
+ end
122
+
123
+ it "should assign the found <%= controller_class_name %> for the view" do
124
+ <%= file_name %> = Factory(:<%= file_name %>)
125
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
126
+ get :edit, :id => "1"
127
+ assigns[:<%= file_name %>].should equal(<%= file_name %>)
128
+ end
129
+ end
130
+
131
+ describe "handling POST /<%= table_name %>" do
132
+
133
+ describe "with successful save" do
134
+
135
+ it "should create a new <%= file_name %>" do
136
+ <%= file_name %> = Factory(:<%= file_name %>)
137
+ <%= file_name %>.stub!(:to_param).and_return("1")
138
+ <%= controller_class_name.singularize %>.should_receive(:new).with({}).and_return(<%= file_name %>)
139
+ <%= file_name %>.should_receive(:save).and_return(true)
140
+ post :create, :<%= file_name %> => {}
141
+ end
142
+
143
+ it "should redirect to the new <%= file_name %>" do
144
+ <%= file_name %> = Factory(:<%= file_name %>)
145
+ <%= file_name %>.stub!(:to_param).and_return("1")
146
+ <%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
147
+ <%= file_name %>.should_receive(:save).and_return(true)
148
+ post :create, :<%= file_name %> => {}
149
+ response.should redirect_to(<%= table_name.singularize %>_url("1"))
150
+ end
151
+
152
+ end
153
+
154
+ describe "with failed save" do
155
+
156
+ it "should re-render 'new'" do
157
+ <%= file_name %> = Factory(:<%= file_name %>)
158
+ <%= file_name %>.stub!(:to_param).and_return("1")
159
+ <%= controller_class_name.singularize %>.stub!(:new).and_return(<%= file_name %>)
160
+ <%= file_name %>.should_receive(:save).and_return(false)
161
+ post :create, :<%= file_name %> => {}
162
+ response.should render_template('new')
163
+ end
164
+
165
+ end
166
+ end
167
+
168
+ describe "handling PUT /<%= table_name %>/1" do
169
+
170
+ describe "with successful update" do
171
+
172
+ it "should find the <%= file_name %> requested" do
173
+ <%= file_name %> = Factory(:<%= file_name %>)
174
+ <%= file_name %>.stub!(:to_param).and_return("1")
175
+ <%= controller_class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
176
+ <%= file_name %>.should_receive(:update_attributes).and_return(true)
177
+ put :update, :id => "1"
178
+ end
179
+
180
+ it "should update the found <%= file_name %>" do
181
+ <%= file_name %> = Factory(:<%= file_name %>)
182
+ <%= file_name %>.stub!(:to_param).and_return("1")
183
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
184
+ <%= file_name %>.should_receive(:update_attributes).and_return(true)
185
+ put :update, :id => "1"
186
+ assigns(:<%= file_name %>).should equal(<%= file_name %>)
187
+ end
188
+
189
+ it "should assign the found <%= file_name %> for the view" do
190
+ <%= file_name %> = Factory(:<%= file_name %>)
191
+ <%= file_name %>.stub!(:to_param).and_return("1")
192
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
193
+ <%= file_name %>.should_receive(:update_attributes).and_return(true)
194
+ put :update, :id => "1"
195
+ assigns(:<%= file_name %>).should equal(<%= file_name %>)
196
+ end
197
+
198
+ it "should redirect to the <%= file_name %>" do
199
+ <%= file_name %> = Factory(:<%= file_name %>)
200
+ <%= file_name %>.stub!(:to_param).and_return("1")
201
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
202
+ <%= file_name %>.should_receive(:update_attributes).and_return(true)
203
+ put :update, :id => "1"
204
+ response.should redirect_to(<%= table_name.singularize %>_url("1"))
205
+ end
206
+
207
+ end
208
+
209
+ describe "with failed update" do
210
+
211
+ it "should re-render 'edit'" do
212
+ <%= file_name %> = Factory(:<%= file_name %>)
213
+ <%= file_name %>.stub!(:to_param).and_return("1")
214
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
215
+ <%= file_name %>.should_receive(:update_attributes).and_return(false)
216
+ put :update, :id => "1"
217
+ response.should render_template('edit')
218
+ end
219
+
220
+ end
221
+ end
222
+
223
+ describe "handling DELETE /<%= table_name %>/1" do
224
+
225
+ it "should find the <%= file_name %> requested" do
226
+ <%= file_name %> = Factory(:<%= file_name %>)
227
+ <%= file_name %>.stub!(:destroy).and_return(true)
228
+ <%= controller_class_name.singularize %>.should_receive(:find).with("1").and_return(<%= file_name %>)
229
+ delete :destroy, :id => "1"
230
+ end
231
+
232
+ it "should call destroy on the found <%= file_name %>" do
233
+ <%= file_name %> = Factory(:<%= file_name %>)
234
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
235
+ <%= file_name %>.should_receive(:destroy).and_return(true)
236
+ delete :destroy, :id => "1"
237
+ end
238
+
239
+ it "should redirect to the <%= table_name %> list" do
240
+ <%= file_name %> = Factory(:<%= file_name %>)
241
+ <%= file_name %>.stub!(:destroy).and_return(true)
242
+ <%= controller_class_name.singularize %>.stub!(:find).and_return(<%= file_name %>)
243
+ delete :destroy, :id => "1"
244
+ response.should redirect_to(<%= table_name %>_url)
245
+ end
246
+ end
247
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../spec_helper')
2
+
3
+ describe <%= controller_class_name %>Helper do
4
+
5
+ #Delete this example and add some real ones or delete this file
6
+ it "should be included in the object returned by #helper" do
7
+ included_modules = (class << helper; self; end).send :included_modules
8
+ included_modules.should include(<%= controller_class_name %>Helper)
9
+ end
10
+
11
+ end
@@ -0,0 +1,61 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../spec_helper')
2
+
3
+ describe <%= 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 == {:path => "/<%= table_name %>/1", :method => :put}
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 == {:path => "/<%= table_name %>/1", :method => :delete}
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
61
+ end
@@ -0,0 +1,10 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../spec_helper')
2
+
3
+ describe <%= class_name %> do
4
+
5
+ it "should be valid" do
6
+ <%= file_name %> = Factory(:<%= file_name %>)
7
+ <%= file_name %>.should be_valid
8
+ end
9
+
10
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../../spec_helper')
2
+
3
+ describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
4
+ include <%= controller_class_name %>Helper
5
+
6
+ before do
7
+ @<%= file_name %> = Factory(:<%= file_name %>)
8
+ assigns[:<%= file_name %>] = @<%= file_name %>
9
+
10
+ template.should_receive(:object_url).twice.and_return(<%= file_name %>_path(@<%= file_name %>))
11
+ template.should_receive(:collection_url).and_return(<%= file_name.pluralize %>_path)
12
+ end
13
+
14
+ it "should render edit form" do
15
+ render "/<%= table_name %>/edit.<%= default_file_extension %>"
16
+
17
+ response.should have_tag("form[action=#{<%= file_name %>_path(@<%= file_name %>)}][method=post]") do
18
+ # Test attributes here
19
+ end
20
+ end
21
+ end
22
+
23
+
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../../spec_helper')
2
+
3
+ describe "/<%= table_name %>/index.<%= default_file_extension %>" do
4
+ include <%= controller_class_name %>Helper
5
+
6
+ before(:each) do
7
+ <% [98,99].each do |id| -%>
8
+ <%= file_name %>_<%= id %> = Factory(:<%= file_name %>)
9
+ <% end -%>
10
+ assigns[:<%= table_name %>] = [<%= file_name %>_98, <%= file_name %>_99]
11
+
12
+ template.stub!(:object_url).and_return(<%= file_name %>_path(<%= file_name %>_99))
13
+ template.stub!(:new_object_url).and_return(new_<%= file_name %>_path)
14
+ template.stub!(:edit_object_url).and_return(edit_<%= file_name %>_path(<%= file_name %>_99))
15
+ end
16
+
17
+ it "should render list of <%= table_name %>" do
18
+ render "/<%= table_name %>/index.<%= default_file_extension %>"
19
+ end
20
+ end
21
+
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../../spec_helper')
2
+
3
+ describe "/<%= table_name %>/new.<%= default_file_extension %>" do
4
+ include <%= controller_class_name %>Helper
5
+
6
+ before(:each) do
7
+ @<%= file_name %> = Factory(:<%= file_name %>)
8
+ @<%= file_name %>.stub!(:new_record?).and_return(true)
9
+ assigns[:<%= file_name %>] = @<%= file_name %>
10
+
11
+
12
+ template.stub!(:object_url).and_return(<%= file_name %>_path(@<%= file_name %>))
13
+ template.stub!(:collection_url).and_return(<%= file_name.pluralize %>_path)
14
+ end
15
+
16
+ it "should render new form" do
17
+ render "/<%= table_name %>/new.<%= default_file_extension %>"
18
+
19
+ response.should have_tag("form[action=?][method=post]", <%= table_name %>_path) do
20
+ # Test attributes here
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../../spec_helper')
2
+
3
+ describe "/<%= table_name %>/show.<%= default_file_extension %>" do
4
+ include <%= controller_class_name %>Helper
5
+
6
+ before(:each) do
7
+ @<%= file_name %> = Factory(:<%= file_name %>)
8
+
9
+ assigns[:<%= file_name %>] = @<%= file_name %>
10
+
11
+ template.stub!(:edit_object_url).and_return(edit_<%= file_name %>_path(@<%= file_name %>))
12
+ template.stub!(:collection_url).and_return(<%= file_name.pluralize %>_path)
13
+ end
14
+
15
+ it "should render attributes in <p>" do
16
+ render "/<%= table_name %>/show.<%= default_file_extension %>"
17
+ end
18
+ end
19
+
@@ -0,0 +1,5 @@
1
+ <%- for attribute in attributes -%>
2
+ %p
3
+ %label{:for => "<%= singular_name %>_<%= attribute.name %>"} <%= attribute.column.human_name %>:
4
+ = f.<%= attribute.field_type %> :<%= attribute.name %>
5
+ <% end -%>
@@ -0,0 +1,11 @@
1
+ %h1 Editing <%= singular_name %>
2
+
3
+ = error_messages_for :<%= singular_name %>
4
+
5
+ - form_for(:<%= singular_name %>, :url => object_url, :html => { :method => :put }) do |f|
6
+ = render :partial => "form", :locals => { :f => f }
7
+ %p= submit_tag "Update"
8
+
9
+ = link_to 'Show', object_url
10
+ |
11
+ = link_to 'Back', collection_url
@@ -0,0 +1,19 @@
1
+ %h1 Listing <%= plural_name %>
2
+
3
+ %table
4
+ %tr
5
+ <% for attribute in attributes -%>
6
+ %th <%= attribute.column.human_name %>
7
+ <% end -%>
8
+ - @<%= plural_name %>.each do |<%= singular_name %>|
9
+ %tr
10
+ <% for attribute in attributes -%>
11
+ %td= h <%= singular_name %>.<%= attribute.name %>
12
+ <% end -%>
13
+ %td= link_to 'Show', object_url(<%= singular_name %>)
14
+ %td= link_to 'Edit', edit_object_url(<%= singular_name %>)
15
+ %td= link_to 'Destroy', object_url(<%= singular_name %>), :confirm => 'Are you sure?', :method => :delete
16
+
17
+ %br/
18
+
19
+ =link_to 'New <%= singular_name %>', new_object_url
@@ -0,0 +1,9 @@
1
+ %h1 New <%= singular_name %>
2
+
3
+ = error_messages_for :<%= singular_name %>
4
+
5
+ - form_for(:<%= singular_name %>, :url => collection_url) do |f|
6
+ = render :partial => "form", :locals => { :f => f }
7
+ %p= submit_tag "Create"
8
+
9
+ = link_to 'Back', collection_url
@@ -0,0 +1,9 @@
1
+ <% for attribute in attributes -%>
2
+ %p
3
+ %strong <%= attribute.column.human_name %>:
4
+ =h @<%= singular_name %>.<%= attribute.name %>
5
+ <% end -%>
6
+
7
+ = link_to 'Edit', edit_object_url
8
+ |
9
+ = link_to 'Back', collection_url
@@ -0,0 +1,22 @@
1
+ require 'rails_generator/generators/components/controller/controller_generator'
2
+
3
+ class ObjectiveServiceGenerator < ControllerGenerator
4
+
5
+ def manifest
6
+ record do |m|
7
+ # Check for class naming collisions.
8
+ m.class_collisions class_path, "#{class_name}Controller", "#{class_name}Helper"
9
+
10
+ # Controller, helper, views, and spec directories.
11
+ m.directory File.join('app/controllers', class_path)
12
+ m.directory File.join('spec/controllers', class_path)
13
+
14
+ # Controller spec, class, and helper.
15
+ m.template 'controller_spec.rb',
16
+ File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
17
+
18
+ m.template 'controller.rb',
19
+ File.join('app/controllers', class_path, "#{file_name}_controller.rb")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,2 @@
1
+ class <%= class_name %>Controller < ResourceController::Base
2
+ end