nifty-generators 0.1.8 → 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.
- data/CHANGELOG +4 -0
- data/Manifest +1 -1
- data/{README → README.rdoc} +25 -6
- data/Rakefile +1 -1
- data/TODO +2 -2
- data/nifty-generators.gemspec +7 -6
- data/rails_generators/nifty_scaffold/templates/views/erb/_form.html.erb +0 -1
- data/rails_generators/nifty_scaffold/templates/views/haml/_form.html.haml +0 -1
- data/test/test_nifty_authentication_generator.rb +158 -0
- data/test/test_nifty_config_generator.rb +1 -1
- metadata +6 -5
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
@@ -65,7 +65,7 @@ rails_generators/nifty_scaffold/templates/views/haml/new.html.haml
|
|
65
65
|
rails_generators/nifty_scaffold/templates/views/haml/show.html.haml
|
66
66
|
rails_generators/nifty_scaffold/USAGE
|
67
67
|
Rakefile
|
68
|
-
README
|
68
|
+
README.rdoc
|
69
69
|
tasks/deployment.rake
|
70
70
|
test/test_helper.rb
|
71
71
|
test/test_nifty_config_generator.rb
|
data/{README → README.rdoc}
RENAMED
@@ -29,28 +29,47 @@ using the script/generate or script/destroy command.
|
|
29
29
|
* nifty_layout: generates generic layout, stylesheet, and helper files.
|
30
30
|
* nifty_scaffold: generates a controller and optional model/migration.
|
31
31
|
* nifty_config: generates a config YAML file and loader.
|
32
|
+
* nifty_authentication: generates user model with sign up and log in.
|
32
33
|
|
33
|
-
Run the command with the
|
34
|
+
Run the command with the <tt>--help</tt> option to learn more.
|
34
35
|
|
35
36
|
script/generate nifty_layout --help
|
36
37
|
|
37
38
|
|
38
39
|
== Troubleshooting
|
39
40
|
|
40
|
-
|
41
|
+
<b>I get "undefined method 'title'" error.</b>
|
41
42
|
|
42
|
-
Try running nifty_layout
|
43
|
+
Try running nifty_layout, that will generate this helper method. Or
|
43
44
|
you can just change the templates to whatever approach you prefer for
|
44
45
|
setting the title.
|
45
46
|
|
46
47
|
|
47
|
-
|
48
|
+
<b>I get "undefined method 'root_url'" error.</b>
|
49
|
+
|
50
|
+
Some generators default redirecting to the root_url. Set this in your
|
51
|
+
routes.rb file like this (substituting your controller name).
|
52
|
+
|
53
|
+
map.root :controller => 'foo'
|
54
|
+
|
55
|
+
|
56
|
+
<b>I get a missing database error.</b>
|
57
|
+
|
58
|
+
Run <tt>rake db:migrate</tt>.
|
59
|
+
|
60
|
+
|
61
|
+
<b>Forms don't work.</b>
|
48
62
|
|
49
63
|
Try restarting your development server. Sometimes it doesn't detect the
|
50
64
|
change in the routing.
|
51
65
|
|
52
66
|
|
53
|
-
|
67
|
+
<b>I can't set new attributes in my User model.</b>
|
68
|
+
|
69
|
+
Add the attribute to the attr_accessible line in the model.
|
70
|
+
|
71
|
+
|
72
|
+
<b>The tests/specs don't work.</b>
|
54
73
|
|
55
74
|
Make sure you have mocha installed and require it in your spec/test helper.
|
56
75
|
|
@@ -62,7 +81,7 @@ Make sure you have mocha installed and require it in your spec/test helper.
|
|
62
81
|
# in test_helper.rb
|
63
82
|
require 'mocha'
|
64
83
|
|
65
|
-
Also, make sure you're using
|
84
|
+
Also, make sure you're using Rails 2.1 or greater.
|
66
85
|
|
67
86
|
|
68
87
|
== Development
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('nifty-generators', '0.
|
5
|
+
Echoe.new('nifty-generators', '0.2.0') do |p|
|
6
6
|
p.project = "niftygenerators"
|
7
7
|
p.summary = "A collection of useful generator scripts for Rails."
|
8
8
|
p.description = "A collection of useful generator scripts for Rails."
|
data/TODO
CHANGED
data/nifty-generators.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Nifty-generators-0.
|
2
|
+
# Gem::Specification for Nifty-generators-0.2.0
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
--- !ruby/object:Gem::Specification
|
6
6
|
name: nifty-generators
|
7
7
|
version: !ruby/object:Gem::Version
|
8
|
-
version: 0.
|
8
|
+
version: 0.2.0
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Ryan Bates
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
|
15
|
-
date: 2008-
|
15
|
+
date: 2008-11-04 00:00:00 -08:00
|
16
16
|
default_executable:
|
17
17
|
dependencies: []
|
18
18
|
|
@@ -26,7 +26,7 @@ extra_rdoc_files:
|
|
26
26
|
- CHANGELOG
|
27
27
|
- lib/nifty_generators.rb
|
28
28
|
- LICENSE
|
29
|
-
- README
|
29
|
+
- README.rdoc
|
30
30
|
- tasks/deployment.rake
|
31
31
|
- TODO
|
32
32
|
files:
|
@@ -97,7 +97,7 @@ files:
|
|
97
97
|
- rails_generators/nifty_scaffold/templates/views/haml/show.html.haml
|
98
98
|
- rails_generators/nifty_scaffold/USAGE
|
99
99
|
- Rakefile
|
100
|
-
- README
|
100
|
+
- README.rdoc
|
101
101
|
- tasks/deployment.rake
|
102
102
|
- test/test_helper.rb
|
103
103
|
- test/test_nifty_config_generator.rb
|
@@ -114,7 +114,7 @@ rdoc_options:
|
|
114
114
|
- --title
|
115
115
|
- Nifty-generators
|
116
116
|
- --main
|
117
|
-
- README
|
117
|
+
- README.rdoc
|
118
118
|
require_paths:
|
119
119
|
- lib
|
120
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -137,6 +137,7 @@ specification_version: 2
|
|
137
137
|
summary: A collection of useful generator scripts for Rails.
|
138
138
|
test_files:
|
139
139
|
- test/test_helper.rb
|
140
|
+
- test/test_nifty_authentication_generator.rb
|
140
141
|
- test/test_nifty_config_generator.rb
|
141
142
|
- test/test_nifty_layout_generator.rb
|
142
143
|
- test/test_nifty_scaffold_generator.rb
|
@@ -0,0 +1,158 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper.rb")
|
2
|
+
|
3
|
+
class TestNiftyAuthenticationGenerator < Test::Unit::TestCase
|
4
|
+
include NiftyGenerators::TestHelper
|
5
|
+
|
6
|
+
# Some generator-related assertions:
|
7
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
8
|
+
# assert_directory_exists(name)
|
9
|
+
# assert_generated_class(name, &block)
|
10
|
+
# assert_generated_module(name, &block)
|
11
|
+
# assert_generated_test_for(name, &block)
|
12
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
13
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
14
|
+
#
|
15
|
+
# Other helper methods are:
|
16
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
17
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
18
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
19
|
+
context "" do # empty context so we can use setup block
|
20
|
+
setup do
|
21
|
+
Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config")
|
22
|
+
File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|
|
23
|
+
f.puts "ActionController::Routing::Routes.draw do |map|\n\nend"
|
24
|
+
end
|
25
|
+
Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app")
|
26
|
+
Dir.mkdir("#{RAILS_ROOT}/app/controllers") unless File.exists?("#{RAILS_ROOT}/app/controllers")
|
27
|
+
File.open("#{RAILS_ROOT}/app/controllers/application.rb", 'w') do |f|
|
28
|
+
f.puts "class Application < ActionController::Base\n\nend"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
teardown do
|
33
|
+
FileUtils.rm_rf "#{RAILS_ROOT}/config"
|
34
|
+
FileUtils.rm_rf "#{RAILS_ROOT}/app"
|
35
|
+
end
|
36
|
+
|
37
|
+
context "generator without arguments" do
|
38
|
+
rails_generator :nifty_authentication
|
39
|
+
should_generate_file 'app/models/user.rb'
|
40
|
+
should_generate_file 'app/controllers/users_controller.rb'
|
41
|
+
should_generate_file 'app/helpers/users_helper.rb'
|
42
|
+
should_generate_file 'app/views/users/new.html.erb'
|
43
|
+
should_generate_file 'app/controllers/sessions_controller.rb'
|
44
|
+
should_generate_file 'app/helpers/sessions_helper.rb'
|
45
|
+
should_generate_file 'app/views/sessions/new.html.erb'
|
46
|
+
should_generate_file 'lib/authentication.rb'
|
47
|
+
should_generate_file 'test/fixtures/users.yml'
|
48
|
+
should_generate_file 'test/unit/user_test.rb'
|
49
|
+
should_generate_file 'test/functional/users_controller_test.rb'
|
50
|
+
should_generate_file 'test/functional/sessions_controller_test.rb'
|
51
|
+
|
52
|
+
should "generate migration file" do
|
53
|
+
assert !Dir.glob("#{RAILS_ROOT}/db/migrate/*.rb").empty?
|
54
|
+
end
|
55
|
+
|
56
|
+
should "generate routes" do
|
57
|
+
assert_generated_file "config/routes.rb" do |body|
|
58
|
+
assert_match "map.resources :sessions", body
|
59
|
+
assert_match "map.resources :users", body
|
60
|
+
assert_match "map.login 'login', :controller => 'sessions', :action => 'new'", body
|
61
|
+
assert_match "map.logout 'logout', :controller => 'sessions', :action => 'destroy'", body
|
62
|
+
assert_match "map.signup 'signup', :controller => 'users', :action => 'new'", body
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
should "include Authentication" do
|
67
|
+
assert_generated_file "app/controllers/application.rb" do |body|
|
68
|
+
assert_match "include Authentication", body
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "generator with user and session names" do
|
74
|
+
rails_generator :nifty_authentication, "Account", "CurrentSessions"
|
75
|
+
should_generate_file 'app/models/account.rb'
|
76
|
+
should_generate_file 'app/controllers/accounts_controller.rb'
|
77
|
+
should_generate_file 'app/helpers/accounts_helper.rb'
|
78
|
+
should_generate_file 'app/views/accounts/new.html.erb'
|
79
|
+
should_generate_file 'app/controllers/current_sessions_controller.rb'
|
80
|
+
should_generate_file 'app/helpers/current_sessions_helper.rb'
|
81
|
+
should_generate_file 'app/views/current_sessions/new.html.erb'
|
82
|
+
should_generate_file 'test/fixtures/accounts.yml'
|
83
|
+
should_generate_file 'test/unit/account_test.rb'
|
84
|
+
should_generate_file 'test/functional/accounts_controller_test.rb'
|
85
|
+
should_generate_file 'test/functional/current_sessions_controller_test.rb'
|
86
|
+
|
87
|
+
should "generate routes" do
|
88
|
+
assert_generated_file "config/routes.rb" do |body|
|
89
|
+
assert_match "map.resources :current_sessions", body
|
90
|
+
assert_match "map.resources :accounts", body
|
91
|
+
assert_match "map.login 'login', :controller => 'current_sessions', :action => 'new'", body
|
92
|
+
assert_match "map.logout 'logout', :controller => 'current_sessions', :action => 'destroy'", body
|
93
|
+
assert_match "map.signup 'signup', :controller => 'accounts', :action => 'new'", body
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "generator with shoulda option" do
|
99
|
+
rails_generator :nifty_authentication, :test_framework => :shoulda
|
100
|
+
|
101
|
+
should "have controller and model tests using shoulda syntax" do
|
102
|
+
assert_generated_file "test/functional/users_controller_test.rb" do |body|
|
103
|
+
assert_match " should ", body
|
104
|
+
end
|
105
|
+
assert_generated_file "test/functional/sessions_controller_test.rb" do |body|
|
106
|
+
assert_match " should ", body
|
107
|
+
end
|
108
|
+
|
109
|
+
assert_generated_file "test/unit/user_test.rb" do |body|
|
110
|
+
assert_match " should ", body
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context "generator with rspec option" do
|
116
|
+
rails_generator :nifty_authentication, :test_framework => :rspec
|
117
|
+
should_generate_file 'spec/fixtures/users.yml'
|
118
|
+
end
|
119
|
+
|
120
|
+
context "with spec dir" do
|
121
|
+
setup do
|
122
|
+
Dir.mkdir("#{RAILS_ROOT}/spec") unless File.exists?("#{RAILS_ROOT}/spec")
|
123
|
+
end
|
124
|
+
|
125
|
+
teardown do
|
126
|
+
FileUtils.rm_rf "#{RAILS_ROOT}/spec"
|
127
|
+
end
|
128
|
+
|
129
|
+
context "generator without arguments" do
|
130
|
+
rails_generator :nifty_authentication
|
131
|
+
should_generate_file 'spec/fixtures/users.yml'
|
132
|
+
should_generate_file 'spec/models/user_spec.rb'
|
133
|
+
should_generate_file 'spec/controllers/users_controller_spec.rb'
|
134
|
+
should_generate_file 'spec/controllers/sessions_controller_spec.rb'
|
135
|
+
end
|
136
|
+
|
137
|
+
context "generator with user and session names" do
|
138
|
+
rails_generator :nifty_authentication, "Account", "CurrentSessions"
|
139
|
+
should_generate_file 'spec/fixtures/accounts.yml'
|
140
|
+
should_generate_file 'spec/models/account_spec.rb'
|
141
|
+
should_generate_file 'spec/controllers/accounts_controller_spec.rb'
|
142
|
+
should_generate_file 'spec/controllers/current_sessions_controller_spec.rb'
|
143
|
+
end
|
144
|
+
|
145
|
+
context "generator with testunit option" do
|
146
|
+
rails_generator :nifty_authentication, :test_framework => :testunit
|
147
|
+
should_generate_file 'test/fixtures/users.yml'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context "generator with haml option" do
|
152
|
+
rails_generator :nifty_authentication, :haml => true
|
153
|
+
|
154
|
+
should_generate_file "app/views/users/new.html.haml"
|
155
|
+
should_generate_file "app/views/sessions/new.html.haml"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nifty-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bates
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-04 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -23,7 +23,7 @@ extra_rdoc_files:
|
|
23
23
|
- CHANGELOG
|
24
24
|
- lib/nifty_generators.rb
|
25
25
|
- LICENSE
|
26
|
-
- README
|
26
|
+
- README.rdoc
|
27
27
|
- tasks/deployment.rake
|
28
28
|
- TODO
|
29
29
|
files:
|
@@ -94,7 +94,7 @@ files:
|
|
94
94
|
- rails_generators/nifty_scaffold/templates/views/haml/show.html.haml
|
95
95
|
- rails_generators/nifty_scaffold/USAGE
|
96
96
|
- Rakefile
|
97
|
-
- README
|
97
|
+
- README.rdoc
|
98
98
|
- tasks/deployment.rake
|
99
99
|
- test/test_helper.rb
|
100
100
|
- test/test_nifty_config_generator.rb
|
@@ -111,7 +111,7 @@ rdoc_options:
|
|
111
111
|
- --title
|
112
112
|
- Nifty-generators
|
113
113
|
- --main
|
114
|
-
- README
|
114
|
+
- README.rdoc
|
115
115
|
require_paths:
|
116
116
|
- lib
|
117
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -135,6 +135,7 @@ specification_version: 2
|
|
135
135
|
summary: A collection of useful generator scripts for Rails.
|
136
136
|
test_files:
|
137
137
|
- test/test_helper.rb
|
138
|
+
- test/test_nifty_authentication_generator.rb
|
138
139
|
- test/test_nifty_config_generator.rb
|
139
140
|
- test/test_nifty_layout_generator.rb
|
140
141
|
- test/test_nifty_scaffold_generator.rb
|