eapi 0.2.1 → 0.3.0
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 +4 -4
- data/README.md +316 -237
- data/lib/eapi/definition_runners/property.rb +21 -6
- data/lib/eapi/definition_runners/runner.rb +4 -0
- data/lib/eapi/errors.rb +6 -0
- data/lib/eapi/methods/accessor.rb +25 -2
- data/lib/eapi/methods/names.rb +4 -0
- data/lib/eapi/methods/properties.rb +17 -15
- data/lib/eapi/methods/types.rb +14 -2
- data/lib/eapi/type_checker.rb +23 -7
- data/lib/eapi/value_converter.rb +10 -0
- data/lib/eapi/version.rb +1 -1
- data/spec/list_elements_spec.rb +149 -48
- data/spec/validations_spec.rb +33 -0
- metadata +2 -2
data/spec/validations_spec.rb
CHANGED
|
@@ -166,6 +166,39 @@ RSpec.describe Eapi do
|
|
|
166
166
|
expect(eapi).to be_valid
|
|
167
167
|
end
|
|
168
168
|
end
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
describe 'using a string as type that is not a class' do
|
|
172
|
+
class SomeValueSomethingTrue
|
|
173
|
+
def is?(type)
|
|
174
|
+
type.to_s == 'my_something'
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
class SomeValueSomethingFalse
|
|
179
|
+
def is?(type)
|
|
180
|
+
type.to_s == 'not'
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
class MyTestClassValTypeStringNotClass
|
|
185
|
+
include Eapi::List
|
|
186
|
+
|
|
187
|
+
property :something, type: 'my_something'
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it 'valid if value returns true to `is?(type)`' do
|
|
191
|
+
eapi = MyTestClassValTypeStringNotClass.new something: SomeValueSomethingTrue.new
|
|
192
|
+
expect(eapi).to be_valid
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it 'invalid if value returns false to `is?(type)`' do
|
|
196
|
+
eapi = MyTestClassValTypeStringNotClass.new something: SomeValueSomethingFalse.new
|
|
197
|
+
expect(eapi).not_to be_valid
|
|
198
|
+
expect(eapi.errors.full_messages).to eq ["Something must be a my_something"]
|
|
199
|
+
expect(eapi.errors.messages).to eq({something: ["must be a my_something"]})
|
|
200
|
+
end
|
|
201
|
+
end
|
|
169
202
|
end
|
|
170
203
|
end
|
|
171
204
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eduardo Turiño
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-07-
|
|
11
|
+
date: 2014-07-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|