very_nifty_generators 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +17 -0
  3. data/lib/generators/nifty/authentication/authentication_generator.rb +152 -0
  4. data/lib/generators/nifty/authentication/templates/authentication.rb +61 -0
  5. data/lib/generators/nifty/authentication/templates/authlogic_session.rb +2 -0
  6. data/lib/generators/nifty/authentication/templates/migration.rb +20 -0
  7. data/lib/generators/nifty/authentication/templates/sessions_controller.rb +45 -0
  8. data/lib/generators/nifty/authentication/templates/sessions_helper.rb +2 -0
  9. data/lib/generators/nifty/authentication/templates/tests/rspec/sessions_controller.rb +39 -0
  10. data/lib/generators/nifty/authentication/templates/tests/rspec/user.rb +83 -0
  11. data/lib/generators/nifty/authentication/templates/tests/rspec/users_controller.rb +26 -0
  12. data/lib/generators/nifty/authentication/templates/tests/shoulda/sessions_controller.rb +40 -0
  13. data/lib/generators/nifty/authentication/templates/tests/shoulda/user.rb +85 -0
  14. data/lib/generators/nifty/authentication/templates/tests/shoulda/users_controller.rb +27 -0
  15. data/lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb +36 -0
  16. data/lib/generators/nifty/authentication/templates/tests/testunit/user.rb +88 -0
  17. data/lib/generators/nifty/authentication/templates/tests/testunit/users_controller.rb +23 -0
  18. data/lib/generators/nifty/authentication/templates/user.rb +42 -0
  19. data/lib/generators/nifty/authentication/templates/users_controller.rb +18 -0
  20. data/lib/generators/nifty/authentication/templates/users_helper.rb +2 -0
  21. data/lib/generators/nifty/config/config_generator.rb +29 -0
  22. data/lib/generators/nifty/layout/layout_generator.rb +28 -0
  23. data/lib/generators/nifty/layout/templates/helper.rb +22 -0
  24. data/lib/generators/nifty/scaffold/scaffold_generator.rb +247 -0
  25. data/lib/generators/nifty/scaffold/templates/actions/create.rb +9 -0
  26. data/lib/generators/nifty/scaffold/templates/actions/destroy.rb +6 -0
  27. data/lib/generators/nifty/scaffold/templates/actions/edit.rb +3 -0
  28. data/lib/generators/nifty/scaffold/templates/actions/index.rb +3 -0
  29. data/lib/generators/nifty/scaffold/templates/actions/new.rb +3 -0
  30. data/lib/generators/nifty/scaffold/templates/actions/show.rb +3 -0
  31. data/lib/generators/nifty/scaffold/templates/actions/update.rb +9 -0
  32. data/lib/generators/nifty/scaffold/templates/controller.rb +3 -0
  33. data/lib/generators/nifty/scaffold/templates/helper.rb +2 -0
  34. data/lib/generators/nifty/scaffold/templates/migration.rb +16 -0
  35. data/lib/generators/nifty/scaffold/templates/model.rb +3 -0
  36. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb +11 -0
  37. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
  38. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb +4 -0
  39. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb +4 -0
  40. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb +4 -0
  41. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb +4 -0
  42. data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb +11 -0
  43. data/lib/generators/nifty/scaffold/templates/tests/rspec/controller.rb +8 -0
  44. data/lib/generators/nifty/scaffold/templates/tests/rspec/model.rb +7 -0
  45. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/create.rb +13 -0
  46. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
  47. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
  48. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/index.rb +6 -0
  49. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/new.rb +6 -0
  50. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/show.rb +6 -0
  51. data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/update.rb +13 -0
  52. data/lib/generators/nifty/scaffold/templates/tests/shoulda/controller.rb +5 -0
  53. data/lib/generators/nifty/scaffold/templates/tests/shoulda/model.rb +7 -0
  54. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/create.rb +11 -0
  55. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
  56. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/edit.rb +4 -0
  57. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/index.rb +4 -0
  58. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/new.rb +4 -0
  59. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/show.rb +4 -0
  60. data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/update.rb +11 -0
  61. data/lib/generators/nifty/scaffold/templates/tests/testunit/controller.rb +5 -0
  62. data/lib/generators/nifty/scaffold/templates/tests/testunit/model.rb +7 -0
  63. data/lib/generators/nifty.rb +15 -0
  64. data/spec/spec_helper.rb +9 -0
  65. data/spec/very_nifty_generators_spec.rb +7 -0
  66. 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,6 @@
1
+ context "edit action" do
2
+ should "render edit template" do
3
+ get :edit, :id => <%= class_name %>.first
4
+ assert_template 'edit'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ context "index action" do
2
+ should "render index template" do
3
+ get :index
4
+ assert_template 'index'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ context "new action" do
2
+ should "render new template" do
3
+ get :new
4
+ assert_template 'new'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ context "show action" do
2
+ should "render show template" do
3
+ get :show, :id => <%= class_name %>.first
4
+ assert_template 'show'
5
+ end
6
+ 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,5 @@
1
+ require 'test_helper'
2
+
3
+ class <%= plural_class_name %>ControllerTest < ActionController::TestCase
4
+ <%= controller_methods 'tests/shoulda/actions' %>
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>Test < ActiveSupport::TestCase
4
+ should "be valid" do
5
+ assert <%= class_name %>.new.valid?
6
+ end
7
+ 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,6 @@
1
+ def test_destroy
2
+ <%= singular_name %> = <%= class_name %>.first
3
+ delete :destroy, :id => <%= singular_name %>
4
+ assert_redirected_to <%= items_path('url') %>
5
+ assert !<%= class_name %>.exists?(<%= singular_name %>.id)
6
+ end
@@ -0,0 +1,4 @@
1
+ def test_edit
2
+ get :edit, :id => <%= class_name %>.first
3
+ assert_template 'edit'
4
+ end
@@ -0,0 +1,4 @@
1
+ def test_index
2
+ get :index
3
+ assert_template 'index'
4
+ end
@@ -0,0 +1,4 @@
1
+ def test_new
2
+ get :new
3
+ assert_template 'new'
4
+ end
@@ -0,0 +1,4 @@
1
+ def test_show
2
+ get :show, :id => <%= class_name %>.first
3
+ assert_template 'show'
4
+ 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,5 @@
1
+ require 'test_helper'
2
+
3
+ class <%= plural_class_name %>ControllerTest < ActionController::TestCase
4
+ <%= controller_methods 'tests/testunit/actions' %>
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>Test < ActiveSupport::TestCase
4
+ def test_should_be_valid
5
+ assert <%= class_name %>.new.valid?
6
+ end
7
+ 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
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'very_nifty_generators'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "VeryNiftyGenerators" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
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