ubazu 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -36,7 +36,17 @@ module Ubazu
|
|
36
36
|
super(instance)
|
37
37
|
|
38
38
|
@expected_message ||= :blank
|
39
|
-
|
39
|
+
logger.debug "Expected to be validated with message: #{@expected_message}" if !@expected_message.blank?
|
40
|
+
wrong_value = rand(99999999999).to_s.to_sym #wrong symbol
|
41
|
+
@instance.send("#{@attribute}=", wrong_value)
|
42
|
+
result = !errors_match?
|
43
|
+
|
44
|
+
if result
|
45
|
+
true
|
46
|
+
else
|
47
|
+
@failure_message = "#{@attribute} is not validated for inclusion in #{@array.inspect}"
|
48
|
+
false
|
49
|
+
end
|
40
50
|
end
|
41
51
|
|
42
52
|
def description
|
@@ -45,6 +55,31 @@ module Ubazu
|
|
45
55
|
|
46
56
|
private
|
47
57
|
|
58
|
+
def errors_match?
|
59
|
+
@instance.valid?
|
60
|
+
@errors = errors_for_attribute(@instance, @attribute)
|
61
|
+
@errors = [@errors] unless @errors.is_a?(Array)
|
62
|
+
@expected_message ? (errors_match_regexp? || errors_match_string?) : (@errors.compact.any?)
|
63
|
+
end
|
64
|
+
|
65
|
+
def errors_match_regexp?
|
66
|
+
if Regexp === @expected_message
|
67
|
+
@matched_error = @errors.detect { |e| e =~ @expected_message }
|
68
|
+
!@matched_error.nil?
|
69
|
+
else
|
70
|
+
false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def errors_match_string?
|
75
|
+
if @errors.include?(@expected_message)
|
76
|
+
@matched_error = @expected_message
|
77
|
+
true
|
78
|
+
else
|
79
|
+
false
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
48
83
|
def blank_value
|
49
84
|
if collection?
|
50
85
|
[]
|
data/ubazu.gemspec
CHANGED
metadata
CHANGED