chef-attribute-validator 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDNkM2Y5MDMwZTEwNmYwN2Q0ZmQ3NzkzYzQyN2NlNjE2ODYwNTc1Mg==
4
+ ZDdiM2M5N2FjMTI2MjY4NWI0ZDViYzU5ZTAzZDAzNDBmZjgwMjkwNg==
5
5
  data.tar.gz: !binary |-
6
- ZjNiMGQwNDZkM2Y0MmI2OGFjZWM3MTM0MjI2ZDA2OGRhNTFkZWZjNg==
6
+ NjM3MmUzZDExMWJkMmNkNTYwMWFhNWMzNDA0ZDY1NDhmY2M0NzhiYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWY1MTBhNTk3MTU2MTQ4NWFkZDk5MjY5NTdlZTY2ODI1YTQ4ZDcwYzU5MGQx
10
- NGFlMmE1OTZhZjdiZWIwZDNiZGY1YzI0YWY3MjAzYTlhYTI0YjliNmM0NzA3
11
- NzUwNzczMjI1OWVjNzFkNjdiNDYyYzE4NDAxZWUyYWYxNGZkNDA=
9
+ YjQwNjUzNTM5NjQ1NzBkZDZlYzEzMmQzOThjZmFmYzU5NTlhZGQ2MjMwYWMz
10
+ ZmFlOGZlNzVjYWIwNGRmODM4MmMzMDc5YjE5ODgyOWYzZmJjYTNmNGEyODJi
11
+ YTc5ZjRiMmU4YzE0YmY4YjBhMjdhOGU2NDYxNTI4NGE2MDJmOGI=
12
12
  data.tar.gz: !binary |-
13
- ZWM3YzFjMjRhZTY2MjYzNjI3YzhhZmU4ZGY4ZDNhMGExYmY5YzMzZDljYmQw
14
- NWQzNThjN2UwOWI3YjkyNTQ1YTJhOWRhZjFjZTIxZGJiYjJjNjBkMWYzZjdl
15
- ZTliYWRhOGQ5ZDk2ZjExYjZkM2Q0ZTdiMjljMTVhZjJjOTViOTQ=
13
+ NTg2YjY1ZWJiYzZlNjllNGVhNWYxYTlkYzc5NGViYjA1ZDFkYTE4MmRkMDk3
14
+ NjA4Yjc1YjVkZjA2NTk2MTJjYmM1OWFkYjIxOGY5MDcyOTk1NmUyZjFmMGRj
15
+ ODg5ZTVhZjEzMDFjMWNiNGRlYzU4MmI2ZmMzNzZjZTc3ZjRjNWU=
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ 2013-11-15 Clinton Wolfe 0.3.1
2
+ regex check should violate, but not throw exception, when given a non-string
3
+
1
4
  2013-11-12 Clinton Wolfe 0.3.0
2
5
  Support for enum check
3
6
  Support for proc check
@@ -10,3 +13,4 @@
10
13
  Initial release
11
14
  Type, Regex, Min/Max Children, Required, and LooksLike checks
12
15
  No wildcards in paths yet, planned for 0.2.0
16
+
@@ -16,8 +16,12 @@ class Chef
16
16
  violations = []
17
17
  attrset.each do |path, value|
18
18
  if val_scalar?(value)
19
- unless check_arg.match(value)
20
- violations.push Chef::Attribute::Validator::Violation.new(rule_name, path, "Attribute's value is '#{value}', which does not match regex '#{check_arg}'")
19
+ if value.respond_to?(:match)
20
+ unless check_arg.match(value)
21
+ violations.push Chef::Attribute::Validator::Violation.new(rule_name, path, "Attribute's value is '#{value}', which does not match regex '#{check_arg}'")
22
+ end
23
+ else
24
+ violations.push Chef::Attribute::Validator::Violation.new(rule_name, path, "Attribute's value is '#{value}' (class #{value.class.name}), which is cannot be regexed")
21
25
  end
22
26
  end
23
27
  end
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  class Attribute
3
3
  class Validator
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
6
6
  end
7
7
  end
@@ -5,7 +5,9 @@ default['foo'] = 'foo'
5
5
  default['bar'] = 'bar'
6
6
  default['chow'] = 'food'
7
7
  default['vittles'] = 'victuals'
8
-
8
+ default['nil'] = nil
9
+ default['false'] = false
10
+ default['one'] = 1
9
11
 
10
12
  rules = default['attribute-validator']['rules']
11
13
 
@@ -40,3 +42,17 @@ rules['not-foo-foo'] = {
40
42
  }
41
43
 
42
44
 
45
+ rules['foo-nil'] = {
46
+ 'path' => '/nil',
47
+ 'regex' => /foo/,
48
+ }
49
+
50
+ rules['foo-false'] = {
51
+ 'path' => '/false',
52
+ 'regex' => /foo/,
53
+ }
54
+
55
+ rules['foo-one'] = {
56
+ 'path' => '/one',
57
+ 'regex' => /foo/,
58
+ }
@@ -57,6 +57,17 @@ describe "'regex' check" do
57
57
  it "/^(?!foo)/ should violate on foo" do
58
58
  expect(av.validate_rule('not-foo-foo')).not_to be_empty
59
59
  end
60
+
61
+ it "/foo/ should violate on false" do
62
+ expect { av.validate_rule('foo-false') }.not_to raise_error
63
+ expect(av.validate_rule('foo-false')).not_to be_empty
64
+ end
65
+
66
+ it "/foo/ should violate on 1" do
67
+ expect { av.validate_rule('foo-one') }.not_to raise_error
68
+ expect(av.validate_rule('foo-one')).not_to be_empty
69
+ end
70
+
60
71
  end
61
72
 
62
73
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-attribute-validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: !binary |-
5
+ MC4zLjE=
5
6
  platform: ruby
6
7
  authors:
7
8
  - Clinton Wolfe
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-11-13 00:00:00.000000000 Z
12
+ date: 2013-11-15 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler