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.
@@ -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.2.1
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-17 00:00:00.000000000 Z
11
+ date: 2014-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler