specky/snippets/rspec.snippets
branchvim-stuff
changeset 5 3346aa8d5364
child 9 0d8306685c5c
equal deleted inserted replaced
4:4ffc0380b228 5:3346aa8d5364
       
     1 #
       
     2 # specky: snippet file for rspec, to be used with the quite excellent
       
     3 # 'snipmate' Vim plugin by Michael Sanders <msanders42+vim@gmail.com>.
       
     4 # http://www.vim.org/scripts/script.php?script_id=2540
       
     5 #
       
     6 # $Id$
       
     7 #
       
     8 
       
     9 snippet .and and_raise()
       
    10 	.and_raise( ${1:exception}.new("${2:message}") )
       
    11 snippet .and and_return { }
       
    12 	.and_return { ${1} }
       
    13 snippet .and and_return()
       
    14 	.and_return( ${1:value} )
       
    15 snippet .and and_throw()
       
    16 	.and_throw( ${1:sym} )
       
    17 snippet .and and_yield()
       
    18 	.and_yield( ${1:values} )
       
    19 snippet .at at_least()
       
    20 	.at_least( ${1:n} ).times
       
    21 snippet .at at_most()
       
    22 	.at_most( ${1:n} ).times
       
    23 snippet .on
       
    24 	.once
       
    25 snippet .tw
       
    26 	.twice
       
    27 snippet .any
       
    28 	.any_number_of_times
       
    29 snippet des Describe subject
       
    30 	describe "${1:subject}" do
       
    31 		${2}
       
    32 	end
       
    33 snippet des Describe Type
       
    34 	describe ${1:Type} do
       
    35 		${2}
       
    36 	end
       
    37 snippet des Describe Type, description
       
    38 	describe ${1:Type}, "${2:description}" do
       
    39 		${3}
       
    40 	end
       
    41 snippet des Describe a shared group
       
    42 	describe "${1:A Shared Thing}", :shared => true do
       
    43 		${2}
       
    44 	end
       
    45 snippet it it block
       
    46 	it "${1:should do something}" do
       
    47 		${2}
       
    48 	end
       
    49 snippet it it (pending)
       
    50 	it "${1:does something}"${2}
       
    51 snippet .ex
       
    52 	.exactly( ${1:n} ).times
       
    53 snippet .w
       
    54 	.with( ${1:args} )${2}
       
    55 snippet con
       
    56 	context "${1:context}" do
       
    57 		${2}
       
    58 	end
       
    59 snippet mock
       
    60 	${1:var} = mock( "${2:mock_name}"${3:, :null_object => true} )
       
    61 	${4}
       
    62 snippet st
       
    63 	stub!( :${1:expectation} ).with( ${2:args} ).and_return( ${3} )
       
    64 snippet bef Before each test
       
    65 	before( :each ) do
       
    66 		${1}
       
    67 	end
       
    68 snippet bef Before all tests
       
    69 	before( :all ) do
       
    70 		${1}
       
    71 	end
       
    72 snippet aft After each test
       
    73 	after( :each ) do
       
    74 		${1}
       
    75 	end
       
    76 snippet aft After all tests
       
    77 	after( :all ) do
       
    78 		${1}
       
    79 	end
       
    80 snippet sh=
       
    81 	${1:target}.should == ${2:value}
       
    82 	${3}
       
    83 snippet shn=
       
    84 	${1:target}.should_not == ${2:value}
       
    85 	${3}
       
    86 snippet she
       
    87 	${1:target}.should equal( ${2:value} )
       
    88 	${3}
       
    89 snippet shne
       
    90 	${1:target}.should_not equal( ${2:value} )
       
    91 	${3}
       
    92 snippet shm Should contain
       
    93 	${1:target}.should =~ /${2:regexp}/
       
    94 	${3}
       
    95 snippet shnm 
       
    96 	${1:target}.should_not =~ /${2:regexp}/
       
    97 	${3}
       
    98 snippet shm Should match
       
    99 	${1:target}.should match( /${2:regexp}/ )${3}
       
   100 snippet shb
       
   101 	${1:target}.should be( ${2:result} )
       
   102 	${3}
       
   103 snippet shnb
       
   104 	${1:target}.should_not be( ${2:result} )
       
   105 	${3}
       
   106 snippet shbko
       
   107 	${1:target}.should be_a_kind_of( ${2:klass} )
       
   108 	${3}
       
   109 snippet shnbko
       
   110 	${1:target}.should_not be_a_kind_of( ${2:klass} )
       
   111 	${3}
       
   112 snippet shbio
       
   113 	${1:target}.should be_instance_of( ${2:klass} )
       
   114 	${3}
       
   115 snippet shnbio
       
   116 	${1:target}.should_not be_instance_of( ${2:klass} )
       
   117 	${3}
       
   118 snippet shbc
       
   119 	${1:target}.should be_close( ${2:result}, ${3:tolerance} )
       
   120 	${4}
       
   121 snippet shnbc
       
   122 	${1:target}.should_not be_close( ${2:result}, ${3:tolerance} )
       
   123 	${4}
       
   124 snippet shh
       
   125 	${1:target}.should have( ${2:num} ).${3:things}
       
   126 	${4}
       
   127 snippet shhal
       
   128 	${1:target}.should have_at_least( ${2:num} ).${3:things}
       
   129 	${4}
       
   130 snippet shham
       
   131 	${1:target}.should have_at_most( ${2:num} ).${3:things}
       
   132 	${4}
       
   133 snippet shbp
       
   134 	${1:target}.should ${2:be_${3:predicate}} ${4}
       
   135 snippet shnbp
       
   136 	${1:target}.should_not ${2:be_${3:predicate}} ${4}
       
   137 snippet shre
       
   138 	lambda { ${1} }.should raise_error( ${2:ErrorClass}, /${3:message match}/i )
       
   139 	${4}
       
   140 snippet shnre
       
   141 	lambda { ${1} }.should_not raise_error( ${2:ErrorClass} )
       
   142 	${3}
       
   143 snippet shr
       
   144 	${1:mock}.should_receive( :${2:message} )${3}
       
   145 snippet shnr
       
   146 	${1:mock}.should_not_receive( :${2:message} )${3}
       
   147 snippet shrt
       
   148 	${1:target}.should respond_to( :${2:sym} )
       
   149 snippet shnrt
       
   150 	${1:target}.should_not respond_to( :${2:sym} )
       
   151 snippet shbl
       
   152 	it_should_behave_like "${1:shared behavior}"
       
   153 	${2}
       
   154 snippet sim
       
   155 	def ${1:matcher_method}( expected )
       
   156 		simple_matcher do |given, matcher|
       
   157 			matcher.description = "${2:verb} with #{expected.inspect}"
       
   158 			matcher.failure_message = "expected #{given.inspect} to $2 with #{expected.inspect}"
       
   159 			matcher.negative_failure_message = "expected #{given.inspect} not to $2 with #{expected.inspect}"
       
   160 			given.${3:...checks something and returns a boolean}
       
   161 		end
       
   162 	end