# HG changeset patch # User mahlon # Date 1238801640 0 # Node ID 3346aa8d5364688b66f093ff05dc5201f8c52763 # Parent 4ffc0380b228067c8a0c7b47ea30373e87931a45 Add snippets and rspec syntax highlights. diff -r 4ffc0380b228 -r 3346aa8d5364 specky/Makefile --- a/specky/Makefile Sat Mar 28 02:57:39 2009 +0000 +++ b/specky/Makefile Fri Apr 03 23:34:00 2009 +0000 @@ -2,8 +2,11 @@ SOURCE = syntax/rdoc.vim SOURCE += syntax/specrun.vim +SOURCE += syntax/rspec.vim +SOURCE += ftdetect/rspec.vim SOURCE += doc/specky.txt SOURCE += plugin/specky.vim +SOURCE += snippets/rspec.snippets ${PLUGIN}.vba: ${SOURCE} vim --cmd 'let g:plugin_name="${PLUGIN}"' -s build.vim diff -r 4ffc0380b228 -r 3346aa8d5364 specky/doc/specky.txt --- a/specky/doc/specky.txt Sat Mar 28 02:57:39 2009 +0000 +++ b/specky/doc/specky.txt Fri Apr 03 23:34:00 2009 +0000 @@ -45,10 +45,11 @@ 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!! ~ @@ -73,6 +74,10 @@ - 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 . (Minimum version 0.74.) + + http://www.vim.org/scripts/script.php?script_id=2540 ============================================================================== 3. ENABLING-SPECKY *SpeckyVimrcExample* diff -r 4ffc0380b228 -r 3346aa8d5364 specky/ftdetect/rspec.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/specky/ftdetect/rspec.vim Fri Apr 03 23:34:00 2009 +0000 @@ -0,0 +1,1 @@ +au BufRead,BufNewFile *_spec.rb set filetype=rspec diff -r 4ffc0380b228 -r 3346aa8d5364 specky/plugin/specky.vim --- a/specky/plugin/specky.vim Sat Mar 28 02:57:39 2009 +0000 +++ b/specky/plugin/specky.vim Fri Apr 03 23:34:00 2009 +0000 @@ -58,11 +58,11 @@ " function! 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 @@ -122,7 +122,7 @@ 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 diff -r 4ffc0380b228 -r 3346aa8d5364 specky/snippets/rspec.snippets --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/specky/snippets/rspec.snippets Fri Apr 03 23:34:00 2009 +0000 @@ -0,0 +1,162 @@ +# +# specky: snippet file for rspec, to be used with the quite excellent +# 'snipmate' Vim plugin by Michael Sanders . +# http://www.vim.org/scripts/script.php?script_id=2540 +# +# $Id$ +# + +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 diff -r 4ffc0380b228 -r 3346aa8d5364 specky/syntax/rspec.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/specky/syntax/rspec.vim Fri Apr 03 23:34:00 2009 +0000 @@ -0,0 +1,30 @@ +" +" specky: syntax highlighting for rspec files. +" $Id$ +" + +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"