object-inspector 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +45 -0
- data/README.md +335 -0
- data/Rakefile +13 -0
- data/examples/example.rb +131 -0
- data/features/error_display.feature +80 -0
- data/features/support/env.rb +1 -0
- data/features/syntax.feature +223 -0
- data/inspector.gemspec +24 -0
- data/lib/inspector.rb +27 -0
- data/lib/inspector/attribute_metadata.rb +19 -0
- data/lib/inspector/constraint.rb +18 -0
- data/lib/inspector/constraint/validators.rb +8 -0
- data/lib/inspector/constraint/validators/simple.rb +13 -0
- data/lib/inspector/constraint/validators/validity.rb +24 -0
- data/lib/inspector/constraint/violation.rb +34 -0
- data/lib/inspector/constraint/violation/list.rb +93 -0
- data/lib/inspector/constraints.rb +61 -0
- data/lib/inspector/constraints/email.rb +57 -0
- data/lib/inspector/constraints/empty.rb +21 -0
- data/lib/inspector/constraints/eq.rb +23 -0
- data/lib/inspector/constraints/false.rb +19 -0
- data/lib/inspector/constraints/have.rb +85 -0
- data/lib/inspector/constraints/predicate.rb +38 -0
- data/lib/inspector/constraints/true.rb +19 -0
- data/lib/inspector/constraints/valid.rb +31 -0
- data/lib/inspector/metadata.rb +75 -0
- data/lib/inspector/metadata/map.rb +24 -0
- data/lib/inspector/metadata/walker.rb +46 -0
- data/lib/inspector/property_metadata.rb +19 -0
- data/lib/inspector/type_metadata.rb +5 -0
- data/lib/inspector/validator.rb +26 -0
- data/lib/inspector/version.rb +3 -0
- data/lib/object_inspector.rb +1 -0
- data/spec/inspector/attribute_metadata_spec.rb +8 -0
- data/spec/inspector/constraint/violation/list_spec.rb +45 -0
- data/spec/inspector/constraints/false_spec.rb +18 -0
- data/spec/inspector/constraints_spec.rb +15 -0
- data/spec/inspector/metadata/map_spec.rb +38 -0
- data/spec/inspector/metadata/walker_spec.rb +7 -0
- data/spec/inspector/property_metadata_spec.rb +8 -0
- data/spec/inspector/type_metadata_spec.rb +7 -0
- data/spec/inspector/validator_spec.rb +65 -0
- data/spec/inspector_spec.rb +22 -0
- data/spec/shared_examples/metadata.rb +33 -0
- data/spec/spec_helper.rb +3 -0
- metadata +175 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe(Inspector) do
|
4
|
+
let(:validator) { double() }
|
5
|
+
before(:each) do
|
6
|
+
Inspector.instance_variable_set(:@validator, validator)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#valid" do
|
10
|
+
it "calls @validator.valid" do
|
11
|
+
validator.should_receive(:valid).once.with("validator name")
|
12
|
+
Inspector.valid("validator name")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#validate" do
|
17
|
+
it "calls @validator.validate" do
|
18
|
+
validator.should_receive(:validate).once.with("value")
|
19
|
+
Inspector.validate("value")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples_for Inspector::Metadata do
|
4
|
+
let(:type) { double() }
|
5
|
+
|
6
|
+
describe "#type" do
|
7
|
+
it "is the original type" do
|
8
|
+
expect(metadata.type).to be(type)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#constraints" do
|
13
|
+
it "are empty" do
|
14
|
+
expect(metadata.constraints).to be_empty
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#attribute" do
|
19
|
+
it "adds attribute metadata" do
|
20
|
+
expect {
|
21
|
+
metadata.attribute(:attribute)
|
22
|
+
}.to change { metadata.attribute_metadatas.length }.from(0).to(1)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#property" do
|
27
|
+
it "adds property metadata" do
|
28
|
+
expect {
|
29
|
+
metadata.property(:property)
|
30
|
+
}.to change { metadata.property_metadatas.length }.from(0).to(1)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: object-inspector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Bulat Shakirzyanov
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.6'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.6'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: cucumber
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.2'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.2'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: aruba
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.4'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.4'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.9'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.9'
|
78
|
+
description: Inspector is a validation library for Ruby with zero assumptions
|
79
|
+
email:
|
80
|
+
- mallluhuct@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- Gemfile.lock
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- examples/example.rb
|
91
|
+
- features/error_display.feature
|
92
|
+
- features/support/env.rb
|
93
|
+
- features/syntax.feature
|
94
|
+
- inspector.gemspec
|
95
|
+
- lib/inspector.rb
|
96
|
+
- lib/inspector/attribute_metadata.rb
|
97
|
+
- lib/inspector/constraint.rb
|
98
|
+
- lib/inspector/constraint/validators.rb
|
99
|
+
- lib/inspector/constraint/validators/simple.rb
|
100
|
+
- lib/inspector/constraint/validators/validity.rb
|
101
|
+
- lib/inspector/constraint/violation.rb
|
102
|
+
- lib/inspector/constraint/violation/list.rb
|
103
|
+
- lib/inspector/constraints.rb
|
104
|
+
- lib/inspector/constraints/email.rb
|
105
|
+
- lib/inspector/constraints/empty.rb
|
106
|
+
- lib/inspector/constraints/eq.rb
|
107
|
+
- lib/inspector/constraints/false.rb
|
108
|
+
- lib/inspector/constraints/have.rb
|
109
|
+
- lib/inspector/constraints/predicate.rb
|
110
|
+
- lib/inspector/constraints/true.rb
|
111
|
+
- lib/inspector/constraints/valid.rb
|
112
|
+
- lib/inspector/metadata.rb
|
113
|
+
- lib/inspector/metadata/map.rb
|
114
|
+
- lib/inspector/metadata/walker.rb
|
115
|
+
- lib/inspector/property_metadata.rb
|
116
|
+
- lib/inspector/type_metadata.rb
|
117
|
+
- lib/inspector/validator.rb
|
118
|
+
- lib/inspector/version.rb
|
119
|
+
- lib/object_inspector.rb
|
120
|
+
- spec/inspector/attribute_metadata_spec.rb
|
121
|
+
- spec/inspector/constraint/violation/list_spec.rb
|
122
|
+
- spec/inspector/constraints/false_spec.rb
|
123
|
+
- spec/inspector/constraints_spec.rb
|
124
|
+
- spec/inspector/metadata/map_spec.rb
|
125
|
+
- spec/inspector/metadata/walker_spec.rb
|
126
|
+
- spec/inspector/property_metadata_spec.rb
|
127
|
+
- spec/inspector/type_metadata_spec.rb
|
128
|
+
- spec/inspector/validator_spec.rb
|
129
|
+
- spec/inspector_spec.rb
|
130
|
+
- spec/shared_examples/metadata.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
homepage: http://avalanche123.github.com/inspector
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ! '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 1.9.2
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ! '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
hash: -3039712991579498207
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 1.8.24
|
157
|
+
signing_key:
|
158
|
+
specification_version: 3
|
159
|
+
summary: inspector - ruby validation library
|
160
|
+
test_files:
|
161
|
+
- features/error_display.feature
|
162
|
+
- features/support/env.rb
|
163
|
+
- features/syntax.feature
|
164
|
+
- spec/inspector/attribute_metadata_spec.rb
|
165
|
+
- spec/inspector/constraint/violation/list_spec.rb
|
166
|
+
- spec/inspector/constraints/false_spec.rb
|
167
|
+
- spec/inspector/constraints_spec.rb
|
168
|
+
- spec/inspector/metadata/map_spec.rb
|
169
|
+
- spec/inspector/metadata/walker_spec.rb
|
170
|
+
- spec/inspector/property_metadata_spec.rb
|
171
|
+
- spec/inspector/type_metadata_spec.rb
|
172
|
+
- spec/inspector/validator_spec.rb
|
173
|
+
- spec/inspector_spec.rb
|
174
|
+
- spec/shared_examples/metadata.rb
|
175
|
+
- spec/spec_helper.rb
|