Skip to content

Commit

Permalink
Version 0.9
Browse files Browse the repository at this point in the history
Added file detection and syntax highlighting for spec files, and now distribute an rspec snippet (vimscript #2540) file as part of the package.
  • Loading branch information
mahlonsmith authored and vim-scripts committed Nov 6, 2010
1 parent 0496346 commit df659a6
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 12 deletions.
15 changes: 10 additions & 5 deletions doc/specky.txt
@@ -1,4 +1,4 @@
*specky.txt* Last change: $Id: specky.txt 49 2008-08-15 13:32:40Z mahlon $
*specky.txt* Last change: $Id: specky.txt 64 2009-03-22 00:49:45Z mahlon $

VIM REFERENCE MANUAL by Mahlon E. Smith

Expand Down Expand Up @@ -45,10 +45,11 @@ programming tasks smooooth and pleasurable.

Okay then, what does it do?

By default? Nothing, unless you are comfortable using the menus. I decided
the easiest way to cherry pick the functionality that you'd like was to enable
them via key bindings. By doing this, Specky won't make assumptions about
your current environment, and won't stomp on anything you don't want it to.
By default? Nothing but syntax highlighting unless you are comfortable using
the menus. I decided the easiest way to cherry pick the functionality that
you'd like was to enable them via key bindings. By doing this, Specky won't
make assumptions about your current environment, and won't stomp on anything
you don't want it to.

Specky won't do -anything- with your environment until you enable ~
the key bindings!! ~
Expand All @@ -73,6 +74,10 @@ now do with a single key stroke:
- Make lovely and quick comment banners for ruby code.
Specky also includes a "snippets" file that can be used with the Snipmate
plugin by Michael Sanders <msanders42+vim@gmail.com>. (Minimum version 0.74.)

http://www.vim.org/scripts/script.php?script_id=2540

==============================================================================
3. ENABLING-SPECKY *SpeckyVimrcExample*
Expand Down
1 change: 1 addition & 0 deletions ftdetect/rspec.vim
@@ -0,0 +1 @@
au BufRead,BufNewFile *_spec.rb set filetype=rspec
14 changes: 7 additions & 7 deletions plugin/specky.vim
Expand Up @@ -2,7 +2,7 @@
"
" Specky!
" Mahlon E. Smith <mahlon@martini.nu>
" $Id: specky.vim 49 2008-08-15 13:32:40Z mahlon $
" $Id: specky.vim 64 2009-03-22 00:49:45Z mahlon $
"

" }}}
Expand Down Expand Up @@ -58,11 +58,11 @@ execute 'menu ' . s:menuloc . '.Make\ a\ &banner :call <SID>MakeBanner()<CR>'
"
function! <SID>SpecSwitcher()

" If we aren't in a ruby file (specs are ruby-mode too) then we probably
" don't care too much about this function.
" If we aren't in a ruby or rspec file then we probably don't care
" too much about this function.
"
if &ft != 'ruby'
call s:err( "Not currently in ruby-mode." )
if &ft != 'ruby' && &ft != 'rspec'
call s:err( "Not currently in ruby or rspec mode." )
return
endif

Expand Down Expand Up @@ -122,7 +122,7 @@ function! <SID>QuoteSwitcher()
execute ":normal viWc'" . l:word . "'"

elseif l:type == "'"
if &ft == "ruby"
if &ft == 'ruby' || &ft == 'rspec'
" Single quote to symbol
"
execute ':normal viWc:' . l:word
Expand Down Expand Up @@ -230,7 +230,7 @@ function! <SID>RunRdoc()
" If we aren't in a ruby file (specs are ruby-mode too) then we probably
" don't care too much about this function.
"
if ( &ft != 'ruby' && &ft != 'rdoc' )
if ( &ft != 'ruby' && &ft != 'rspec' )
call s:err( "Not currently in ruby-mode." )
return
endif
Expand Down
162 changes: 162 additions & 0 deletions snippets/rspec.snippets
@@ -0,0 +1,162 @@
#
# specky: snippet file for rspec, to be used with the quite excellent
# 'snipmate' Vim plugin by Michael Sanders <msanders42+vim@gmail.com>.
# http://www.vim.org/scripts/script.php?script_id=2540
#
# $Id: specrun.vim 46 2008-08-12 16:24:10Z mahlon $
#

snippet .and and_raise()
.and_raise( ${1:exception}.new("${2:message}") )
snippet .and and_return { }
.and_return { ${1} }
snippet .and and_return()
.and_return( ${1:value} )
snippet .and and_throw()
.and_throw( ${1:sym} )
snippet .and and_yield()
.and_yield( ${1:values} )
snippet .at at_least()
.at_least( ${1:n} ).times
snippet .at at_most()
.at_most( ${1:n} ).times
snippet .on
.once
snippet .tw
.twice
snippet .any
.any_number_of_times
snippet des Describe subject
describe "${1:subject}" do
${2}
end
snippet des Describe Type
describe ${1:Type} do
${2}
end
snippet des Describe Type, description
describe ${1:Type}, "${2:description}" do
${3}
end
snippet des Describe a shared group
describe "${1:A Shared Thing}", :shared => true do
${2}
end
snippet it it block
it "${1:should do something}" do
${2}
end
snippet it it (pending)
it "${1:does something}"${2}
snippet .ex
.exactly( ${1:n} ).times
snippet .w
.with( ${1:args} )${2}
snippet con
context "${1:context}" do
${2}
end
snippet mock
${1:var} = mock( "${2:mock_name}"${3:, :null_object => true} )
${4}
snippet st
stub!( :${1:expectation} ).with( ${2:args} ).and_return( ${3} )
snippet bef Before each test
before( :each ) do
${1}
end
snippet bef Before all tests
before( :all ) do
${1}
end
snippet aft After each test
after( :each ) do
${1}
end
snippet aft After all tests
after( :all ) do
${1}
end
snippet sh=
${1:target}.should == ${2:value}
${3}
snippet shn=
${1:target}.should_not == ${2:value}
${3}
snippet she
${1:target}.should equal( ${2:value} )
${3}
snippet shne
${1:target}.should_not equal( ${2:value} )
${3}
snippet shm Should contain
${1:target}.should =~ /${2:regexp}/
${3}
snippet shnm
${1:target}.should_not =~ /${2:regexp}/
${3}
snippet shm Should match
${1:target}.should match( /${2:regexp}/ )${3}
snippet shb
${1:target}.should be( ${2:result} )
${3}
snippet shnb
${1:target}.should_not be( ${2:result} )
${3}
snippet shbko
${1:target}.should be_a_kind_of( ${2:klass} )
${3}
snippet shnbko
${1:target}.should_not be_a_kind_of( ${2:klass} )
${3}
snippet shbio
${1:target}.should be_instance_of( ${2:klass} )
${3}
snippet shnbio
${1:target}.should_not be_instance_of( ${2:klass} )
${3}
snippet shbc
${1:target}.should be_close( ${2:result}, ${3:tolerance} )
${4}
snippet shnbc
${1:target}.should_not be_close( ${2:result}, ${3:tolerance} )
${4}
snippet shh
${1:target}.should have( ${2:num} ).${3:things}
${4}
snippet shhal
${1:target}.should have_at_least( ${2:num} ).${3:things}
${4}
snippet shham
${1:target}.should have_at_most( ${2:num} ).${3:things}
${4}
snippet shbp
${1:target}.should ${2:be_${3:predicate}} ${4}
snippet shnbp
${1:target}.should_not ${2:be_${3:predicate}} ${4}
snippet shre
lambda { ${1} }.should raise_error( ${2:ErrorClass}, /${3:message match}/i )
${4}
snippet shnre
lambda { ${1} }.should_not raise_error( ${2:ErrorClass} )
${3}
snippet shr
${1:mock}.should_receive( :${2:message} )${3}
snippet shnr
${1:mock}.should_not_receive( :${2:message} )${3}
snippet shrt
${1:target}.should respond_to( :${2:sym} )
snippet shnrt
${1:target}.should_not respond_to( :${2:sym} )
snippet shbl
it_should_behave_like "${1:shared behavior}"
${2}
snippet sim
def ${1:matcher_method}( expected )
simple_matcher do |given, matcher|
matcher.description = "${2:verb} with #{expected.inspect}"
matcher.failure_message = "expected #{given.inspect} to $2 with #{expected.inspect}"
matcher.negative_failure_message = "expected #{given.inspect} not to $2 with #{expected.inspect}"
given.${3:...checks something and returns a boolean}
end
end
30 changes: 30 additions & 0 deletions syntax/rspec.vim
@@ -0,0 +1,30 @@
"
" specky: syntax highlighting for rspec files.
" $Id: specrun.vim 46 2008-08-12 16:24:10Z mahlon $
"

runtime! syntax/ruby.vim
unlet b:current_syntax

syntax keyword rspecGroupMethods describe it
highlight link rspecGroupMethods Type

syntax keyword rspecBeforeAndAfter after after_suite_parts append_after append_before before before_suite_parts prepend_after prepend_before
highlight link rspecBeforeAndAfter Statement

syntax keyword rspecMocks mock stub
highlight link rspecMocks Constant

syntax keyword rspecMockMethods and_raise and_return and_throw and_yield build_child called_max_times expected_args invoke matches
highlight link rspecMockMethods Function

syntax keyword rspecKeywords should should_not should_not_receive should_receive
highlight link rspecKeywords Constant

syntax keyword rspecMatchers be_a be_a_kind_of be_an be_an_instance_of be_close be_false be_instance_of be_kind_of be_nil be_true change eql equal exist have have_at_least have_at_most have_exactly include match matcher raise_error respond_to satisfy throw_symbol wrap_expectation
highlight link rspecMatchers Function

syntax keyword rspecMessageExpectation advise any_number_of_times at_least at_most exactly expected_messages_received generate_error ignoring_args matches_at_least_count matches_at_most_count matches_exact_count matches_name_but_not_args negative_expectation_for never once ordered similar_messages times twice verify_messages_received with
highlight link rspecMessageExpectation Function

let b:current_syntax = "rspec"

0 comments on commit df659a6

Please sign in to comment.