forked from kaichen/vim-snipmate-ruby-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ruby-rspec_shoulda_model.snippets
48 lines (44 loc) · 1.66 KB
/
ruby-rspec_shoulda_model.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
# Shoulda macros for Rspec
# association
snippet itshbt shoulda macros for rspec: should_belong_to
it { should belong_to :${1:association} }
snippet itshhabtm shoulda macros for rspec: should_have_and_belong_to_many
it { should have_and_belong_to_many :${1:association} }
snippet itshhm shoulda macros for rspec: should_have_many
it { should have_many :${1:association} }
snippet itshho shoulda macros for rspec: should_have_one
it { should have_one :${1:association} }
# validate
snippet itshvuniq
it { should validate_uniqueness_of :${1:attribute} }
snippet itshvpre
it { should validate_presence_of :${1:attribute} }
snippet itshvacc
it { should validate_acceptance_of(:${1:attribute}) }
snippet itshvnum
it { should validate_numericality_of(:${1:attribute}) }
snippet itshlengthlm
it { should ensure_length_of(:${1:attribute}).
is_at_least(${2:least}).
is_at_most(${3:most}) }
snippet itshlengthl
it { should ensure_length_of(:${1:attribute}).
is_at_least(${2:least}) }
snippet itshlengtheq
it { should ensure_length_of(:${1:attribute}).
is_equal_to(${2:num}) }
snippet itshinclusion
it { should ensure_inclusion_of(:${1:attribute}).in_range(${2:range}) }
snippet itshhns
it { should have_named_scope(:${1:scope}).
finding(:conditions => {:${2:cond} => ${3:value}) }
snippet itshhroa
it { should have_readonly_attributes(:${1:attribute}) }
snippet itshhdbc
it { should have_db_column(:${1:column}).of_type(:${2:type}) }
snippet itshnhdbc
it { should_not have_db_column(:${1:column}).of_type(:${2:type}) }
snippet itshhindex
it { should have_index(:${1:index}) }
snippet itshhindexu
it { should have_index(:${1:index}).unique(${2:true}) }