zoo-generators 0.1.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 (98) hide show
  1. data/CHANGELOG +198 -0
  2. data/Gemfile +2 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +96 -0
  5. data/Rakefile +10 -0
  6. data/features/step_definitions/common_steps.rb +62 -0
  7. data/features/step_definitions/rails_setup_steps.rb +6 -0
  8. data/features/support/env.rb +6 -0
  9. data/features/support/matchers.rb +7 -0
  10. data/features/zoo_authentication.feature +83 -0
  11. data/features/zoo_config.feature +17 -0
  12. data/features/zoo_layout.feature +13 -0
  13. data/features/zoo_scaffold.feature +84 -0
  14. data/lib/generators/zoo.rb +28 -0
  15. data/lib/generators/zoo/authentication/USAGE +46 -0
  16. data/lib/generators/zoo/authentication/authentication_generator.rb +151 -0
  17. data/lib/generators/zoo/authentication/templates/controller_authentication.rb +48 -0
  18. data/lib/generators/zoo/authentication/templates/factory.rb +6 -0
  19. data/lib/generators/zoo/authentication/templates/fixtures.yml +12 -0
  20. data/lib/generators/zoo/authentication/templates/migration.rb +15 -0
  21. data/lib/generators/zoo/authentication/templates/sessions_controller.rb +20 -0
  22. data/lib/generators/zoo/authentication/templates/sessions_helper.rb +2 -0
  23. data/lib/generators/zoo/authentication/templates/tests/rspec/sessions_controller.rb +26 -0
  24. data/lib/generators/zoo/authentication/templates/tests/rspec/user.rb +81 -0
  25. data/lib/generators/zoo/authentication/templates/tests/rspec/users_controller.rb +54 -0
  26. data/lib/generators/zoo/authentication/templates/tests/shoulda/sessions_controller.rb +26 -0
  27. data/lib/generators/zoo/authentication/templates/tests/shoulda/user.rb +83 -0
  28. data/lib/generators/zoo/authentication/templates/tests/shoulda/users_controller.rb +59 -0
  29. data/lib/generators/zoo/authentication/templates/tests/testunit/sessions_controller.rb +22 -0
  30. data/lib/generators/zoo/authentication/templates/tests/testunit/user.rb +87 -0
  31. data/lib/generators/zoo/authentication/templates/tests/testunit/users_controller.rb +51 -0
  32. data/lib/generators/zoo/authentication/templates/user.rb +35 -0
  33. data/lib/generators/zoo/authentication/templates/users_controller.rb +30 -0
  34. data/lib/generators/zoo/authentication/templates/users_helper.rb +2 -0
  35. data/lib/generators/zoo/authentication/templates/views/haml/_form.html.haml +16 -0
  36. data/lib/generators/zoo/authentication/templates/views/haml/edit.html.haml +3 -0
  37. data/lib/generators/zoo/authentication/templates/views/haml/login.html.haml +13 -0
  38. data/lib/generators/zoo/authentication/templates/views/haml/signup.html.haml +5 -0
  39. data/lib/generators/zoo/config/USAGE +23 -0
  40. data/lib/generators/zoo/config/config_generator.rb +24 -0
  41. data/lib/generators/zoo/config/templates/config.yml +8 -0
  42. data/lib/generators/zoo/config/templates/load_config.rb +2 -0
  43. data/lib/generators/zoo/layout/USAGE +25 -0
  44. data/lib/generators/zoo/layout/layout_generator.rb +26 -0
  45. data/lib/generators/zoo/layout/templates/error_messages_helper.rb +23 -0
  46. data/lib/generators/zoo/layout/templates/layout.html.erb +19 -0
  47. data/lib/generators/zoo/layout/templates/layout.html.haml +21 -0
  48. data/lib/generators/zoo/layout/templates/layout_helper.rb +22 -0
  49. data/lib/generators/zoo/layout/templates/stylesheet.css +83 -0
  50. data/lib/generators/zoo/layout/templates/stylesheet.sass +73 -0
  51. data/lib/generators/zoo/scaffold/USAGE +51 -0
  52. data/lib/generators/zoo/scaffold/scaffold_generator.rb +316 -0
  53. data/lib/generators/zoo/scaffold/templates/actions/create.rb +8 -0
  54. data/lib/generators/zoo/scaffold/templates/actions/destroy.rb +5 -0
  55. data/lib/generators/zoo/scaffold/templates/actions/edit.rb +3 -0
  56. data/lib/generators/zoo/scaffold/templates/actions/index.rb +3 -0
  57. data/lib/generators/zoo/scaffold/templates/actions/new.rb +3 -0
  58. data/lib/generators/zoo/scaffold/templates/actions/show.rb +3 -0
  59. data/lib/generators/zoo/scaffold/templates/actions/update.rb +8 -0
  60. data/lib/generators/zoo/scaffold/templates/controller.rb +3 -0
  61. data/lib/generators/zoo/scaffold/templates/factory.rb +5 -0
  62. data/lib/generators/zoo/scaffold/templates/fixtures.yml +9 -0
  63. data/lib/generators/zoo/scaffold/templates/helper.rb +2 -0
  64. data/lib/generators/zoo/scaffold/templates/migration.rb +16 -0
  65. data/lib/generators/zoo/scaffold/templates/model.rb +4 -0
  66. data/lib/generators/zoo/scaffold/templates/tests/rspec/actions/create.rb +11 -0
  67. data/lib/generators/zoo/scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
  68. data/lib/generators/zoo/scaffold/templates/tests/rspec/actions/edit.rb +4 -0
  69. data/lib/generators/zoo/scaffold/templates/tests/rspec/actions/index.rb +4 -0
  70. data/lib/generators/zoo/scaffold/templates/tests/rspec/actions/new.rb +4 -0
  71. data/lib/generators/zoo/scaffold/templates/tests/rspec/actions/show.rb +4 -0
  72. data/lib/generators/zoo/scaffold/templates/tests/rspec/actions/update.rb +11 -0
  73. data/lib/generators/zoo/scaffold/templates/tests/rspec/controller.rb +8 -0
  74. data/lib/generators/zoo/scaffold/templates/tests/rspec/model.rb +7 -0
  75. data/lib/generators/zoo/scaffold/templates/tests/shoulda/actions/create.rb +13 -0
  76. data/lib/generators/zoo/scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
  77. data/lib/generators/zoo/scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
  78. data/lib/generators/zoo/scaffold/templates/tests/shoulda/actions/index.rb +6 -0
  79. data/lib/generators/zoo/scaffold/templates/tests/shoulda/actions/new.rb +6 -0
  80. data/lib/generators/zoo/scaffold/templates/tests/shoulda/actions/show.rb +6 -0
  81. data/lib/generators/zoo/scaffold/templates/tests/shoulda/actions/update.rb +13 -0
  82. data/lib/generators/zoo/scaffold/templates/tests/shoulda/controller.rb +5 -0
  83. data/lib/generators/zoo/scaffold/templates/tests/shoulda/model.rb +7 -0
  84. data/lib/generators/zoo/scaffold/templates/tests/testunit/actions/create.rb +11 -0
  85. data/lib/generators/zoo/scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
  86. data/lib/generators/zoo/scaffold/templates/tests/testunit/actions/edit.rb +4 -0
  87. data/lib/generators/zoo/scaffold/templates/tests/testunit/actions/index.rb +4 -0
  88. data/lib/generators/zoo/scaffold/templates/tests/testunit/actions/new.rb +4 -0
  89. data/lib/generators/zoo/scaffold/templates/tests/testunit/actions/show.rb +4 -0
  90. data/lib/generators/zoo/scaffold/templates/tests/testunit/actions/update.rb +11 -0
  91. data/lib/generators/zoo/scaffold/templates/tests/testunit/controller.rb +5 -0
  92. data/lib/generators/zoo/scaffold/templates/tests/testunit/model.rb +7 -0
  93. data/lib/generators/zoo/scaffold/templates/views/haml/_form.html.haml +9 -0
  94. data/lib/generators/zoo/scaffold/templates/views/haml/edit.html.haml +14 -0
  95. data/lib/generators/zoo/scaffold/templates/views/haml/index.html.haml +25 -0
  96. data/lib/generators/zoo/scaffold/templates/views/haml/new.html.haml +7 -0
  97. data/lib/generators/zoo/scaffold/templates/views/haml/show.html.haml +20 -0
  98. metadata +243 -0
@@ -0,0 +1,198 @@
1
+ 0.4.6 (March 26, 2011)
2
+
3
+ * fixing form block in HAML (thanks apocalyptiq)
4
+
5
+ * fixing instance variable setting in HAML (thanks nhocki)
6
+
7
+
8
+ 0.4.5 (February 14, 2011)
9
+
10
+ * fixing user validation tests in zoo:authentication (thanks apocalyptiq) - issue #87
11
+
12
+ * fixing form generation when only new action exists for haml scaffold (thanks gouravtiwari) - issue #83
13
+
14
+ * fixing spacing issue in zoo:scaffold model
15
+
16
+ * fixing instance instance variable in haml form for zoo:scaffold - issue #81
17
+
18
+ * improving redirect implementation in haml authentication
19
+
20
+ * adding i18n to error_messages_for in zoo:layout (thanks nhocki)
21
+
22
+
23
+ 0.4.4 (January 17, 2011)
24
+
25
+ * adding namespaces to zoo:scaffold (thanks DouglasMeyer) - issue #63
26
+
27
+ * adding .rvmrc file
28
+
29
+
30
+ 0.4.3 (December 28, 2010)
31
+
32
+ * display usage documentation when given an invalid model name with zoo:scaffold - issue #76
33
+
34
+ * add newline when necessary to Gemfile before adding gem - issue #64
35
+
36
+ * remove extra whitespace between controller methods in zoo:scaffold - issue #62
37
+
38
+ * renaming edit_user route to edit_current_user - issue #59
39
+
40
+ * HAML template improvements (thanks IamNaN) - issue #71
41
+
42
+
43
+ 0.4.2 (October 15, 2010)
44
+
45
+ * adding mocha to Gemfile automatically if it's not there already
46
+
47
+ * switching to BCrypt for user password encryption on zoo:authentication - issue #53
48
+
49
+ * adding Gemfile, now just run "bunde" and "rake" to get cucumber features running - issue #56
50
+
51
+ * renaming Authentication module to ControllerAuthentication to avoid conflicts in zoo:authentication - issue #57
52
+
53
+ * automatically use RSpec when there's a spec directory - issue #50
54
+
55
+ * escaping page title in layout helper (thanks cbmeeks) - issue #52
56
+
57
+ * adding edit profile page to zoo:authentication - closes #54
58
+
59
+
60
+ 0.4.1 (September 23rd, 2010)
61
+
62
+ * fixing frozen hash error when not passing additional arguments to zoo:scaffold - issue #35
63
+
64
+ * fixing rendering of default title in zoo:layout - issue #36
65
+
66
+ * fixing integrate_views error in zoo:scaffold specs - issue #43
67
+
68
+ * updating SASS syntax (thanks semaperepelitsa) - issue #46
69
+
70
+
71
+ 0.4.0 (April 19th, 2010)
72
+
73
+ * adding error_messages_for and f.error_messages helper for Rails 3 zoo:layout
74
+
75
+ * adding initial Rails 3 support (thanks Henrik Hodne)
76
+
77
+ * adding xmlns to <head> element in haml_layout
78
+
79
+
80
+ 0.3.2 (February 16th, 2010)
81
+
82
+ * Including all files in gem, was missing files in rails_generator directory
83
+
84
+
85
+ 0.3.1 (February 16th, 2010)
86
+
87
+ * improving documentation
88
+
89
+ * fixing name of generated session model for authlogic in haml_authorization
90
+
91
+ * use "username" instead of "login" for authlogic haml form template in haml_authorization
92
+
93
+
94
+ 0.3.0 (August 15th, 2009)
95
+
96
+ * adding attr_accessible to models in haml_scaffold
97
+
98
+ * adding authlogic support with --authlogic option in haml_authentication
99
+
100
+ * pluralize second argument for controller in haml_authentication
101
+
102
+ * don't convert javascript/stylesheet arguments to strings in haml_layout
103
+
104
+ * store request location and redirect to it when logging in under haml_authentication
105
+
106
+
107
+ 0.2.4 (May 5th, 2009)
108
+
109
+ * using root_url when no index action in haml_scaffold
110
+
111
+ * making password editable in user model in haml_authentication
112
+
113
+ * adding filter_parameter_logging :password in haml_authentication
114
+
115
+
116
+ 0.2.3 (February 20th, 2009)
117
+
118
+ * fixing haml_authentication to work with Rails 2.3 application_controller.rb
119
+
120
+ * fixing password field in HAML signup page in haml_authentication
121
+
122
+
123
+ 0.2.2 (November 11th, 2008)
124
+
125
+ * fixing sessions_path reference in haml_authentication
126
+
127
+ * adding more validations to user model in haml_authentication
128
+
129
+ * cleaning up haml_layout stylesheet
130
+
131
+
132
+ 0.2.1 (November 10th, 2008)
133
+
134
+ * adding missing haml_authentication files
135
+
136
+
137
+ 0.2.0 (November 4th, 2008)
138
+
139
+ * adding haml_authentication
140
+
141
+
142
+ 0.1.8 (October 3rd, 2008)
143
+
144
+ * compatibility with RubyGems 1.3
145
+
146
+ * using f.error_messages instead of error_messages_for (thanks Zach Langley)
147
+
148
+
149
+ 0.1.7 (August 15th, 2008)
150
+
151
+ * fixing shoulda tests
152
+
153
+
154
+ 0.1.6 (August 7th, 2008)
155
+
156
+ * adding option to specify Shoulda as testing framework in haml_scaffold generator
157
+
158
+ * adding options to manually specify rspec or testunit framework in haml_scaffold generator
159
+
160
+
161
+ 0.1.5 (August 7th, 2008)
162
+
163
+ * adding option to haml layout to generate HAML views and SASS stylesheets
164
+
165
+ * adding option to haml scaffold to generate HAML views
166
+
167
+
168
+ 0.1.4 (July 21st, 2008)
169
+
170
+ * using same logic as model spec in model test for scaffold
171
+
172
+ * simplifying model spec generated by scaffold
173
+
174
+ * adding error_messages_for to form partial
175
+
176
+
177
+ 0.1.3 (June 20th, 2008)
178
+
179
+ * using _url in controllers instead of _path
180
+
181
+ * improving the haml_config default example YAML file
182
+
183
+
184
+ 0.1.2 (May 16th, 2008)
185
+
186
+ * mentioning haml_layout in haml_scaffold generator
187
+
188
+ * adding haml_config generator
189
+
190
+
191
+ 0.1.1 (May 9th, 2008)
192
+
193
+ * adding tests and specs to scaffold generator
194
+
195
+
196
+ 0.1.0 (May 8th, 2008)
197
+
198
+ * initial release
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Ryan Bates
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,96 @@
1
+ = Zoo Generators
2
+
3
+ A collection of useful Rails generator scripts for scaffolding, layout files, authentication, and more.
4
+
5
+
6
+ == Setup
7
+
8
+ === Rails 3
9
+
10
+ Add the gem to your Gemfile.
11
+
12
+ gem "zoo-generators", :group => :development
13
+
14
+ Then you can run any of the included generators.
15
+
16
+ rails g zoo:scaffold Recipe name:string index new
17
+
18
+ == Included Generators
19
+
20
+ * zoo:layout: generates generic layout, stylesheet, and helper files.
21
+ * zoo:scaffold: generates a controller and optional model/migration.
22
+ * zoo:config: generates a config YAML file and loader.
23
+ * zoo:authentication: generates user model with sign up and log in.
24
+
25
+ To view the README for each generator, run it with the +help+ option.
26
+
27
+ rails g zoo:layout --help
28
+
29
+
30
+ == Troubleshooting and FAQs
31
+
32
+ <b>What is the difference between zoo:scaffold and built-in scaffold?</b>
33
+
34
+ One of the primary differences is that zoo:scaffold allows you to choose which controller actions to generate.
35
+
36
+ rails g zoo:scaffold post name:string index new edit
37
+
38
+ There are a few changes to the generated code as well, such as no XML format by default.
39
+
40
+ It also offers support for HAML, Shoulda, and RSpec.
41
+
42
+
43
+ <b>I get "undefined method 'title'" error.</b>
44
+
45
+ Try running zoo:layout, that will generate this helper method. Or you can just change the templates to whatever approach you prefer for setting the title.
46
+
47
+
48
+ <b>I can't set new attributes in my model.</b>
49
+
50
+ Add the attribute to the attr_accessible line in the model.
51
+
52
+
53
+ <b>I get "undefined method 'root_url'" error.</b>
54
+
55
+ Some generators default redirecting to the root_url. Set this in your routes.rb file like this (substituting your controller name).
56
+
57
+ root :to => "home#index"
58
+
59
+
60
+ <b>I get a missing database error.</b>
61
+
62
+ Run <tt>rake db:migrate</tt>.
63
+
64
+
65
+ <b>I get a routing error when I try to submit a form.</b>
66
+
67
+ Try restarting your development server. Sometimes it doesn't detect the change in the routing.
68
+
69
+
70
+ <b>The tests/specs don't work.</b>
71
+
72
+ Make sure you have mocha installed and require it in your spec/test helper.
73
+
74
+ gem install mocha
75
+
76
+ # in spec_helper.rb
77
+ config.mock_with :mocha
78
+
79
+ # in test_helper.rb
80
+ require 'mocha'
81
+
82
+ Also, make sure you're using Rails 2.1 or greater.
83
+
84
+
85
+ == Found a bug?
86
+
87
+ If you are having a problem with Zoo Generators, first look at the FAQs above. If you still cannot resolve it, please submit an issue here.
88
+
89
+ http://github.com/ryanb/haml-generators/issues
90
+
91
+
92
+ == Development
93
+
94
+ If you want to contribute to this project, you can download the Git repository and get the Cucumber features running by calling +bundle+ then +rake+. I normally develop this using Ruby 1.9.2 however it should work with 1.8.7 as well.
95
+
96
+ The Rails 3 generators are located under <tt>lib/generators</tt> and are tested with Cucumber. The older Rails 2 generators are under <tt>rails_generators</tt> and are tested with Shoulda under the <tt>test</tt> directory.
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'cucumber'
4
+ require 'cucumber/rake/task'
5
+
6
+ Cucumber::Rake::Task.new(:features) do |t|
7
+ t.cucumber_opts = "features --format progress"
8
+ end
9
+
10
+ task :default => :features
@@ -0,0 +1,62 @@
1
+ When /^I run "([^\"]*)"$/ do |command|
2
+ system("cd #{@current_directory} && #{command}").should be_true
3
+ end
4
+
5
+ When /^I add "([^\"]*)" to file "([^\"]*)"$/ do |content, short_path|
6
+ path = File.join(@current_directory, short_path)
7
+ File.should exist(path)
8
+ File.open(path, 'a') { |f| f.write(content + "\n") }
9
+ end
10
+
11
+ When /^I replace "([^\"]*)" with "([^\"]*)" in file "([^\"]*)"$/ do |old_content, new_content, short_path|
12
+ path = File.join(@current_directory, short_path)
13
+ File.should exist(path)
14
+ content = File.read(path).gsub(old_content, new_content)
15
+ File.open(path, 'w') { |f| f.write(content) }
16
+ end
17
+
18
+ When /^I insert "([^\"]*)" into "([^\"]*)" after line (\d+)$/ do |content, short_path, after_line|
19
+ path = File.join(@current_directory, short_path)
20
+ File.should exist(path)
21
+ lines = File.read(path).split("\n")
22
+ lines[after_line.to_i, 0] = content
23
+ File.open(path, 'w') { |f| f.write(lines.join("\n")) }
24
+ end
25
+
26
+ Then /^I should see file "([^\"]*)"$/ do |path|
27
+ File.should exist(File.join(@current_directory, path))
28
+ end
29
+
30
+ Then /^I should see "(.*)" in file "([^\"]*)"$/ do |content, short_path|
31
+ path = File.join(@current_directory, short_path)
32
+ File.should exist(path)
33
+ File.readlines(path).join.should include(content)
34
+ end
35
+
36
+ Then /^I should not see "(.*)" in file "([^\"]*)"$/ do |content, short_path|
37
+ path = File.join(@current_directory, short_path)
38
+ File.should exist(path)
39
+ File.readlines(path).join.should_not include(content)
40
+ end
41
+
42
+ Then /^I should see the following files$/ do |table|
43
+ table.raw.flatten.each do |path|
44
+ File.should exist(File.join(@current_directory, path))
45
+ end
46
+ end
47
+
48
+ Then /^I should see the following in file "([^\"]*)"$/ do |short_path, table|
49
+ path = File.join(@current_directory, short_path)
50
+ File.should exist(path)
51
+ table.raw.flatten.each do |content|
52
+ File.readlines(path).join.should include(content)
53
+ end
54
+ end
55
+
56
+ Then /^I should successfully run "([^\"]*)"$/ do |command|
57
+ system("cd #{@current_directory} && #{command}").should be_true
58
+ end
59
+
60
+ Then /^I should see "([^\"]*)" when running "([^\"]*)"$/ do |expected_response, command|
61
+ `cd #{@current_directory} && #{command}`.should include(expected_response)
62
+ end
@@ -0,0 +1,6 @@
1
+ Given /^a new Rails app$/ do
2
+ FileUtils.mkdir_p("tmp")
3
+ system("rails new tmp/rails_app").should be_true
4
+ system("ln -s ../../../lib/generators tmp/rails_app/lib/generators").should be_true
5
+ @current_directory = File.expand_path("tmp/rails_app")
6
+ end
@@ -0,0 +1,6 @@
1
+ require 'cucumber'
2
+ require 'rspec'
3
+
4
+ Before do
5
+ FileUtils.rm_rf "tmp/rails_app"
6
+ end
@@ -0,0 +1,7 @@
1
+ RSpec::Matchers.define :exist do |path|
2
+ match do
3
+ File.exist?(path)
4
+ end
5
+ failure_message_for_should { "Expected #{path} to exist but no file found" }
6
+ failure_message_for_should_not { "Expected #{path} to not exist but file was found" }
7
+ end
@@ -0,0 +1,83 @@
1
+ Feature: Zoo Authentication Generator
2
+ In order to authenticate users
3
+ As a rails developer
4
+ I want to generate some user authentication
5
+
6
+ Scenario: Generate default authentication
7
+ Given a new Rails app
8
+ When I insert "root :to => 'users#new'" into "config/routes.rb" after line 1
9
+ And I run "rails g zoo:authentication"
10
+ Then I should see the following files
11
+ | app/models/user.rb |
12
+ | app/controllers/users_controller.rb |
13
+ | app/helpers/users_helper.rb |
14
+ | app/views/users/new.html.haml |
15
+ | app/views/users/edit.html.haml |
16
+ | app/controllers/sessions_controller.rb |
17
+ | app/helpers/sessions_helper.rb |
18
+ | app/views/sessions/new.html.haml |
19
+ | lib/controller_authentication.rb |
20
+ | test/fixtures/users.yml |
21
+ | test/unit/user_test.rb |
22
+ | test/functional/users_controller_test.rb |
23
+ | test/functional/sessions_controller_test.rb |
24
+ | db/migrate |
25
+ And I should see the following in file "config/routes.rb"
26
+ | resources :sessions |
27
+ | resources :users |
28
+ | match 'login' => 'sessions#new', :as => :login |
29
+ | match 'logout' => 'sessions#destroy', :as => :logout |
30
+ | match 'signup' => 'users#new', :as => :signup |
31
+ | match 'user/edit' => 'users#edit', :as => :edit_current_user |
32
+ And I should see "include ControllerAuthentication" in file "app/controllers/application_controller.rb"
33
+ And I should see "gem "mocha", :group => :test" in file "Gemfile"
34
+ And I should see "gem "bcrypt-ruby", :require => "bcrypt"" in file "Gemfile"
35
+ When I run "rails g zoo:layout -f"
36
+ And I run "rake db:migrate"
37
+ And I run "bundle install"
38
+ Then I should successfully run "rake test"
39
+
40
+ Scenario: Generate named authentication
41
+ Given a new Rails app
42
+ When I insert "root :to => 'accounts#new'" into "config/routes.rb" after line 1
43
+ And I run "rails g zoo:authentication Account CurrentSession"
44
+ Then I should see the following files
45
+ | app/models/account.rb |
46
+ | app/controllers/accounts_controller.rb |
47
+ | app/helpers/accounts_helper.rb |
48
+ | app/views/accounts/new.html.haml |
49
+ | app/views/accounts/edit.html.haml |
50
+ | app/controllers/current_sessions_controller.rb |
51
+ | app/helpers/current_sessions_helper.rb |
52
+ | app/views/current_sessions/new.html.haml |
53
+ | test/fixtures/accounts.yml |
54
+ | test/unit/account_test.rb |
55
+ | test/functional/accounts_controller_test.rb |
56
+ | test/functional/current_sessions_controller_test.rb |
57
+ And I should see the following in file "config/routes.rb"
58
+ | resources :current_sessions |
59
+ | resources :accounts |
60
+ | match 'login' => 'current_sessions#new', :as => :login |
61
+ | match 'logout' => 'current_sessions#destroy', :as => :logout |
62
+ | match 'signup' => 'accounts#new', :as => :signup |
63
+ | match 'account/edit' => 'accounts#edit', :as => :edit_current_account |
64
+ When I run "rails g zoo:layout -f"
65
+ And I run "rake db:migrate"
66
+ And I run "bundle install"
67
+ Then I should successfully run "rake test"
68
+
69
+ Scenario: Generate named authentication with rspec
70
+ Given a new Rails app
71
+ When I insert "root :to => 'accounts#new'" into "config/routes.rb" after line 1
72
+ And I run "rails g zoo:authentication Account CurrentSession --rspec"
73
+ Then I should see the following files
74
+ | spec/models/account_spec.rb |
75
+ | spec/controllers/accounts_controller_spec.rb |
76
+ | spec/controllers/current_sessions_controller_spec.rb |
77
+ When I run "rails g zoo:layout -f"
78
+ And I run "rake db:migrate"
79
+ And I add "gem 'rspec-rails', '>= 2.0.1'" to file "Gemfile"
80
+ And I run "rails g rspec:install"
81
+ And I replace "mock_with :rspec" with "mock_with :mocha" in file "spec/spec_helper.rb"
82
+ And I run "bundle install"
83
+ Then I should successfully run "rake spec"