2
|
1 |
*specky.txt* Last change: $Id$
|
|
2 |
|
|
3 |
VIM REFERENCE MANUAL by Mahlon E. Smith
|
|
4 |
|
|
5 |
|
|
6 |
specky!
|
|
7 |
|
|
8 |
A Plugin for testing Ruby code with RSpec -- and more *specky*
|
|
9 |
==============================================================================
|
|
10 |
CONTENTS *SpeckyContents*
|
|
11 |
|
|
12 |
|
|
13 |
1) Intro........................................|SpeckyIntro|
|
|
14 |
2) Functionality................................|SpeckyFunctionality|
|
|
15 |
3) Enabling Specky..............................|SpeckyVimrcExample|
|
|
16 |
4) Configuration................................|SpeckyOptions|
|
3
|
17 |
4.1) Create text banners....................|g:speckyBannerKey|
|
|
18 |
4.2) Cycling quote styles...................|g:speckyQuoteSwitcherKey|
|
|
19 |
4.3) Display ruby documentation.............|g:speckyRunRdocKey|
|
|
20 |
4.4) Toggle editing between spec and code...|g:speckySpecSwitcherKey|
|
|
21 |
4.5) Run specs for the current buffer.......|g:speckyRunSpecKey|
|
|
22 |
4.6) Modify the default spec command........|g:speckyRunSpecCmd|
|
|
23 |
4.7) Modify the default rdoc command........|g:speckyRunRdocCmd|
|
|
24 |
4.8) Split windows vertically...............|g:speckyVertSplit|
|
2
|
25 |
5) Author.......................................|SpeckyAuthor|
|
|
26 |
6) License......................................|SpeckyLicense|
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
==============================================================================
|
|
31 |
1. INTRO *SpeckyIntro*
|
|
32 |
|
|
33 |
|
|
34 |
Specky is primarily a small collection of functions to help make behavioral
|
|
35 |
testing streamlined and easy when working with ruby and rspec.
|
|
36 |
|
|
37 |
Specky secondarily includes a couple of conveniences to make your everyday
|
|
38 |
programming tasks smooooth and pleasurable.
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
==============================================================================
|
|
43 |
2. FUNCTIONALITY *SpeckyFunctionality*
|
|
44 |
|
|
45 |
|
|
46 |
Okay then, what does it do?
|
|
47 |
|
5
|
48 |
By default? Nothing but syntax highlighting unless you are comfortable using
|
|
49 |
the menus. I decided the easiest way to cherry pick the functionality that
|
|
50 |
you'd like was to enable them via key bindings. By doing this, Specky won't
|
|
51 |
make assumptions about your current environment, and won't stomp on anything
|
|
52 |
you don't want it to.
|
3
|
53 |
|
|
54 |
Specky won't do -anything- with your environment until you enable ~
|
|
55 |
the key bindings!! ~
|
2
|
56 |
|
|
57 |
After you've configured your bindings, here are some of the things you can
|
|
58 |
now do with a single key stroke:
|
|
59 |
>
|
|
60 |
- Switch back and forth from code to testing spec
|
|
61 |
|
|
62 |
- Run the spec, with results going to a new, syntax highlighted buffer
|
|
63 |
|
|
64 |
- Jump quickly to spec failures and failure detail
|
|
65 |
- 'e' and 'r' to move back and forth on each failed assertion,
|
|
66 |
- 'E' to jump details for it.
|
|
67 |
- '<C-e>' to "forget" the currently selected failed assertion
|
|
68 |
- 'q' to close the spec output buffer.
|
|
69 |
|
|
70 |
- View rdoc of the word under the cursor
|
|
71 |
|
|
72 |
- Dynamically switch string types for the word under the cursor
|
|
73 |
(double quoted, quoted, symbol)
|
|
74 |
|
3
|
75 |
- Make lovely and quick comment banners for ruby code.
|
2
|
76 |
|
5
|
77 |
Specky also includes a "snippets" file that can be used with the Snipmate
|
|
78 |
plugin by Michael Sanders <msanders42+vim@gmail.com>. (Minimum version 0.74.)
|
|
79 |
|
|
80 |
http://www.vim.org/scripts/script.php?script_id=2540
|
2
|
81 |
|
|
82 |
==============================================================================
|
|
83 |
3. ENABLING-SPECKY *SpeckyVimrcExample*
|
|
84 |
|
|
85 |
|
|
86 |
Here's what my config looks like. >
|
|
87 |
|
3
|
88 |
let g:speckyBannerKey = "<C-S>b"
|
2
|
89 |
let g:speckyQuoteSwitcherKey = "<C-S>'"
|
|
90 |
let g:speckyRunRdocKey = "<C-S>r"
|
|
91 |
let g:speckySpecSwitcherKey = "<C-S>x"
|
|
92 |
let g:speckyRunSpecKey = "<C-S>s"
|
|
93 |
let g:speckyRunSpecCmd = "spec -fs -r loadpath.rb"
|
|
94 |
let g:speckyRunRdocCmd = "fri -L -f plain"
|
|
95 |
let g:speckyVertSplit = 1
|
|
96 |
|
|
97 |
|
|
98 |
With these bindings, all specky commands start with <ctrl-s> ("s" for
|
|
99 |
specky!), followed by a mnemonic function to run:
|
|
100 |
|
3
|
101 |
b ----> Banner creation ~
|
2
|
102 |
' ----> Quote cycling ~
|
|
103 |
r ----> run Rdoc ~
|
|
104 |
x ----> code and spec eXchange ~
|
|
105 |
s ----> run Spec ~
|
|
106 |
|
|
107 |
Of course, <ctrl-s> is a "suspend" signal for most terminals, so these
|
|
108 |
bindings are meant for a |gui| environment, such as gvim. Your mileage (and
|
3
|
109 |
tastes) will doubtlessly vary. Do what you will. I won't judge you.
|
2
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
==============================================================================
|
|
114 |
4. CONFIGURATION-OPTIONS *SpeckyOptions*
|
|
115 |
|
|
116 |
|
|
117 |
Here are all of the available configuration options.
|
|
118 |
|
3
|
119 |
Please note that you must set binding variables:
|
2
|
120 |
|
3
|
121 |
|g:speckyBannerKey|
|
2
|
122 |
|g:speckyQuoteSwitcherKey|
|
|
123 |
|g:speckyRunRdocKey|
|
|
124 |
|g:speckySpecSwitcherKey|
|
|
125 |
|g:speckyRunSpecKey|
|
|
126 |
|
3
|
127 |
...in order to enable the respective specky functionality. See
|
|
128 |
|SpeckyVimrcExample| for details. Any other options are entirely optional.
|
|
129 |
Put these into your |vimrc|, or wherever else you enjoy storing this kind of
|
|
130 |
stuff.
|
2
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
------------------------------------------------------------------------------
|
3
|
135 |
4.1 *g:speckyBannerKey*
|
|
136 |
|
|
137 |
|
|
138 |
Setting this binding enables comment banner creation.
|
|
139 |
|
|
140 |
This is purely a convenience routine, and a stylistic one at that. I prefer
|
|
141 |
large advertising of what "area" of code you are in, along with other
|
|
142 |
miscellaneous labels for humans to read. If this isn't how you roll, then by
|
|
143 |
all means, don't enable this binding! :)
|
|
144 |
|
|
145 |
As an example -- you can just type:
|
|
146 |
|
|
147 |
instance methods ~
|
|
148 |
|
|
149 |
Then hit the keystroke. It will magically turn into: >
|
|
150 |
|
|
151 |
########################################################################
|
|
152 |
### I N S T A N C E M E T H O D S
|
|
153 |
########################################################################
|
|
154 |
|
|
155 |
With all those saved extra keystrokes this might provide you per banner over
|
|
156 |
the years, your RSI-free hands will thank you. And the total time savings!!
|
|
157 |
Oh man, what are you going to DO with all of that extra free time?
|
|
158 |
The possibilities are staggering.
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
------------------------------------------------------------------------------
|
|
163 |
4.2 *g:speckyQuoteSwitcherKey*
|
2
|
164 |
|
|
165 |
|
|
166 |
Setting this binding enables quote "style switching".
|
|
167 |
|
|
168 |
If you aren't in ruby mode, this just changes the word under the cursor
|
|
169 |
back and forth from double quoting to single quoting.
|
|
170 |
|
|
171 |
string -> "string" -> 'string' -> "string" ... ~
|
|
172 |
|
|
173 |
In ruby mode, symbols are also put into the rotation.
|
|
174 |
|
|
175 |
"string" -> 'string' -> :string -> "string" ... ~
|
|
176 |
|
3
|
177 |
Note that quote cycling only works with a |word|.
|
2
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
------------------------------------------------------------------------------
|
3
|
182 |
4.3 *g:speckyRunRdocKey*
|
2
|
183 |
|
|
184 |
|
|
185 |
Setting this enables the display of rdoc documentation for the current
|
|
186 |
word under the cursor. For lookups with multiple matches, you can continue
|
|
187 |
using this binding to "drill down" to the desired documentation.
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
------------------------------------------------------------------------------
|
3
|
192 |
4.4 *g:speckySpecSwitcherKey*
|
2
|
193 |
|
|
194 |
|
|
195 |
Setting this enables spec to code switching, and visa versa.
|
|
196 |
|
|
197 |
Switching uses path searching instead of reliance on directory structure in
|
|
198 |
your project. The idea here is that you'd |:chdir| into your project
|
|
199 |
directory. Spec files just need to end in '_spec.rb', which is a common
|
|
200 |
convention.
|
|
201 |
|
|
202 |
aRubyClass.rb ---> aRubyClass_spec.rb~
|
|
203 |
|
|
204 |
Because it leaves respective buffers open, you can essentially think of this
|
|
205 |
as a quick toggle for code and tests.
|
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
------------------------------------------------------------------------------
|
3
|
210 |
4.5 *g:speckyRunSpecKey*
|
2
|
211 |
|
|
212 |
|
|
213 |
Setting this variable allows you to run "spec" on the current buffer.
|
|
214 |
|
|
215 |
All output is sent to a syntax highlighted scratch buffer. This new window is
|
|
216 |
re-used for each spec run. You can quickly "jump" to assertion failures and
|
|
217 |
their associated details with the following keys:
|
|
218 |
|
|
219 |
e and r ~
|
|
220 |
Move forward and backward through the failed assertions.
|
|
221 |
|
|
222 |
E~
|
|
223 |
While on a failure line, jump to the details of the failure.
|
|
224 |
|
|
225 |
<C-e> ~
|
|
226 |
"Forget" the last found failed assertion, and start over at the
|
|
227 |
beginning of the list. (ie, the next 'e' keystroke will select
|
|
228 |
error #1.)
|
|
229 |
|
|
230 |
q ~
|
|
231 |
Closes the spec output buffer.
|
|
232 |
|
|
233 |
|
|
234 |
Normally, you'd only want to perform this keystroke while in a spec file
|
|
235 |
buffer. If specky thinks you are in code, rather than a buffer (as indicated
|
|
236 |
by the lack of a "_spec.rb" file naming convention) then it will attempt to
|
|
237 |
switch to the spec before running the command.
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
------------------------------------------------------------------------------
|
3
|
242 |
4.6 *g:speckyRunSpecCmd*
|
2
|
243 |
|
|
244 |
|
|
245 |
This is the program, with flags, that the current file is sent to when
|
|
246 |
executing the |g:speckyRunSpecKey| keybinding.
|
|
247 |
|
|
248 |
A common addition is to include an "-r" flag for sucking in local libraries
|
|
249 |
necessary for testing your project. The spec "plain" output format is
|
|
250 |
supported too, though less useful.
|
|
251 |
|
|
252 |
Default: ~
|
|
253 |
spec -fs
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
------------------------------------------------------------------------------
|
3
|
258 |
4.7 *g:speckyRunRdocCmd*
|
2
|
259 |
|
|
260 |
|
|
261 |
If you prefer an rdoc display program other than "ri", you can set it
|
|
262 |
with this variable.
|
|
263 |
|
|
264 |
Default: ~
|
|
265 |
ri
|
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
------------------------------------------------------------------------------
|
3
|
270 |
4.8 *g:speckyVertSplit*
|
2
|
271 |
|
|
272 |
|
|
273 |
For both spec and rdoc commands, split the new window vertically instead of
|
|
274 |
horizontally.
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
==============================================================================
|
|
279 |
5. AUTHOR *SpeckyAuthor*
|
|
280 |
|
|
281 |
|
|
282 |
Specky was written by Mahlon E. Smith.
|
|
283 |
|
|
284 |
mahlon@martini.nu ~
|
|
285 |
http://www.martini.nu/
|
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
==============================================================================
|
|
290 |
6. LICENSE *SpeckyLicense*
|
|
291 |
|
|
292 |
|
|
293 |
Specky is distributed under the BSD license.
|
|
294 |
http://www.opensource.org/licenses/bsd-license.php
|
|
295 |
>
|
|
296 |
Copyright (c) 2008, Mahlon E. Smith <mahlon@martini.nu>
|
|
297 |
All rights reserved.
|
|
298 |
|
|
299 |
Redistribution and use in source and binary forms, with or without
|
|
300 |
modification, are permitted provided that the following conditions are
|
|
301 |
met:
|
|
302 |
|
|
303 |
* Redistributions of source code must retain the above copyright
|
|
304 |
notice, this list of conditions and the following disclaimer.
|
|
305 |
|
|
306 |
* Redistributions in binary form must reproduce the above copyright
|
|
307 |
notice, this list of conditions and the following disclaimer in the
|
|
308 |
documentation and/or other materials provided with the distribution.
|
|
309 |
|
|
310 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
311 |
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
312 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
313 |
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
314 |
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
315 |
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
316 |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
317 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
318 |
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
319 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
320 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
vim: set noet nosta sw=4 ts=4 ft=help :
|