author | Mahlon E. Smith <mahlon@martini.nu> |
Sat, 16 Jan 2016 11:31:53 -0800 | |
branch | vim-stuff |
changeset 29 | a0e6ddfadf82 |
parent 19 | specky/snippets/rspec.snippets@763cef799c74 |
permissions | -rw-r--r-- |
5 | 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 |
|
19
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
12
diff
changeset
|
59 |
# this is the 'old' mock syntax (rspec 1.x) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
12
diff
changeset
|
60 |
# use 'double' for rspec 2.x |
5 | 61 |
snippet mock |
62 |
${1:var} = mock( "${2:mock_name}"${3:, :null_object => true} ) |
|
63 |
${4} |
|
19
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
12
diff
changeset
|
64 |
snippet dou |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
12
diff
changeset
|
65 |
${1:var} = double( "${2:double_name}" )${3:.as_null_object} |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
12
diff
changeset
|
66 |
${4} |
5 | 67 |
snippet st |
68 |
stub!( :${1:expectation} ).with( ${2:args} ).and_return( ${3} ) |
|
69 |
snippet bef Before each test |
|
70 |
before( :each ) do |
|
71 |
${1} |
|
72 |
end |
|
73 |
snippet bef Before all tests |
|
74 |
before( :all ) do |
|
75 |
${1} |
|
76 |
end |
|
77 |
snippet aft After each test |
|
78 |
after( :each ) do |
|
79 |
${1} |
|
80 |
end |
|
81 |
snippet aft After all tests |
|
82 |
after( :all ) do |
|
83 |
${1} |
|
84 |
end |
|
85 |
snippet sh= |
|
86 |
${1:target}.should == ${2:value} |
|
87 |
${3} |
|
88 |
snippet shn= |
|
89 |
${1:target}.should_not == ${2:value} |
|
90 |
${3} |
|
91 |
snippet she |
|
92 |
${1:target}.should equal( ${2:value} ) |
|
93 |
${3} |
|
94 |
snippet shne |
|
95 |
${1:target}.should_not equal( ${2:value} ) |
|
96 |
${3} |
|
97 |
snippet shm Should contain |
|
98 |
${1:target}.should =~ /${2:regexp}/ |
|
99 |
${3} |
|
100 |
snippet shnm |
|
101 |
${1:target}.should_not =~ /${2:regexp}/ |
|
102 |
${3} |
|
103 |
snippet shm Should match |
|
104 |
${1:target}.should match( /${2:regexp}/ )${3} |
|
105 |
snippet shb |
|
106 |
${1:target}.should be( ${2:result} ) |
|
107 |
${3} |
|
108 |
snippet shnb |
|
109 |
${1:target}.should_not be( ${2:result} ) |
|
110 |
${3} |
|
111 |
snippet shbko |
|
112 |
${1:target}.should be_a_kind_of( ${2:klass} ) |
|
113 |
${3} |
|
114 |
snippet shnbko |
|
115 |
${1:target}.should_not be_a_kind_of( ${2:klass} ) |
|
116 |
${3} |
|
117 |
snippet shbio |
|
118 |
${1:target}.should be_instance_of( ${2:klass} ) |
|
119 |
${3} |
|
120 |
snippet shnbio |
|
121 |
${1:target}.should_not be_instance_of( ${2:klass} ) |
|
122 |
${3} |
|
123 |
snippet shbc |
|
124 |
${1:target}.should be_close( ${2:result}, ${3:tolerance} ) |
|
125 |
${4} |
|
126 |
snippet shnbc |
|
127 |
${1:target}.should_not be_close( ${2:result}, ${3:tolerance} ) |
|
128 |
${4} |
|
129 |
snippet shh |
|
130 |
${1:target}.should have( ${2:num} ).${3:things} |
|
131 |
${4} |
|
132 |
snippet shhal |
|
133 |
${1:target}.should have_at_least( ${2:num} ).${3:things} |
|
134 |
${4} |
|
135 |
snippet shham |
|
136 |
${1:target}.should have_at_most( ${2:num} ).${3:things} |
|
137 |
${4} |
|
138 |
snippet shbp |
|
139 |
${1:target}.should ${2:be_${3:predicate}} ${4} |
|
140 |
snippet shnbp |
|
141 |
${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
|
142 |
snippet exre |
12
a9f1ce3766d1
raise_error -> raise_exception
Mahlon E. Smith <mahlon@martini.nu>
parents:
9
diff
changeset
|
143 |
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
|
144 |
${4} |
0d8306685c5c
Add support for 1.2.6 to, to_not, and expect keywords.
mahlon
parents:
5
diff
changeset
|
145 |
snippet exnre |
12
a9f1ce3766d1
raise_error -> raise_exception
Mahlon E. Smith <mahlon@martini.nu>
parents:
9
diff
changeset
|
146 |
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
|
147 |
${3} |
5 | 148 |
snippet shre |
12
a9f1ce3766d1
raise_error -> raise_exception
Mahlon E. Smith <mahlon@martini.nu>
parents:
9
diff
changeset
|
149 |
lambda { ${1} }.should raise_exception( ${2:ErrorClass}, /${3:message match}/i ) |
5 | 150 |
${4} |
151 |
snippet shnre |
|
12
a9f1ce3766d1
raise_error -> raise_exception
Mahlon E. Smith <mahlon@martini.nu>
parents:
9
diff
changeset
|
152 |
lambda { ${1} }.should_not raise_exception( ${2:ErrorClass} ) |
5 | 153 |
${3} |
154 |
snippet shr |
|
155 |
${1:mock}.should_receive( :${2:message} )${3} |
|
156 |
snippet shnr |
|
157 |
${1:mock}.should_not_receive( :${2:message} )${3} |
|
158 |
snippet shrt |
|
159 |
${1:target}.should respond_to( :${2:sym} ) |
|
160 |
snippet shnrt |
|
161 |
${1:target}.should_not respond_to( :${2:sym} ) |
|
162 |
snippet shbl |
|
163 |
it_should_behave_like "${1:shared behavior}" |
|
164 |
${2} |
|
165 |
snippet sim |
|
166 |
def ${1:matcher_method}( expected ) |
|
167 |
simple_matcher do |given, matcher| |
|
168 |
matcher.description = "${2:verb} with #{expected.inspect}" |
|
169 |
matcher.failure_message = "expected #{given.inspect} to $2 with #{expected.inspect}" |
|
170 |
matcher.negative_failure_message = "expected #{given.inspect} not to $2 with #{expected.inspect}" |
|
171 |
given.${3:...checks something and returns a boolean} |
|
172 |
end |
|
173 |
end |