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