Module: SmartRspec::Macros
Instance Method Summary
collapse
#assert_association, #assert_has_attributes, #build_length_validation, #build_type_str, #scoped_validation?, #validates_email_of, #validates_exclusion_of, #validates_format_of, #validates_inclusion_of, #validates_length_of, #validates_presence_of, #validates_uniqueness_of
Instance Method Details
#belongs_to(*associations) ⇒ Object
6
7
8
|
# File 'lib/smart_rspec/macros.rb', line 6
def belongs_to(*associations)
assert_association :belongs_to, associations
end
|
#fails_validation_of(*attrs, validations) ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/smart_rspec/macros.rb', line 23
def fails_validation_of(*attrs, validations)
attrs.each do |attr|
context attr do
validations.keys.each do |key|
validation = validations[key]
validation && send("validates_#{key}_of", attr, validation)
end
end
end
end
|
#has_attributes(*attrs) ⇒ Object
10
11
12
13
|
# File 'lib/smart_rspec/macros.rb', line 10
def has_attributes(*attrs)
options = attrs.last.is_a?(Hash) && attrs.last.key?(:type) ? attrs.pop : nil
assert_has_attributes(attrs, options)
end
|
#has_many(*associations) ⇒ Object
19
20
21
|
# File 'lib/smart_rspec/macros.rb', line 19
def has_many(*associations)
assert_association :has_many, associations
end
|
#has_one(*associations) ⇒ Object
15
16
17
|
# File 'lib/smart_rspec/macros.rb', line 15
def has_one(*associations)
assert_association :has_one, associations
end
|