Class: Ubazu::Rspec::Matchers::ActiveRecord::ValidateInclusionOfMatcher
- Inherits:
-
ValidationMatcher
- Object
- ValidationMatcher
- Ubazu::Rspec::Matchers::ActiveRecord::ValidateInclusionOfMatcher
show all
- Defined in:
- lib/ubazu/rspec/matchers/active_record/validate_inclusion_of_matcher.rb
Overview
Instance Attribute Summary
#failure_message
Instance Method Summary
collapse
#initialize, #negative_failure_message
Instance Method Details
#description ⇒ Object
51
52
53
|
# File 'lib/ubazu/rspec/matchers/active_record/validate_inclusion_of_matcher.rb', line 51
def description
"ensured inclusion of #{@attribute} in #{@array.inspect}"
end
|
#in(array) ⇒ Object
24
25
26
27
|
# File 'lib/ubazu/rspec/matchers/active_record/validate_inclusion_of_matcher.rb', line 24
def in(array)
@array = array
self
end
|
#matches?(instance) ⇒ Boolean
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/ubazu/rspec/matchers/active_record/validate_inclusion_of_matcher.rb', line 34
def matches?(instance)
@instance = instance
super(instance)
@expected_message ||= :blank
wrong_value = rand(99999999999).to_s.to_sym @instance.send("#{@attribute}=", wrong_value)
result = !errors_match?
if result
true
else
@failure_message = "#{@attribute} is not validated for inclusion in #{@array.inspect}"
false
end
end
|
#with_message(message) ⇒ Object
29
30
31
32
|
# File 'lib/ubazu/rspec/matchers/active_record/validate_inclusion_of_matcher.rb', line 29
def with_message(message)
@expected_message = message if message
self
end
|