callcredit 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/callcredit.gemspec +2 -2
- data/lib/callcredit/request.rb +1 -1
- data/lib/callcredit/version.rb +1 -1
- data/spec/callcredit_spec.rb +9 -5
- data/spec/checks/id_enhanced_spec.rb +9 -5
- data/spec/client_spec.rb +8 -2
- data/spec/request_spec.rb +11 -7
- data/spec/response_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -2
- data/spec/validations_spec.rb +9 -9
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1213865aa7687c9adfd222ffeed8c2e1e6a76ccd
|
4
|
+
data.tar.gz: 2e1265299afc2b3198eb4c1c0c07da6e809dd6fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88f56e2dce84202fdaed7891de549f8e6c4d89400c6c6b1718efe717fc50368f7ef990ccd9a066ff5568f69388db2a6e9020e38b0e06f732bc1d4cb0581f4259
|
7
|
+
data.tar.gz: 321382da4b9e994eeb5c702c166ff78a8372e5bfb3d640b17a6d8dc596339427c1d507354f87e437bf0945b6021ea5f9cd53887762a2faf4e0bbd8f90e2ba80f
|
data/CHANGELOG.md
CHANGED
data/callcredit.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.add_runtime_dependency 'nokogiri', '~> 1.4'
|
7
7
|
gem.add_runtime_dependency 'unicode_utils', '~> 1.4.0'
|
8
8
|
|
9
|
-
gem.add_development_dependency 'rspec', '~>
|
10
|
-
gem.add_development_dependency 'webmock', '~> 1.
|
9
|
+
gem.add_development_dependency 'rspec', '~> 3.0.0'
|
10
|
+
gem.add_development_dependency 'webmock', '~> 1.18.0'
|
11
11
|
|
12
12
|
gem.authors = ['Grey Baker']
|
13
13
|
gem.description = %q{Ruby wrapper for Callcredit's CallValidate API}
|
data/lib/callcredit/request.rb
CHANGED
data/lib/callcredit/version.rb
CHANGED
data/spec/callcredit_spec.rb
CHANGED
@@ -8,7 +8,11 @@ describe Callcredit do
|
|
8
8
|
Callcredit::Config::DEFAULT_OPTIONS.keys.map(&:to_sym).each do |key|
|
9
9
|
context "setting #{key}" do
|
10
10
|
before { Callcredit.configure { |config| config[key] = key } }
|
11
|
-
|
11
|
+
|
12
|
+
describe [key] do
|
13
|
+
subject { super()[key] }
|
14
|
+
it { should == key }
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
@@ -26,8 +30,8 @@ describe Callcredit do
|
|
26
30
|
let(:data) { { first_name: "Grey", last_name: "Baker" } }
|
27
31
|
|
28
32
|
it "delegates to the client" do
|
29
|
-
Callcredit::Client.
|
30
|
-
|
33
|
+
expect_any_instance_of(Callcredit::Client).
|
34
|
+
to receive(:id_enhanced_check).with(data)
|
31
35
|
Callcredit.id_enhanced_check(data)
|
32
36
|
end
|
33
37
|
end
|
@@ -39,8 +43,8 @@ describe Callcredit do
|
|
39
43
|
end
|
40
44
|
|
41
45
|
it "delegates to the client" do
|
42
|
-
Callcredit::Client.
|
43
|
-
|
46
|
+
expect_any_instance_of(Callcredit::Client).
|
47
|
+
to receive(:perform_check).with(:id_enhanced_check, data)
|
44
48
|
Callcredit.perform_check(:id_enhanced_check, data)
|
45
49
|
end
|
46
50
|
end
|
@@ -24,15 +24,19 @@ describe Callcredit::Checks::IDEnhanced do
|
|
24
24
|
|
25
25
|
it "makes a get request" do
|
26
26
|
perform_check
|
27
|
-
a_request(:get, config[:api_endpoint]).
|
27
|
+
expect(a_request(:get, config[:api_endpoint])).to have_been_made
|
28
28
|
end
|
29
29
|
|
30
|
-
it {
|
30
|
+
it { is_expected.to be_a Callcredit::Response }
|
31
31
|
|
32
32
|
context "when the config[:raw] is true" do
|
33
33
|
before { config[:raw] = true }
|
34
|
-
it {
|
35
|
-
|
34
|
+
it { is_expected.to be_a Faraday::Response }
|
35
|
+
|
36
|
+
describe '#body' do
|
37
|
+
subject { super().body }
|
38
|
+
it { should be_a String }
|
39
|
+
end
|
36
40
|
end
|
37
41
|
|
38
42
|
describe "validates inputs" do
|
@@ -48,7 +52,7 @@ describe Callcredit::Checks::IDEnhanced do
|
|
48
52
|
|
49
53
|
it "makes a get request" do
|
50
54
|
perform_check
|
51
|
-
a_request(:get, config[:api_endpoint]).
|
55
|
+
expect(a_request(:get, config[:api_endpoint])).to have_been_made
|
52
56
|
end
|
53
57
|
end
|
54
58
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -10,7 +10,10 @@ describe Callcredit::Client do
|
|
10
10
|
before { configure_callcredit }
|
11
11
|
subject(:new_client) { Callcredit::Client.new }
|
12
12
|
|
13
|
-
|
13
|
+
describe '#config' do
|
14
|
+
subject { super().config }
|
15
|
+
it { should_not == Callcredit.config }
|
16
|
+
end
|
14
17
|
it "has the attributes of the global config" do
|
15
18
|
new_client.config[:first_name] == Callcredit.config[:first_name]
|
16
19
|
end
|
@@ -20,7 +23,10 @@ describe Callcredit::Client do
|
|
20
23
|
before { config[:first_name] = "test" }
|
21
24
|
subject(:new_client) { Callcredit::Client.new(config) }
|
22
25
|
|
23
|
-
|
26
|
+
describe '#config' do
|
27
|
+
subject { super().config }
|
28
|
+
it { should_not == config }
|
29
|
+
end
|
24
30
|
it "has the attributes of the passed in config" do
|
25
31
|
new_client.config[:first_name] == config[:first_name]
|
26
32
|
end
|
data/spec/request_spec.rb
CHANGED
@@ -32,13 +32,13 @@ describe Callcredit::Request do
|
|
32
32
|
let(:xsd) { Nokogiri::XML::Schema(xml_schema) }
|
33
33
|
|
34
34
|
it "generates a valid XML request" do
|
35
|
-
xsd.validate(request_xml).
|
35
|
+
expect(xsd.validate(request_xml)).to eq([])
|
36
36
|
end
|
37
37
|
|
38
38
|
context "with a date object for date_of_birth" do
|
39
39
|
let(:date_of_birth) { Date.parse("01/01/2000") }
|
40
40
|
it "generates a valid XML request" do
|
41
|
-
xsd.validate(request_xml).
|
41
|
+
expect(xsd.validate(request_xml)).to eq([])
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -48,18 +48,22 @@ describe Callcredit::Request do
|
|
48
48
|
|
49
49
|
it "makes a get request" do
|
50
50
|
perform_check
|
51
|
-
a_request(:get, config[:api_endpoint]).
|
51
|
+
expect(a_request(:get, config[:api_endpoint])).to have_been_made
|
52
52
|
end
|
53
53
|
|
54
54
|
context "when the config[:raw] is true" do
|
55
55
|
before { config[:raw] = true }
|
56
|
-
it {
|
57
|
-
|
56
|
+
it { is_expected.to be_a Faraday::Response }
|
57
|
+
|
58
|
+
describe '#body' do
|
59
|
+
subject { super().body }
|
60
|
+
it { should be_a String }
|
61
|
+
end
|
58
62
|
end
|
59
63
|
|
60
64
|
context "when the config[:raw] is false" do
|
61
|
-
it {
|
62
|
-
it {
|
65
|
+
it { is_expected.to be_a Hash }
|
66
|
+
it { is_expected.to include "Results" }
|
63
67
|
|
64
68
|
context "errors" do
|
65
69
|
context "500" do
|
data/spec/response_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'callcredit'
|
2
2
|
require 'webmock/rspec'
|
3
|
-
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.mock_with(:rspec) { |mocks| mocks.verify_partial_doubles = true }
|
6
|
+
config.raise_errors_for_deprecations!
|
7
|
+
config.include WebMock::API
|
8
|
+
end
|
4
9
|
|
5
10
|
def configure_callcredit
|
6
11
|
Callcredit.configure do |config|
|
@@ -23,4 +28,4 @@ shared_examples "it validates presence" do |property|
|
|
23
28
|
expect { subject }.to raise_error Callcredit::InvalidRequestError
|
24
29
|
end
|
25
30
|
end
|
26
|
-
end
|
31
|
+
end
|
data/spec/validations_spec.rb
CHANGED
@@ -6,17 +6,17 @@ describe Callcredit::Validations do
|
|
6
6
|
|
7
7
|
context "without a date of birth" do
|
8
8
|
let(:date_of_birth) { nil }
|
9
|
-
it {
|
9
|
+
it { is_expected.to eq(nil) }
|
10
10
|
end
|
11
11
|
|
12
12
|
context "with a date object" do
|
13
13
|
let(:date_of_birth) { Date.parse("01/01/2000") }
|
14
|
-
it {
|
14
|
+
it { is_expected.to eq(date_of_birth.strftime("%d/%m/%Y")) }
|
15
15
|
end
|
16
16
|
|
17
17
|
context "with a parseable string" do
|
18
18
|
let(:date_of_birth) { "01-01-2000" }
|
19
|
-
it {
|
19
|
+
it { is_expected.to eq("01/01/2000") }
|
20
20
|
end
|
21
21
|
|
22
22
|
context "with a load of rubbish" do
|
@@ -32,17 +32,17 @@ describe Callcredit::Validations do
|
|
32
32
|
|
33
33
|
context "without a name" do
|
34
34
|
let(:name) { nil }
|
35
|
-
it {
|
35
|
+
it { is_expected.to eq(nil) }
|
36
36
|
end
|
37
37
|
|
38
38
|
context "with a simple name" do
|
39
39
|
let(:name) { "Grey" }
|
40
|
-
it {
|
40
|
+
it { is_expected.to eq(name) }
|
41
41
|
end
|
42
42
|
|
43
43
|
context "with a name with non-ASCII characters" do
|
44
44
|
let(:name) { "Gréy" }
|
45
|
-
it {
|
45
|
+
it { is_expected.to eq("Grey") }
|
46
46
|
end
|
47
47
|
|
48
48
|
context "with a very long name" do
|
@@ -65,17 +65,17 @@ describe Callcredit::Validations do
|
|
65
65
|
|
66
66
|
context "without a postcode" do
|
67
67
|
let(:postcode) { nil }
|
68
|
-
it {
|
68
|
+
it { is_expected.to eq(nil) }
|
69
69
|
end
|
70
70
|
|
71
71
|
context "with a correct postcode" do
|
72
72
|
let(:postcode) { "EC2A 1DX" }
|
73
|
-
it {
|
73
|
+
it { is_expected.to eq(postcode) }
|
74
74
|
end
|
75
75
|
|
76
76
|
context "with a padded postcode" do
|
77
77
|
let(:postcode) { "EC2A 1DX " }
|
78
|
-
it {
|
78
|
+
it { is_expected.to eq("EC2A 1DX") }
|
79
79
|
end
|
80
80
|
|
81
81
|
context "with a postcode that is too short" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: callcredit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grey Baker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday_middleware
|
@@ -78,28 +78,28 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - ~>
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
81
|
+
version: 3.0.0
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - ~>
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
88
|
+
version: 3.0.0
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: webmock
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - ~>
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 1.
|
95
|
+
version: 1.18.0
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - ~>
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 1.
|
102
|
+
version: 1.18.0
|
103
103
|
description: Ruby wrapper for Callcredit's CallValidate API
|
104
104
|
email:
|
105
105
|
- grey@gocardless.com
|