Skip to content

Commit 6961e11

Browse files
committed
Update and expand :Rake documentation
1 parent 0f3a706 commit 6961e11

File tree

1 file changed

+66
-25
lines changed

1 file changed

+66
-25
lines changed

doc/rails.txt

Lines changed: 66 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Tim Pope <[email protected]> |rails-plugin-author|
1414
|rails-controller-navigation| Controller Navigation Commands
1515
|rails-misc-navigation| Miscellaneous Navigation Commands
1616
|rails-custom-navigation| Custom Navigation Commands
17+
|rails-rake| Rake
1718
|rails-scripts| Script Wrappers
1819
|rails-refactoring| Refactoring Helpers
1920
|rails-partials| Partial Extraction
@@ -62,19 +63,24 @@ Rails application development.
6263
method names, 'completefunc' is set to enable syntax based completion on
6364
|i_CTRL-X_CTRL-U|. |rails-syntax|
6465

65-
5. Interface to script/*. Generally, use ":Rscript about" to call
66+
5. Interface to rake. Use :Rake to run the current test, spec, or feature.
67+
Use :.Rake to do a focused run of just the method, example, or scenario on
68+
the current line. :Rake can also run arbitrary migrations, load individual
69+
fixtures, and more. |rails-rake|
70+
71+
6. Interface to script/*. Generally, use ":Rscript about" to call
6672
"script/about". Most commands have wrappers with additional features:
6773
":Rgenerate controller Blog" generates a blog controller and edits
6874
app/controllers/blog_controller.rb. |rails-scripts|
6975

70-
6. Partial extraction and migration inversion. |:Rextract| {file} replaces
76+
7. Partial extraction and migration inversion. |:Rextract| {file} replaces
7177
the desired range (ideally selected in visual line mode) with "render
7278
:partial => '{file}'", which is automatically created with your content.
7379
The @{file} instance variable is replaced with the {file} local variable.
7480
|:Rinvert| takes a self.up migration and writes a self.down.
7581
|rails-refactoring|
7682

77-
7. Integration with other plugins. |:Rtree| spawns NERDTree.vim or creates a
83+
8. Integration with other plugins. |:Rtree| spawns NERDTree.vim or creates a
7884
new project.vim project. If dbext.vim is installed, it will be
7985
transparently configured to reflect database.yml. Cream users get some
8086
additional mappings, and all GUI users get a menu. |rails-integration|
@@ -133,28 +139,6 @@ actually edit a file from a Rails application.
133139
is active for the current buffer, also show the type
134140
of Rails file detected.
135141

136-
*rails-:Rake*
137-
:[range]Rake {targets} Like calling |:make| {targets} (with 'makeprg' being
138-
rake). However, in some contexts, if {targets} are
139-
omitted, :Rake defaults to something sensible (like
140-
db:migrate in a migration, or your current test).
141-
In tests (and specs), giving a line argument runs only
142-
the test method (or example) at that line. Use :.Rake
143-
to run the test method at the cursor position. Use
144-
:.Rake inside a self.up or self.down method in a
145-
migration to run the db:migrate:up or db:migrate:down
146-
task for that particular migration. You can override
147-
the default task with a comment like "# rake ..."
148-
before the method pointed to by [range] or at the top
149-
of the file.
150-
151-
*rails-:Rake!*
152-
:[range]Rake! {targets} Called with a bang, :Rake will use an alternate
153-
'errorformat' which attempts to parse the full stack
154-
backtrace. For purely informative rake tasks (stats,
155-
routes, notes, etc), the preview pane is opened with
156-
the full output of the command.
157-
158142
*rails-:Rcd*
159143
:Rcd [{directory}] |:cd| to /path/to/railsapp/{directory}.
160144

@@ -560,6 +544,63 @@ Finally, one Vim feature that proves helpful in conjunction with all of the
560544
above is |CTRL-^|. This keystroke edits the previous file, and is helpful to
561545
back out of any of the above commands.
562546

547+
==============================================================================
548+
RAKE *rails-rake*
549+
550+
Rake integration happens through the :Rake command.
551+
552+
*rails-:Rake*
553+
:[range]Rake {targets} Calls |:make!| {targets} (with 'makeprg' being rake)
554+
and opens the quickfix window if there were any
555+
errors. If {targets} are omitted, :Rake defaults to
556+
something sensible as described below. Giving a line
557+
number argument may affect that default.
558+
559+
*rails-:Rake!*
560+
:[range]Rake! {targets} Called with a bang, :Rake will forgo opening the
561+
quickfix window.
562+
563+
*rails-rake-defaults*
564+
565+
Generally, the default task is one that runs the test you'd expect. For
566+
example, if you're in a view in an RSpec application, the view spec is run,
567+
but if it's a Test::Unit application, the functional test for the
568+
corresponding controller is run. The following table lists the most
569+
interesting mappings:
570+
571+
File Task ~
572+
unit test test:units TEST=...
573+
functional test test:functionals TEST=...
574+
integration test test:integration TEST=...
575+
spec spec SPEC=...
576+
feature cucumber FEATURE=...
577+
model test:units TEST=... spec SPEC=...
578+
controller test:functionals TEST=... spec SPEC=...
579+
helper test:functionals TEST=... spec SPEC=...
580+
view test:functionals TEST=... spec SPEC=...
581+
fixtures db:fixtures:load FIXTURES=...
582+
migration db:migrate VERSION=...
583+
config/routes.rb routes
584+
db/seeds.rb db:seed
585+
586+
Additionally, when :Rake is given a line number (e.g., :.Rake), the following
587+
additional tasks can be invoked:
588+
589+
File Task ~
590+
unit test test:units TEST=... TESTOPTS=-n...
591+
functional test test:functionals TEST=... TESTOPTS=-n...
592+
integration test test:integration TEST=... TESTOPTS=-n...
593+
spec spec SPEC=... SPEC_OPTS=--line=...
594+
feature cucumber FEATURE=...:...
595+
fixtures db:fixtures:identify LABEL=...
596+
migration in self.up db:migrate:up VERSION=...
597+
migration in self.down db:migrate:down VERSION=...
598+
migration elsewhere db:migrate:redo VERSION=...
599+
task ... (try to guess currently edited declaration)
600+
601+
Finally, you can override the default task with a comment like "# rake ..."
602+
before the method pointed to by [range] or at the top of the file.
603+
563604
==============================================================================
564605
SCRIPT WRAPPERS *rails-scripts*
565606

0 commit comments

Comments
 (0)