PeterCoulton-rotten-generators 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/rails_generators/rotten_controller/rotten_controller_generator.rb +56 -0
- data/rails_generators/rotten_controller/templates/controller.rb +7 -0
- data/rails_generators/rotten_controller/templates/controller_spec.rb +25 -0
- data/rails_generators/rotten_controller/templates/helper.rb +2 -0
- data/rails_generators/rotten_controller/templates/helper_spec.rb +11 -0
- data/rails_generators/rotten_controller/templates/view.html.haml +2 -0
- data/rails_generators/rotten_controller/templates/view_spec.rb +12 -0
- data/rotten-generators.gemspec +9 -2
- metadata +9 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#require 'rails_generator/generators/components/controller/controller_generator'
|
2
|
+
|
3
|
+
class RottenControllerGenerator < Rails::Generator::NamedBase
|
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('app/helpers', class_path)
|
13
|
+
m.directory File.join('app/views', class_path, file_name)
|
14
|
+
m.directory File.join('spec/controllers', class_path)
|
15
|
+
m.directory File.join('spec/helpers', class_path)
|
16
|
+
m.directory File.join('spec/views', class_path, file_name)
|
17
|
+
|
18
|
+
@default_file_extension = "html.haml"
|
19
|
+
|
20
|
+
# Controller class, functional test, and helper class.
|
21
|
+
m.template 'controller.rb',
|
22
|
+
File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
23
|
+
|
24
|
+
m.template 'helper.rb',
|
25
|
+
File.join('app/helpers', class_path, "#{file_name}_helper.rb")
|
26
|
+
|
27
|
+
# Controller spec, class, and helper.
|
28
|
+
m.template 'controller_spec.rb',
|
29
|
+
File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
|
30
|
+
|
31
|
+
m.template 'helper_spec.rb',
|
32
|
+
File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")
|
33
|
+
|
34
|
+
m.template 'controller:controller.rb',
|
35
|
+
File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
36
|
+
|
37
|
+
m.template 'controller:helper.rb',
|
38
|
+
File.join('app/helpers', class_path, "#{file_name}_helper.rb")
|
39
|
+
|
40
|
+
|
41
|
+
# View template for each action.
|
42
|
+
actions.each do |action|
|
43
|
+
|
44
|
+
specpath = File.join('app/views', class_path, file_name, "#{action}.html.haml")
|
45
|
+
|
46
|
+
m.template 'view_spec.rb',
|
47
|
+
File.join('spec/views', class_path, file_name, "#{action}.#{@default_file_extension}_spec.rb"),
|
48
|
+
:assigns => { :action => action, :model => file_name }
|
49
|
+
|
50
|
+
m.template 'view.html.haml', specpath,
|
51
|
+
:assigns => { :action => action, :path => specpath }
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
|
2
|
+
|
3
|
+
describe <%= class_name %>Controller do
|
4
|
+
|
5
|
+
<% if actions.empty? -%>
|
6
|
+
#Delete this example and add some real ones
|
7
|
+
<% else -%>
|
8
|
+
#Delete these examples and add some real ones
|
9
|
+
<% end -%>
|
10
|
+
it "should use <%= class_name %>Controller" do
|
11
|
+
controller.should be_an_instance_of(<%= class_name %>Controller)
|
12
|
+
end
|
13
|
+
|
14
|
+
<% unless actions.empty? -%>
|
15
|
+
<% for action in actions -%>
|
16
|
+
|
17
|
+
describe "GET '<%= action %>'" do
|
18
|
+
it "should be successful" do
|
19
|
+
get '<%= action %>'
|
20
|
+
response.should be_success
|
21
|
+
end
|
22
|
+
end
|
23
|
+
<% end -%>
|
24
|
+
<% end -%>
|
25
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
|
2
|
+
|
3
|
+
describe <%= 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(<%= class_name %>Helper)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
|
2
|
+
|
3
|
+
describe "/<%= class_name.underscore %>/<%= action %>" do
|
4
|
+
before(:each) do
|
5
|
+
render '<%= class_name.underscore %>/<%= action %>'
|
6
|
+
end
|
7
|
+
|
8
|
+
#Delete this example and add some real ones or delete this file
|
9
|
+
it "should tell you where to find the file" do
|
10
|
+
response.should have_tag('p', %r[Find me in app/views/<%= class_name.underscore %>/<%= action %>])
|
11
|
+
end
|
12
|
+
end
|
data/rotten-generators.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rotten-generators}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.5.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Peter Coulton"]
|
9
|
-
s.date = %q{2009-05-
|
9
|
+
s.date = %q{2009-05-30}
|
10
10
|
s.email = %q{peter@petercoulton.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
@@ -24,6 +24,13 @@ Gem::Specification.new do |s|
|
|
24
24
|
"features/step_definitions/rotten_steps.rb",
|
25
25
|
"features/support/env.rb",
|
26
26
|
"lib/rotten_generators.rb",
|
27
|
+
"rails_generators/rotten_controller/rotten_controller_generator.rb",
|
28
|
+
"rails_generators/rotten_controller/templates/controller.rb",
|
29
|
+
"rails_generators/rotten_controller/templates/controller_spec.rb",
|
30
|
+
"rails_generators/rotten_controller/templates/helper.rb",
|
31
|
+
"rails_generators/rotten_controller/templates/helper_spec.rb",
|
32
|
+
"rails_generators/rotten_controller/templates/view.html.haml",
|
33
|
+
"rails_generators/rotten_controller/templates/view_spec.rb",
|
27
34
|
"rails_generators/rotten_layout/USAGE",
|
28
35
|
"rails_generators/rotten_layout/rotten_layout_generator.rb",
|
29
36
|
"rails_generators/rotten_layout/templates/helper.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: PeterCoulton-rotten-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Coulton
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-30 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,6 +34,13 @@ files:
|
|
34
34
|
- features/step_definitions/rotten_steps.rb
|
35
35
|
- features/support/env.rb
|
36
36
|
- lib/rotten_generators.rb
|
37
|
+
- rails_generators/rotten_controller/rotten_controller_generator.rb
|
38
|
+
- rails_generators/rotten_controller/templates/controller.rb
|
39
|
+
- rails_generators/rotten_controller/templates/controller_spec.rb
|
40
|
+
- rails_generators/rotten_controller/templates/helper.rb
|
41
|
+
- rails_generators/rotten_controller/templates/helper_spec.rb
|
42
|
+
- rails_generators/rotten_controller/templates/view.html.haml
|
43
|
+
- rails_generators/rotten_controller/templates/view_spec.rb
|
37
44
|
- rails_generators/rotten_layout/USAGE
|
38
45
|
- rails_generators/rotten_layout/rotten_layout_generator.rb
|
39
46
|
- rails_generators/rotten_layout/templates/helper.rb
|