va 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -4
- data/Rakefile +5 -0
- data/lib/va/version.rb +1 -1
- data/spec/va_spec.rb +29 -29
- data/spec/validations_spec.rb +13 -12
- data/va.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5887c31b6f007a988c252d4c52cb1f8c4598250c
|
4
|
+
data.tar.gz: 793b15b2a9fc46e065342f9b1fd31558769773cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea237ac47df122348a36a5035ce5c16e401248c5cafbfff4d7b0d9663e7914d4c5105cdf61e36249eece04bc1b12f5c59160176751d9f246a61148b63123132a
|
7
|
+
data.tar.gz: 89e94ab72b764d42943eecea80c52399b57e3b299d067611e8f8c945404262d3dff271368a790a63d714efb742ef14a3c683148d23999ae109721627326ec136
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
data/lib/va/version.rb
CHANGED
data/spec/va_spec.rb
CHANGED
@@ -6,50 +6,52 @@ scope do
|
|
6
6
|
attribute :pass
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
va
|
11
|
-
|
12
|
-
|
9
|
+
scope "init" do
|
10
|
+
let(:va) { Login.new({"email" => "fede@example.com", pass: "123456"}) }
|
11
|
+
|
12
|
+
it { va.email == "fede@example.com" }
|
13
|
+
it { va.pass == "123456" }
|
13
14
|
end
|
14
15
|
|
15
16
|
scope "#attributes" do
|
16
|
-
|
17
|
-
va = Login.new(email: "fede@example.com", pass: "123456")
|
18
|
-
|
17
|
+
spec "all" do
|
18
|
+
@va = Login.new(email: "fede@example.com", pass: "123456")
|
19
|
+
@va.attributes == { email: "fede@example.com", pass: "123456" }
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
-
va =
|
23
|
-
|
22
|
+
spec "some" do
|
23
|
+
@va = Login.new(email: "fede@example.com")
|
24
|
+
@va.attributes == { email: "fede@example.com" }
|
24
25
|
end
|
25
26
|
|
26
|
-
|
27
|
-
va =
|
28
|
-
|
27
|
+
spec "spureous" do
|
28
|
+
@va = Login.new(email: "fede@example.com", i_dont_belong_here: "HELLO!")
|
29
|
+
@va.attributes == { email: "fede@example.com" }
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
33
|
+
|
32
34
|
scope "custom validations" do
|
33
|
-
|
35
|
+
spec "basic passing validation" do
|
34
36
|
class VeryValid < Va::Model
|
35
37
|
validate do
|
36
38
|
true
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
|
-
va = VeryValid.new
|
41
|
-
|
42
|
+
@va = VeryValid.new
|
43
|
+
@va.valid?
|
42
44
|
end
|
43
45
|
|
44
|
-
|
46
|
+
spec "basic passing validation" do
|
45
47
|
class VeryInvalid < Va::Model
|
46
48
|
validate do
|
47
49
|
false
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
51
|
-
va = VeryInvalid.new
|
52
|
-
|
53
|
+
@va = VeryInvalid.new
|
54
|
+
! @va.valid?
|
53
55
|
end
|
54
56
|
|
55
57
|
scope "A range validation" do
|
@@ -62,19 +64,19 @@ scope "custom validations" do
|
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
|
-
|
66
|
-
r = MyRange.new(from: 1, to: 5)
|
67
|
-
|
67
|
+
spec "valid" do
|
68
|
+
@r = MyRange.new(from: 1, to: 5)
|
69
|
+
@r.valid?
|
68
70
|
end
|
69
71
|
|
70
|
-
|
71
|
-
r = MyRange.new(from: 10, to: 5)
|
72
|
-
|
72
|
+
spec do
|
73
|
+
@r = MyRange.new(from: 10, to: 5)
|
74
|
+
! @r.valid?
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
76
78
|
scope "can't validate" do
|
77
|
-
|
79
|
+
spec "invalid arguments" do
|
78
80
|
begin
|
79
81
|
class FaceValidator < Va::Model
|
80
82
|
attribute :face
|
@@ -83,11 +85,9 @@ scope "custom validations" do
|
|
83
85
|
true
|
84
86
|
end
|
85
87
|
end
|
86
|
-
assert nil
|
87
88
|
rescue Object => e
|
88
|
-
|
89
|
+
e.class == Va::UnknownAttribute
|
89
90
|
end
|
90
91
|
end
|
91
92
|
end
|
92
93
|
end
|
93
|
-
|
data/spec/validations_spec.rb
CHANGED
@@ -7,24 +7,25 @@ scope "basic validations" do
|
|
7
7
|
attribute :age
|
8
8
|
validate_present(:name, :age)
|
9
9
|
end
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
|
11
|
+
spec "passing" do
|
12
|
+
@va = ANonBlankAttribute.new(name: "Fede", age: :of_ultron)
|
13
|
+
@va.valid?
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
va = ANonBlankAttribute.new(name: "", age: :of_ultron)
|
17
|
-
|
16
|
+
spec "one empty string" do
|
17
|
+
@va = ANonBlankAttribute.new(name: "", age: :of_ultron)
|
18
|
+
! @va.valid?
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
va = ANonBlankAttribute.new(name: "Fede", age: nil)
|
22
|
-
|
21
|
+
spec "one nil" do
|
22
|
+
@va = ANonBlankAttribute.new(name: "Fede", age: nil)
|
23
|
+
! @va.valid?
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
va = ANonBlankAttribute.new(name: nil, age: "")
|
27
|
-
|
26
|
+
spec "both empty" do
|
27
|
+
@va = ANonBlankAttribute.new(name: nil, age: "")
|
28
|
+
! @va.valid?
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
data/va.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: va
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Federico Iachetti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: matest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.1.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.1.3
|
55
55
|
description: Minimalistic framework agnostic Validator.
|
56
56
|
email:
|
57
57
|
- iachetti.federico@gmail.com
|