gotcha 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/gotcha/controller_helpers.rb +6 -5
- data/lib/gotcha/version.rb +1 -1
- metadata +1 -1
@@ -7,13 +7,13 @@ module Gotcha
|
|
7
7
|
end
|
8
8
|
|
9
9
|
# return a true / false as to whether or not *all* of the gotchas on the page validated
|
10
|
-
def gotcha_valid?
|
11
|
-
@_gotcha_validated ||= determine_gotcha_validity
|
10
|
+
def gotcha_valid?(expected = 1)
|
11
|
+
@_gotcha_validated ||= determine_gotcha_validity(expected)
|
12
12
|
end
|
13
13
|
|
14
14
|
# Validate the gotcha, throw an exception if the gotcha does not validate (any on the page)
|
15
|
-
def validate_gotcha!
|
16
|
-
raise Gotcha::ValidationError.new unless
|
15
|
+
def validate_gotcha!(expected = 1)
|
16
|
+
raise Gotcha::ValidationError.new unless gotcha_valid?(expected)
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
@@ -21,8 +21,9 @@ module Gotcha
|
|
21
21
|
# Go through each response, using the down_transform
|
22
22
|
# of the original class (as long as it is a subclass of Gotcha::Base)
|
23
23
|
# and compare the hash to the hash of the value
|
24
|
-
def determine_gotcha_validity
|
24
|
+
def determine_gotcha_validity(expected_gotcha_count = 1)
|
25
25
|
return false unless params[:gotcha_response].kind_of?(Enumerable)
|
26
|
+
return false unless params[:gotcha_response].count == expected_gotcha_count
|
26
27
|
params[:gotcha_response].all? do |ident, value|
|
27
28
|
type, hash = ident.split '-'
|
28
29
|
return false unless Object.const_defined?(type)
|
data/lib/gotcha/version.rb
CHANGED