forked from kaichen/vim-snipmate-ruby-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ruby-shoulda.snippets
98 lines (91 loc) · 2.52 KB
/
ruby-shoulda.snippets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Shoulda
# macros
snippet shc shoulda macros should_change
should_change "${1:expression}"
snippet shcb
should_change "${1:expression}", :by => ${2:by}
snippet shcft
should_change "${1:expression}", :from => ${2:from}, :to => ${3:to}
snippet shnotc
should_not_change "${1:expression}"
# shoulda validation macros
snippet shalvf
should_allow_values_for :${1:attribute}, ${2}
snippet should_ensure_length_at_least
should_ensure_length_at_least :${1:attribute}, ${2:length}
snippet should_ensure_length_in_range
should_ensure_length_in_range :${1:attribute}, ${2:range}
snippet should_ensure_length_is
should_ensure_length_is :${1:attribute}, ${2:length}
snippet should_ensure_value_in_range
should_ensure_value_in_range :${1:attribute}, ${2:range}
snippet shnal
should_not_allow_values_for :${1:attribute}, ${2:values}
snippet shvacc
should_validate_acceptance_of :${1:attribute}
snippet shvuniq
should_validate_uniqueness_of :${1:attribute}
snippet shvpre
should_validate_presence_of :${1:attribute}
snippet shvnum
should_validate_numericality_of :${1:attribute}
snippet shhdbc
should_have_db_columns :${1:column}
snippet shhdbi
should_have_indices :${1:column}
snippet shhclm
should_have_class_methods :${1:method}
snippet shhim
should_have_instance_methods :${1:method}
snippet shhns
should_have_named_scope :${1:named_scope}, :conditions => {:${2:cond} => ${3:cond_val}}
snippet shhroa
should_have_readonly_attributes :${1:attribute}
# shoulda association macros
snippet shbt
should_belong_to :${1:association}
snippet shhabtm
should_have_and_belong_to_many :${1:association}
snippet shhm
should_have_many :${1:association}
snippet shho
should_have_one :${1:association}
# shoulda controller macros
snippet shass
should_assign_to :${1}
snippet shnass
should_not_assign_to :${1}
snippet shfl
should_set_the_flash_to /${1}/i
snippet shnfl
should_not_set_the_flash ${1}
snippet shss
should_set_session(:${1:key}) { ${2} }
snippet shflp
should_filter_params :${1:password}
snippet shred
should_redirect_to "${1}"
snippet shrend
should_render_template :${1}
snippet shrewol
should_render_without_layout :${1}
snippet shres
should_respond_with :${1:success}
snippet shroute
should_route :${1:method}, "${2:path}", :action => :${3}
# Shoulda view macros
snippet shrenderaform
should_render_a_form
snippet shrender_page_with_metadata
should_render_page_with_metadata :${1:meta} => ${2:content}
# shoulda contexts
snippet cont
context "${1:description}" do
setup do
${2}
end
end
snippet sh
should "${1:description}" do
${2}
end