pupa 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3539ca0b77fc4b2174c42857990638713dac180
4
- data.tar.gz: c5a18a0390ac9a3a48e0ba868ac1dd627af0db08
3
+ metadata.gz: 5c9f14316f20d5b37194d8e61ead60c90eaf1e41
4
+ data.tar.gz: 50b4de7a5b95f287f46760356e22c5fe45cbc03a
5
5
  SHA512:
6
- metadata.gz: c93da2b8ff26107c28e02e51b8ea2ec999b5e086cc8564e0af6062a58af7fe3b71429e20d26eefc57471313da578699218a4098cd35ca94eed831340f63beef1
7
- data.tar.gz: 2444a4491a3c0b499f4dd40c4b188a72644fc4fddec941471816747bb2e694bd5b96c7d550fe4dd98ed6c477b358ade25b25cf17c3a329ca8733929f6041252c
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 (address.address == data && address.domain && address.__send__(:tree).domain.dot_atom_text.elements.size > 1 rescue false)
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
@@ -1,3 +1,3 @@
1
1
  module Pupa
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -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.8
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