validocno 0.0.4 → 0.1.0

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
- SHA1:
3
- metadata.gz: 1c3dcc97a6fc2dbf8e31d24f40a1ccd292f3e006
4
- data.tar.gz: 2d0e220cae2235931d5fe2f4ae1aeebef279b9bf
5
2
  SHA512:
6
- metadata.gz: ec4aa02e190faba1fce5ff17005633cd56cf7600b175110aad2fb44277584b9eb0beb5adf4e62a2a8ddd7b0862c3c01a1cff8281be9832cd0927d170d5a4da55
7
- data.tar.gz: dd00d4950ad63e9b2db3b236b288982aec051b04b3ee739dad9838d5b693d0e7db53505b2e1e4b7053302acf25d8b2e50970294f8712fcefbe9aa7a557843c72
3
+ metadata.gz: 185b383a8583ca4c0bb9d13dc31f130c213e0a34fb39030a9eb4e6810997022aec3069e76303eb95a02058bb19e45add7f95547a8408c0f05494b1f1deed02b8
4
+ data.tar.gz: 726084ea929a160371b3a2e844a0d4b6c852c530d4bbf6d631ee3d9fc64852c39cffffc04d9457aa9fff02a952ac9da6640e983dcc722809914eac15126358f2
5
+ SHA1:
6
+ metadata.gz: e9ecae61688b852b69d897fa32600a8139402e4d
7
+ data.tar.gz: dacbe802188d7d89b01a6e2d94ca6a2684ee8bf6
@@ -44,9 +44,13 @@ module Validocno
44
44
  end
45
45
  end
46
46
 
47
- def valid?
48
- return true if response_string.match(response_strings[:valid])
49
- false
47
+ def validate
48
+ is_valid = response_string.match(response_strings[:valid]) ? true : false
49
+
50
+ {
51
+ :valid => is_valid,
52
+ :message => response_string
53
+ }
50
54
  end
51
55
 
52
56
  def response_strings
@@ -1,3 +1,3 @@
1
1
  module Validocno
2
- VERSION = '0.0.4'
2
+ VERSION = '0.1.0'
3
3
  end
data/lib/validocno.rb CHANGED
@@ -11,8 +11,8 @@ require 'validocno/version'
11
11
  require 'validocno/http_client'
12
12
 
13
13
  module Validocno
14
- def self.valid?(doc_number)
14
+ def self.validate(doc_number)
15
15
  validator = Validocno::Validator.new(doc_number)
16
- validator.valid?
16
+ validator.validate
17
17
  end
18
18
  end
@@ -20,16 +20,36 @@ describe Validocno::Validator do
20
20
 
21
21
  end
22
22
 
23
- describe '#valid?' do
23
+ describe '#validate' do
24
24
  let(:invalid_doc_number) { 'A1234567890' }
25
- let(:invalid_validator) { Validocno::Validator.new(invalid_doc_number) }
25
+ let(:expired_doc_number) { 'A0111856' }
26
+ let(:validator_with_invalid) { Validocno::Validator.new(invalid_doc_number) }
27
+ let(:validator_with_expired) { Validocno::Validator.new(expired_doc_number) }
26
28
 
27
- it 'returns true when document with valid number provided' do
28
- expect(validator).to be_valid
29
+ it 'returns hash with :valid and :message keys' do
30
+ expect(validator.validate).to have_key(:valid)
31
+ expect(validator.validate).to have_key(:message)
29
32
  end
30
33
 
31
- it 'returns false when document with invalid number provided' do
32
- expect(invalid_validator).to_not be_valid
34
+ it 'validates document with valid number' do
35
+ expect(validator.validate).to include(
36
+ :valid => true,
37
+ :message => "Dokument #{doc_number} on kehtiv."
38
+ )
39
+ end
40
+
41
+ it 'validates expired document' do
42
+ expect(validator_with_expired.validate).to include(
43
+ :valid => false,
44
+ :message => "Dokument #{expired_doc_number} on kehtetu."
45
+ )
46
+ end
47
+
48
+ it 'validates document with invalid number' do
49
+ expect(validator_with_invalid.validate).to include(
50
+ :valid => false,
51
+ :message => "Dokumenti #{invalid_doc_number} ei ole välja antud."
52
+ )
33
53
  end
34
54
  end
35
55
  end
@@ -1,20 +1,39 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Validocno do
4
- describe '.valid?' do
4
+ describe '.validate' do
5
5
  let(:valid_doc_number) { 'A1234567' }
6
+ let(:expired_doc_number) { 'A0111856' }
6
7
  let(:invalid_doc_number) { 'A1234567890' }
7
8
 
8
- it 'returns true when document with valid number provided' do
9
- expect(Validocno.valid?(valid_doc_number)).to be true
9
+ it 'returns hash with :valid and :message keys' do
10
+ expect(Validocno.validate(valid_doc_number)).to have_key(:valid)
11
+ expect(Validocno.validate(valid_doc_number)).to have_key(:message)
10
12
  end
11
13
 
12
- it 'returns false when document with invalid number provided' do
13
- expect(Validocno.valid?(invalid_doc_number)).to be false
14
+ it 'validates document with valid number' do
15
+ expect(Validocno.validate(valid_doc_number)).to include(
16
+ :valid => true,
17
+ :message => "Dokument #{valid_doc_number} on kehtiv."
18
+ )
19
+ end
20
+
21
+ it 'validates expired document' do
22
+ expect(Validocno.validate(expired_doc_number)).to include(
23
+ :valid => false,
24
+ :message => "Dokument #{expired_doc_number} on kehtetu."
25
+ )
26
+ end
27
+
28
+ it 'validates document with invalid number' do
29
+ expect(Validocno.validate(invalid_doc_number)).to include(
30
+ :valid => false,
31
+ :message => "Dokumenti #{invalid_doc_number} ei ole välja antud."
32
+ )
14
33
  end
15
34
 
16
35
  it 'raises an error without a document number' do
17
- expect { Validocno.valid? }.to raise_error(ArgumentError)
36
+ expect { Validocno.validate }.to raise_error(ArgumentError)
18
37
  end
19
38
  end
20
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validocno
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Pakk
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-12-03 00:00:00 Z
12
+ date: 2014-12-04 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: &id001 !ruby/object:Gem::Requirement