napcs / lazy_developer

Rake tasks to make working with Rails apps a bit easier.

This URL has Read+Write access

lazy_developer / README.rdoc
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 1 =LazyDeveloper
a8168de6 » Brian Hogan 2009-02-23 Merged commits and updated ... 2 Copyright (C) 2007-2009 Brian P. Hogan and Kevin Gisi
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 3
4 Developers are lazy. I know I am. If I have to do things over and over, I want
44a0f294 » Brian Hogan 2009-01-07 Removed gem stuff, changed ... 5 them to be automated. Maybe that's efficient and not lazy. However, lazy is a
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 6 shorter word and it's funnier to call this plugin LazyDeveloper.
7
8 This plugin provides some useful Rake tasks that will make your life a little
44a0f294 » Brian Hogan 2009-01-07 Removed gem stuff, changed ... 9 easier. I use them in many of my projects and I invite you to do the same.
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 10
11 = Usage
789e4fb4 » Brian Hogan 2009-04-21 Updated to 1.1.4.1 12
13 == Nuke
14 The Nuke tasks make cleaning up your project a breeze.
15
16 Let's say a previous developer generated some controllers, models, helpers, and views using scaffolding and a healthy mix of broken Test::Unit test cases. You've already generated a nice RESTful controller, correctly pluralized while the original ones are not. When you look in your controllers folder, you see this:
17
18 account_controller.rb
19 accounts_controller.rb
20
21 If you want to clean this up, you'd have to delete these files like so:
22
23 rm -rf app/controllers/account_controller.rb
24 rm -rf app/helpers/account_helper.rb
25 rm -rf app/views/account
26 rm -rf test/functionals/account_controller_test.rb
27
28 Well, with the Nuke tasks, you can do this easily:
29
30 rake nuke:vc:account
31
32 The 'vc' is for view and controller. It'll take out the whole controller and view combination, including the helper too. It'll blow away any specs or tests associated, and it'll detect if you're using svn or git, so instead of deleting the files directly, it will schedule them for deletion via your source control system.
33
34 The nuke tasks can be quite granular.
35
36 * rake nuke:model:user / rake nuke:m:user
37 * rake nuke:controller:user / rake nuke:c:user
38 * rake nuke:views:user / rake nuke:v:user
39 * rake nuke:helper:user
40 * rake nuke:vc:user
41 * rake nuke:mvc:user
42
43 The only thing these tasks won't do is remove migrations, and that's cos I think that's dangerous
44
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 45 == Databases
46
47 === rake db:migrate
48
a8168de6 » Brian Hogan 2009-02-23 Merged commits and updated ... 49 Everyone I know forgets to clone the test database when they make changes, so I decided to override rake:db:migrate so that when you run it, it automatically clones the
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 50 test database, which is really useful if you run tests individually via TextMate
44a0f294 » Brian Hogan 2009-01-07 Removed gem stuff, changed ... 51 or through the command line.
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 52
a8168de6 » Brian Hogan 2009-02-23 Merged commits and updated ... 53 rake db:migrate
54 rake db:migrate:up
55 rake db:migrate:down
56
57 are all supported.
58
789e4fb4 » Brian Hogan 2009-04-21 Updated to 1.1.4.1 59 === rake db:migrate:compact
60 Uses schema.rb to construct a brand new clean migration and moves all of your existing migrations out of the way. This might at first seem to violate the spirit of migrations, but honestly sometimes large projects have a LOT of migrations and it can get difficult to manage these files.
61
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 62 === rake db:remigrate
63
64 Sometimes you just need to wipe out your database tables and start over. This
65 task drops your tables and starts over by dropping the tables directly and then
66 re-running your migrations. This provides a great way to test to make sure you
44a0f294 » Brian Hogan 2009-01-07 Removed gem stuff, changed ... 67 haven't broken migrations at some point, which *will* happen to you at some point.
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 68
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 69 === rake db:to_yaml
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 70
44a0f294 » Brian Hogan 2009-01-07 Removed gem stuff, changed ... 71 Dump your database to fixtures. Stores them in RAILS_ROOT/production_data. You can then use this to load the data back into another database, even one of a different type. We've used this to move
72 data from SQL Server to MySQL and back again.
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 73
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 74 === rake db:from_yaml
44a0f294 » Brian Hogan 2009-01-07 Removed gem stuff, changed ... 75 Load fixtures from RAILS_ROOT/production_data into your database. Loads fixtures dumped by using rake db:export
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 76
77 == Subversion
78
79 === rake svn:root
80 Displays the root of your repository
81
82 === rake svn:tags
83 Displays all the tags. Assumes you use a tags/ folder and a /trunk folder
84
85 === rake svn:tags:last
86 Displays the last tag.
87
88 === rake svn:tag TAG=rel_1-0-0
89 Creates a new tag from the trunk.
90
91 == Rcov
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 92 We're fans of RCov and we've included some ways to make it easier to use RCov in your projects.
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 93
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 94 === Test::Unit
95
96 In order to use the Test::Unit coverage tasks, you'll need to install the Rails_rcov plugin
97
98 ruby script/plugin install http://svn.codahale.com/rails_rcov/
99
100 This is not needed if your project uses Rspec.
101
102 ==== rake test:models:rcov
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 103
104 Runs coverage on your models
105
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 106 === rake test:controllers:rcov
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 107
108 Runs coverage on your controllers
109
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 110 ==== rake test:rcov:full
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 111
112 Runs coverage on models and controllers
113
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 114 === RSpec
115
116 Rspec already includes the ability to get code coverage, but we made it just as focused and granular as we made the tasks for Test::Unit
117
118 ==== rake spec:models:rcov
119
120 Coverage for models
121
122 ==== rake spec:controllers:rcov
123
124 Coverage for controllers
125
126 ==== rake spec:views:rcov
127
128 Coverage for views
129
130 ==== rake spec:helpers:rcov
131
132 Coverage for helpers
133
134 ==== rake spec:lib:rcov
135
136 Coverage for files in lib/
137
138 == Test::Unit
139
140 === Running individual tests
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 141
142 Based on an idea from Geoffrey Grosenbach, you can run all tests in units\user_test.rb by doing
143
144 rake test:units:user:all
145
44a0f294 » Brian Hogan 2009-01-07 Removed gem stuff, changed ... 146 Or run a specific test by specifying all or part of a name. For example, if I
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 147 wanted to run the "test_create" test case, I would use
148
149 rake test:units:user:create
150
151 The same rules apply to functional tests
152
153 rake test:functionals:users:list
154
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 155 == RSpec
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 156
157 RSpec gets some love here. If you need nice output for your specs, we overrode
158 some of the built-in specs.
159
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 160 === rake spec:models
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 161
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 162 Runs all model specs
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 163
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 164 === rake spec:controllers
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 165
19a24de8 » Brian Hogan 2009-06-12 rspec model, controller, vi... 166 Runs all controller specs
167
ecb1841f » Brian Hogan 2008-10-28 Added rspec tasks for prett... 168 === Running a specific model or controller spec
169
170 rake spec:model:user
171 rake spec:controller:sessions
172
173 == Plugins
174
175 Create a file in your Home folder called .plugins and you can have all of your
176 favorite plugins easily installed by doing
177
178 rake rails:install:plugins
179
180 Just put each plugin name or repository on its own line.
181
182 Windows users need to set the HOME environment variable.
183
184 == Cleaning Up
185
186 Run
187
188 rake rails:clear
189
190 to clean up tmp, logs, and docs in one easy command.
191
192
193
a8168de6 » Brian Hogan 2009-02-23 Merged commits and updated ... 194 Copyright (c) 2007-2009 Brian Hogan and Kevin Gisi. Released under the MIT license