very_nifty_generators 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/lib/generators/nifty/authentication/authentication_generator.rb +152 -0
- data/lib/generators/nifty/authentication/templates/authentication.rb +61 -0
- data/lib/generators/nifty/authentication/templates/authlogic_session.rb +2 -0
- data/lib/generators/nifty/authentication/templates/migration.rb +20 -0
- data/lib/generators/nifty/authentication/templates/sessions_controller.rb +45 -0
- data/lib/generators/nifty/authentication/templates/sessions_helper.rb +2 -0
- data/lib/generators/nifty/authentication/templates/tests/rspec/sessions_controller.rb +39 -0
- data/lib/generators/nifty/authentication/templates/tests/rspec/user.rb +83 -0
- data/lib/generators/nifty/authentication/templates/tests/rspec/users_controller.rb +26 -0
- data/lib/generators/nifty/authentication/templates/tests/shoulda/sessions_controller.rb +40 -0
- data/lib/generators/nifty/authentication/templates/tests/shoulda/user.rb +85 -0
- data/lib/generators/nifty/authentication/templates/tests/shoulda/users_controller.rb +27 -0
- data/lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb +36 -0
- data/lib/generators/nifty/authentication/templates/tests/testunit/user.rb +88 -0
- data/lib/generators/nifty/authentication/templates/tests/testunit/users_controller.rb +23 -0
- data/lib/generators/nifty/authentication/templates/user.rb +42 -0
- data/lib/generators/nifty/authentication/templates/users_controller.rb +18 -0
- data/lib/generators/nifty/authentication/templates/users_helper.rb +2 -0
- data/lib/generators/nifty/config/config_generator.rb +29 -0
- data/lib/generators/nifty/layout/layout_generator.rb +28 -0
- data/lib/generators/nifty/layout/templates/helper.rb +22 -0
- data/lib/generators/nifty/scaffold/scaffold_generator.rb +247 -0
- data/lib/generators/nifty/scaffold/templates/actions/create.rb +9 -0
- data/lib/generators/nifty/scaffold/templates/actions/destroy.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/actions/edit.rb +3 -0
- data/lib/generators/nifty/scaffold/templates/actions/index.rb +3 -0
- data/lib/generators/nifty/scaffold/templates/actions/new.rb +3 -0
- data/lib/generators/nifty/scaffold/templates/actions/show.rb +3 -0
- data/lib/generators/nifty/scaffold/templates/actions/update.rb +9 -0
- data/lib/generators/nifty/scaffold/templates/controller.rb +3 -0
- data/lib/generators/nifty/scaffold/templates/helper.rb +2 -0
- data/lib/generators/nifty/scaffold/templates/migration.rb +16 -0
- data/lib/generators/nifty/scaffold/templates/model.rb +3 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb +11 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb +11 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/controller.rb +8 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/model.rb +7 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/create.rb +13 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/index.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/new.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/show.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/update.rb +13 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/controller.rb +5 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/model.rb +7 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/create.rb +11 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/edit.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/index.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/new.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/show.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/update.rb +11 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/controller.rb +5 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/model.rb +7 -0
- data/lib/generators/nifty.rb +15 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/very_nifty_generators_spec.rb +7 -0
- metadata +128 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
context "create action" do
|
2
|
+
should "render new template when model is invalid" do
|
3
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
4
|
+
post :create
|
5
|
+
assert_template 'new'
|
6
|
+
end
|
7
|
+
|
8
|
+
should "redirect when model is valid" do
|
9
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
10
|
+
post :create
|
11
|
+
assert_redirected_to <%= item_path_for_test('url') %>
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
context "destroy action" do
|
2
|
+
should "destroy model and redirect to index action" do
|
3
|
+
<%= singular_name %> = <%= class_name %>.first
|
4
|
+
delete :destroy, :id => <%= singular_name %>
|
5
|
+
assert_redirected_to <%= items_path('url') %>
|
6
|
+
assert !<%= class_name %>.exists?(<%= singular_name %>.id)
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
context "update action" do
|
2
|
+
should "render edit template when model is invalid" do
|
3
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
4
|
+
put :update, :id => <%= class_name %>.first
|
5
|
+
assert_template 'edit'
|
6
|
+
end
|
7
|
+
|
8
|
+
should "redirect when model is valid" do
|
9
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
10
|
+
put :update, :id => <%= class_name %>.first
|
11
|
+
assert_redirected_to <%= item_path_for_test('url') %>
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
def test_create_invalid
|
2
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
3
|
+
post :create
|
4
|
+
assert_template 'new'
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_create_valid
|
8
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
9
|
+
post :create
|
10
|
+
assert_redirected_to <%= item_path_for_test('url') %>
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
def test_update_invalid
|
2
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
3
|
+
put :update, :id => <%= class_name %>.first
|
4
|
+
assert_template 'edit'
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_update_valid
|
8
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
9
|
+
put :update, :id => <%= class_name %>.first
|
10
|
+
assert_redirected_to <%= item_path_for_test('url') %>
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Nifty
|
4
|
+
module Generators
|
5
|
+
class Base < Rails::Generators::Base #:nodoc:
|
6
|
+
def self.source_root
|
7
|
+
@_nifty_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'nifty', generator_name, 'templates'))
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.banner
|
11
|
+
"#{$0} nifty:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: very_nifty_generators
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kristian Mandrup, dvyjones
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-28 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
description: Rails 3 nifty generators, based on efforts by ryanb and dvyjones
|
26
|
+
email: kmandrup@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- lib/generators/nifty.rb
|
36
|
+
- lib/generators/nifty/authentication/authentication_generator.rb
|
37
|
+
- lib/generators/nifty/authentication/templates/authentication.rb
|
38
|
+
- lib/generators/nifty/authentication/templates/authlogic_session.rb
|
39
|
+
- lib/generators/nifty/authentication/templates/migration.rb
|
40
|
+
- lib/generators/nifty/authentication/templates/sessions_controller.rb
|
41
|
+
- lib/generators/nifty/authentication/templates/sessions_helper.rb
|
42
|
+
- lib/generators/nifty/authentication/templates/tests/rspec/sessions_controller.rb
|
43
|
+
- lib/generators/nifty/authentication/templates/tests/rspec/user.rb
|
44
|
+
- lib/generators/nifty/authentication/templates/tests/rspec/users_controller.rb
|
45
|
+
- lib/generators/nifty/authentication/templates/tests/shoulda/sessions_controller.rb
|
46
|
+
- lib/generators/nifty/authentication/templates/tests/shoulda/user.rb
|
47
|
+
- lib/generators/nifty/authentication/templates/tests/shoulda/users_controller.rb
|
48
|
+
- lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb
|
49
|
+
- lib/generators/nifty/authentication/templates/tests/testunit/user.rb
|
50
|
+
- lib/generators/nifty/authentication/templates/tests/testunit/users_controller.rb
|
51
|
+
- lib/generators/nifty/authentication/templates/user.rb
|
52
|
+
- lib/generators/nifty/authentication/templates/users_controller.rb
|
53
|
+
- lib/generators/nifty/authentication/templates/users_helper.rb
|
54
|
+
- lib/generators/nifty/config/config_generator.rb
|
55
|
+
- lib/generators/nifty/layout/layout_generator.rb
|
56
|
+
- lib/generators/nifty/layout/templates/helper.rb
|
57
|
+
- lib/generators/nifty/scaffold/scaffold_generator.rb
|
58
|
+
- lib/generators/nifty/scaffold/templates/actions/create.rb
|
59
|
+
- lib/generators/nifty/scaffold/templates/actions/destroy.rb
|
60
|
+
- lib/generators/nifty/scaffold/templates/actions/edit.rb
|
61
|
+
- lib/generators/nifty/scaffold/templates/actions/index.rb
|
62
|
+
- lib/generators/nifty/scaffold/templates/actions/new.rb
|
63
|
+
- lib/generators/nifty/scaffold/templates/actions/show.rb
|
64
|
+
- lib/generators/nifty/scaffold/templates/actions/update.rb
|
65
|
+
- lib/generators/nifty/scaffold/templates/controller.rb
|
66
|
+
- lib/generators/nifty/scaffold/templates/helper.rb
|
67
|
+
- lib/generators/nifty/scaffold/templates/migration.rb
|
68
|
+
- lib/generators/nifty/scaffold/templates/model.rb
|
69
|
+
- lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb
|
70
|
+
- lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb
|
71
|
+
- lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb
|
72
|
+
- lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb
|
73
|
+
- lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb
|
74
|
+
- lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb
|
75
|
+
- lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb
|
76
|
+
- lib/generators/nifty/scaffold/templates/tests/rspec/controller.rb
|
77
|
+
- lib/generators/nifty/scaffold/templates/tests/rspec/model.rb
|
78
|
+
- lib/generators/nifty/scaffold/templates/tests/shoulda/actions/create.rb
|
79
|
+
- lib/generators/nifty/scaffold/templates/tests/shoulda/actions/destroy.rb
|
80
|
+
- lib/generators/nifty/scaffold/templates/tests/shoulda/actions/edit.rb
|
81
|
+
- lib/generators/nifty/scaffold/templates/tests/shoulda/actions/index.rb
|
82
|
+
- lib/generators/nifty/scaffold/templates/tests/shoulda/actions/new.rb
|
83
|
+
- lib/generators/nifty/scaffold/templates/tests/shoulda/actions/show.rb
|
84
|
+
- lib/generators/nifty/scaffold/templates/tests/shoulda/actions/update.rb
|
85
|
+
- lib/generators/nifty/scaffold/templates/tests/shoulda/controller.rb
|
86
|
+
- lib/generators/nifty/scaffold/templates/tests/shoulda/model.rb
|
87
|
+
- lib/generators/nifty/scaffold/templates/tests/testunit/actions/create.rb
|
88
|
+
- lib/generators/nifty/scaffold/templates/tests/testunit/actions/destroy.rb
|
89
|
+
- lib/generators/nifty/scaffold/templates/tests/testunit/actions/edit.rb
|
90
|
+
- lib/generators/nifty/scaffold/templates/tests/testunit/actions/index.rb
|
91
|
+
- lib/generators/nifty/scaffold/templates/tests/testunit/actions/new.rb
|
92
|
+
- lib/generators/nifty/scaffold/templates/tests/testunit/actions/show.rb
|
93
|
+
- lib/generators/nifty/scaffold/templates/tests/testunit/actions/update.rb
|
94
|
+
- lib/generators/nifty/scaffold/templates/tests/testunit/controller.rb
|
95
|
+
- lib/generators/nifty/scaffold/templates/tests/testunit/model.rb
|
96
|
+
- LICENSE
|
97
|
+
- README.rdoc
|
98
|
+
has_rdoc: true
|
99
|
+
homepage: http://github.com/kristianmandrup/very_nifty_generators
|
100
|
+
licenses: []
|
101
|
+
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options:
|
104
|
+
- --charset=UTF-8
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: "0"
|
112
|
+
version:
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: "0"
|
118
|
+
version:
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 1.3.5
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: Rails 3 nifty generators
|
126
|
+
test_files:
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/very_nifty_generators_spec.rb
|