validator-matchers 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 439c18f7d1952192bf309d571c0f8b8a36d75409bc7f3cdafcad6c765387a198
4
- data.tar.gz: dbb77ae1dab7d97d995b4c5dae464506453cfd302a4aa7355aa3bc6b88ed3a4a
3
+ metadata.gz: 493186123992690fea3b54115bcc1c31afbeb4a44b078d576e1659f7395f3795
4
+ data.tar.gz: 6034275eface3a9ba31b52487118d4a3c2a1c17a236e1e88e5d32e4b61612d00
5
5
  SHA512:
6
- metadata.gz: 2cac5a39393a8c6fa6ace485a8c1163bd8e3e0b7838cdbe0cc60615f865b59328e817e35b04c28f37479e01db7574c2845c0f7144282e8a8d8c7a30138116500
7
- data.tar.gz: c87a2bc3961aae7197e113546f0bcd263be587285c37a1321a44430e7a44dcc4564dd90fa1acc71710fa842142362e099b1643203a264c21c8d9882c8d8e1b80
6
+ metadata.gz: 8387dfa37a304bd26dfbb10a89e54c2abe9e78057952444a66d550322850b705c3e5c7d630e4c156e9c14ad1ab975739ae0e5fd1b1bc5b9c0db32921388fadb1
7
+ data.tar.gz: 16b4fdc9813adb2e414b00255713216dd731642cbcfef963b35a6ea95efb95a26cace5c0e5892de381053fe6c8b731967d622bb2ca04c0b9bdc994031951c7ba
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ Historical changelog for all versions.
4
4
 
5
5
  ## HEAD
6
6
 
7
+ ## v0.0.3
8
+
9
+ * Fix dynamic validator not allowing different attributes
10
+
7
11
  ## v0.0.2
8
12
 
9
13
  * Add respond_to_missing? method to ModelSpecHelper
@@ -11,7 +15,7 @@ Historical changelog for all versions.
11
15
 
12
16
  ## v0.0.1
13
17
 
14
- * Added initial model spec helpers, needs further testing and code cleanup
18
+ * Add initial ModelSpecHelper, needs further testing and code cleanup
15
19
 
16
20
  ## v0.0.0
17
21
 
@@ -2,9 +2,9 @@ require 'rspec/core'
2
2
 
3
3
  module Validator
4
4
  module Matchers
5
- autoload :VERSION, 'validator/matchers/version'
6
- autoload :ModelSpecHelper, 'validator/matchers/model_spec_helper'
5
+ autoload :ModelSpecHelper, 'validator/matchers/model_spec_helper'
7
6
  autoload :ValidatorSpecHelper, 'validator/matchers/validator_spec_helper'
7
+ autoload :VERSION, 'validator/matchers/version'
8
8
  end
9
9
  end
10
10
 
@@ -15,25 +15,29 @@ module Validator
15
15
  validator_name = regex[1]
16
16
  validator_class_name = validator_name.camelcase + 'Validator'
17
17
 
18
- RSpec::Matchers.define method_name do |dynamic_matcher|
18
+ RSpec::Matchers.define method_name do |attribute|
19
19
  match do |model|
20
+ attribute = attribute.first if attribute.is_a?(Array)
20
21
  model_validators =
21
- model._validators[args.first].map{ |v| v.class.to_s }
22
+ model._validators[attribute].map{ |v| v.class.to_s }
22
23
  model_validators.include?(validator_class_name)
23
24
  end
24
25
 
25
26
  failure_message do |model|
27
+ attribute = attribute.first if attribute.is_a?(Array)
26
28
  model.class.to_s + ' does not ' +
27
- method_name.to_s.humanize.downcase + ' :' + args.first.to_s
29
+ method_name.to_s.humanize.downcase + ' :' + attribute.to_s
28
30
  end
29
31
 
30
32
  failure_message_when_negated do |model|
33
+ attribute = attribute.first if attribute.is_a?(Array)
31
34
  model.class.to_s + ' does ' +
32
- method_name.to_s.humanize.downcase + ' :' + args.first.to_s
35
+ method_name.to_s.humanize.downcase + ' :' + attribute.to_s
33
36
  end
34
37
 
35
38
  description do |model|
36
- method_name.to_s.humanize.downcase + ' :' + args.first.to_s
39
+ attribute = attribute.first if attribute.is_a?(Array)
40
+ method_name.to_s.humanize.downcase + ' :' + attribute.to_s
37
41
  end
38
42
  end
39
43
 
@@ -7,7 +7,7 @@ module Validator
7
7
  module VERSION
8
8
  MAJOR = 0
9
9
  MINOR = 0
10
- PATCH = 2
10
+ PATCH = 3
11
11
 
12
12
  STRING = [MAJOR, MINOR, PATCH].join('.')
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validator-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Buker
@@ -51,9 +51,9 @@ licenses:
51
51
  - MIT
52
52
  metadata:
53
53
  bug_tracker_uri: https://github.com/athix/validator-matchers/issues
54
- changelog_uri: https://github.com/athix/validator-matchers/releases/tag/v0.0.2
54
+ changelog_uri: https://github.com/athix/validator-matchers/releases/tag/v0.0.3
55
55
  documentation_uri: https://rubydoc.info/gems/validator-matchers
56
- source_code_uri: https://github.com/athix/validator-matchers/tree/v0.0.2
56
+ source_code_uri: https://github.com/athix/validator-matchers/tree/v0.0.3
57
57
  post_install_message:
58
58
  rdoc_options: []
59
59
  require_paths: