pupa 0.1.8 → 0.1.9
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/lib/pupa/refinements/json-schema.rb +1 -1
- data/lib/pupa/version.rb +1 -1
- data/spec/refinements/json-schema_spec.rb +38 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c9f14316f20d5b37194d8e61ead60c90eaf1e41
|
4
|
+
data.tar.gz: 50b4de7a5b95f287f46760356e22c5fe45cbc03a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1abbc8fa6cd13e2a53ee675e8c57d040668dd9606ec62ef800a8143c35b50b5403d1085bb12a83d3e4239fac178b0f0e50d6c5c0df3d76f541df5bfd0538b909
|
7
|
+
data.tar.gz: b307d48deb6b948b53d42c8d76481f6c011d84665543315ca3cdaa1e1b7d329dd8696f735a2956d9fda2875f607b23f638494de063d8e99a39f723d5643b0d50
|
@@ -11,7 +11,7 @@ module Pupa
|
|
11
11
|
when 'email'
|
12
12
|
if String === data
|
13
13
|
address = Mail::Address.new(data)
|
14
|
-
unless
|
14
|
+
unless address.address == data && address.domain && address.domain.split('.').size > 1
|
15
15
|
error_message = "The property '#{build_fragment(fragments)}' must be a valid email address (#{data})"
|
16
16
|
validation_error(processor, error_message, fragments, current_schema, self, options[:record_errors])
|
17
17
|
end
|
data/lib/pupa/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Pupa::Refinements do
|
4
|
+
let(:schema) do
|
5
|
+
{
|
6
|
+
'properties' => {
|
7
|
+
'email' => {
|
8
|
+
'type' => ['string', 'null'],
|
9
|
+
'format' => 'email',
|
10
|
+
},
|
11
|
+
'uri' => {
|
12
|
+
'type' => ['string', 'null'],
|
13
|
+
'format' => 'uri',
|
14
|
+
},
|
15
|
+
}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'email validation' do
|
20
|
+
it 'should not raise an error if valid' do
|
21
|
+
expect{JSON::Validator.validate!(schema, 'email' => 'ceo@example.com')}.to_not raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should raise an error if invalid' do
|
25
|
+
expect{JSON::Validator.validate!(schema, 'email' => 'example.com')}.to raise_error(JSON::Schema::ValidationError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'uri validation' do
|
30
|
+
it 'should not raise an error if valid' do
|
31
|
+
expect{JSON::Validator.validate!(schema, 'uri' => 'scheme://user:pass@host/path?query#fragment')}.to_not raise_error
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should raise an error if invalid' do
|
35
|
+
expect{JSON::Validator.validate!(schema, 'uri' => 'example.com')}.to raise_error(JSON::Schema::ValidationError)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pupa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Open North
|
@@ -384,6 +384,7 @@ files:
|
|
384
384
|
- spec/processor/middleware/parse_json_spec.rb
|
385
385
|
- spec/processor/yielder_spec.rb
|
386
386
|
- spec/processor_spec.rb
|
387
|
+
- spec/refinements/json-schema_spec.rb
|
387
388
|
- spec/refinements/opencivicdata_spec.rb
|
388
389
|
- spec/runner_spec.rb
|
389
390
|
- spec/spec_helper.rb
|
@@ -447,6 +448,7 @@ test_files:
|
|
447
448
|
- spec/processor/middleware/parse_json_spec.rb
|
448
449
|
- spec/processor/yielder_spec.rb
|
449
450
|
- spec/processor_spec.rb
|
451
|
+
- spec/refinements/json-schema_spec.rb
|
450
452
|
- spec/refinements/opencivicdata_spec.rb
|
451
453
|
- spec/runner_spec.rb
|
452
454
|
- spec/spec_helper.rb
|