companies-house-gateway 0.3.10 → 0.3.11

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: 05a3d186a2b57c5de2e17b78a83a675e9153e0c0
4
- data.tar.gz: 3588395c41471554e498d46e42bb452a624c28f7
3
+ metadata.gz: 04cf38078081525f799988721cdbf1b56edeff84
4
+ data.tar.gz: 7d930409cc38db5bb0ce57180953fc4d0b0f2752
5
5
  SHA512:
6
- metadata.gz: 58f37a2cd12dadb470d10704dcf50ec443437c3f8b48dbf54d0002b379dd6b2c945759d1cdfb29aa2ed7261c205531cb96d386f7506b2d7a87f33ca507c2abf6
7
- data.tar.gz: 5a8f495818a5196eb50d67ebab79d5fc0147223a152eca941a277af2bfaa810f28a3c1a6733d891b7057d691e3c3f99cabe3ccd4702f79f027487933dc3e4fe2
6
+ metadata.gz: 216bc972349999e778674cb0fe63d4ef2af2aef28059f805ced622099a1db751d594222d20ee31114c0ed3d185505b7726ce7063e16e58d297115abf275a0103
7
+ data.tar.gz: a27e4551ee2a88f49006a1e1f80c35617d70fdff0ceada8c263c35a806fa6e58b67c73ca4302d9cffdfe8deb080336f2198a6ca88f925a0c2b0ac65e2a50addc
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.0
4
- - 2.0.0
5
3
  - 1.9.3
6
- - 1.9.2
4
+ - 2.0.0
5
+ - 2.1
6
+ - 2.2
7
7
  notifications:
8
8
  email:
9
9
  recipients:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.3.11 - June 28, 2015
2
+
3
+ - Upcase company numbers whilst cleaning them. Stops lower-case prefixes
4
+ causing errors
5
+
1
6
  ## 0.3.10 - June 3, 2014
2
7
 
3
8
  - Add support for Faraday 0.9
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Companies House Gateway
2
2
 
3
- Simple Ruby Gem for interacting with the Companies House XML Gateway API. Wraps
4
- the XML submissions and responses required so you can deal with Ruby hashes
5
- instead.
3
+ Simple Ruby Gem for interacting with the [Companies House XML Gateway API](http://xmlgw.companieshouse.gov.uk/).
6
4
 
7
5
  [![Gem Version](https://badge.fury.io/rb/companies-house-gateway.svg)](http://badge.fury.io/rb/companies-house-gateway)
8
6
  [![Build Status](https://travis-ci.org/gocardless/companies-house-gateway-ruby.svg?branch=master)](https://travis-ci.org/gocardless/companies-house-gateway-ruby)
@@ -5,8 +5,8 @@ Gem::Specification.new do |gem|
5
5
  gem.add_runtime_dependency 'multi_xml', '~> 0.5.1'
6
6
  gem.add_runtime_dependency 'nokogiri', '~> 1.4'
7
7
 
8
- gem.add_development_dependency 'rspec', '~> 2.14.1'
9
- gem.add_development_dependency 'webmock', '~> 1.17.2'
8
+ gem.add_development_dependency 'rspec', '~> 3.0'
9
+ gem.add_development_dependency 'webmock', '~> 1.21'
10
10
 
11
11
  gem.authors = ['Grey Baker']
12
12
  gem.description = %q{Ruby wrapper for the Companies House XML Gateway}
@@ -69,6 +69,7 @@ module CompaniesHouseGateway
69
69
  def self.clean_company_number(number)
70
70
  return unless number
71
71
  number = number.to_s.strip # remove whitespace
72
+ number = number.upcase # upcase any prefixes
72
73
 
73
74
  # 0-pad 5 or 7 digit registration number
74
75
  if number.match /\A(\D{2})(\d{5})\z/
@@ -94,4 +95,4 @@ module CompaniesHouseGateway
94
95
  raise InvalidRequestError.new(msg, param)
95
96
  end
96
97
  end
97
- end
98
+ end
@@ -1,3 +1,3 @@
1
1
  module CompaniesHouseGateway
2
- VERSION = '0.3.10'.freeze
2
+ VERSION = '0.3.11'.freeze
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -19,7 +19,10 @@ describe CompaniesHouseGateway::Client do
19
19
  before { configure_companies_house_gateway }
20
20
  subject(:new_client) { CompaniesHouseGateway::Client.new }
21
21
 
22
- its(:config) { should_not == CompaniesHouseGateway.config }
22
+ describe '#config' do
23
+ subject { super().config }
24
+ it { should_not == CompaniesHouseGateway.config }
25
+ end
23
26
  it "has the attributes of the global config" do
24
27
  new_client.config[:sender_id] ==
25
28
  CompaniesHouseGateway.config[:sender_id]
@@ -30,7 +33,10 @@ describe CompaniesHouseGateway::Client do
30
33
  before { config[:first_name] = "test" }
31
34
  subject(:new_client) { CompaniesHouseGateway::Client.new(config) }
32
35
 
33
- its(:config) { should_not == config }
36
+ describe '#config' do
37
+ subject { super().config }
38
+ it { should_not == config }
39
+ end
34
40
  it "has the attributes of the passed in config" do
35
41
  new_client.config[:sender_id] == config[:sender_id]
36
42
  end
@@ -5,8 +5,8 @@ shared_examples "it delegates to the client" do |method_name|
5
5
  let(:data) { "data" }
6
6
 
7
7
  it "delegates #{method_name} to the client" do
8
- CompaniesHouseGateway::Client.any_instance.
9
- should_receive(method_name).with(data)
8
+ expect_any_instance_of(CompaniesHouseGateway::Client).
9
+ to receive(method_name).with(data)
10
10
  CompaniesHouseGateway.send(method_name, data)
11
11
  end
12
12
  end
@@ -21,7 +21,11 @@ describe CompaniesHouseGateway do
21
21
  before do
22
22
  CompaniesHouseGateway.configure { |config| config[key] = key }
23
23
  end
24
- its([key]) { should == key }
24
+
25
+ describe [key] do
26
+ subject { super()[key] }
27
+ it { should == key }
28
+ end
25
29
  end
26
30
  end
27
31
  end
data/spec/request_spec.rb CHANGED
@@ -25,14 +25,14 @@ describe CompaniesHouseGateway::Request do
25
25
  let(:xsd) { Nokogiri::XML::Schema(xml_schema) }
26
26
 
27
27
  it "generates a valid XML request" do
28
- xsd.validate(request_xml).should == []
28
+ expect(xsd.validate(request_xml)).to eq([])
29
29
  end
30
30
 
31
31
  context "with an email address" do
32
32
  before { config[:email] = "grey@gocardless.com" }
33
33
 
34
34
  it "generates a valid XML request" do
35
- xsd.validate(request_xml).should == []
35
+ expect(xsd.validate(request_xml)).to eq([])
36
36
  end
37
37
  end
38
38
  end
@@ -42,18 +42,22 @@ describe CompaniesHouseGateway::Request do
42
42
 
43
43
  it "makes a get request" do
44
44
  perform_check
45
- a_request(:post, config[:api_endpoint]).should have_been_made
45
+ expect(a_request(:post, config[:api_endpoint])).to have_been_made
46
46
  end
47
47
 
48
48
  context "when the config[:raw] is true" do
49
49
  before { config[:raw] = true }
50
- it { should be_a Faraday::Response }
51
- its(:body) { should be_a String }
50
+ it { is_expected.to be_a Faraday::Response }
51
+
52
+ describe '#body' do
53
+ subject { super().body }
54
+ it { should be_a String }
55
+ end
52
56
  end
53
57
 
54
58
  context "when the config[:raw] is false" do
55
- it { should be_a Hash }
56
- it { should include "GovTalkMessage" }
59
+ it { is_expected.to be_a Hash }
60
+ it { is_expected.to include "GovTalkMessage" }
57
61
 
58
62
  context "errors" do
59
63
  context "500" do
@@ -80,8 +84,8 @@ describe CompaniesHouseGateway::Request do
80
84
  it "wraps the error" do
81
85
  expect { perform_check }.
82
86
  to raise_error CompaniesHouseGateway::APIError do |error|
83
- error.error_code.should == "604"
84
- error.message.should == "Error text"
87
+ expect(error.error_code).to eq("604")
88
+ expect(error.message).to eq("Error text")
85
89
  end
86
90
  end
87
91
  end
@@ -35,7 +35,7 @@ shared_examples 'it generates valid xml' do
35
35
  let(:xsd) { Nokogiri::XML::Schema.from_document(xsd_doc) }
36
36
 
37
37
  it "generates a valid XML request" do
38
- xsd.validate(request_xml).should == []
38
+ expect(xsd.validate(request_xml)).to eq([])
39
39
  end
40
40
  end
41
41
 
@@ -51,7 +51,7 @@ shared_examples 'it returns only the body of the response' do
51
51
  before { stub_request(:post, config[:api_endpoint]).to_return(response) }
52
52
  subject { described_class.new(client).perform(check_data) }
53
53
 
54
- it { should be_a Hash }
55
- it { should_not be_empty }
56
- it { should_not include klass }
54
+ it { is_expected.to be_a Hash }
55
+ it { is_expected.not_to be_empty }
56
+ it { is_expected.not_to include klass }
57
57
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,12 @@
1
1
  require 'companies_house_gateway'
2
2
  require 'webmock/rspec'
3
3
  require 'shared_examples'
4
- RSpec.configure { |config| config.include WebMock::API }
4
+
5
+ RSpec.configure do |config|
6
+ config.mock_with(:rspec) { |mocks| mocks.verify_partial_doubles = true }
7
+ config.raise_errors_for_deprecations!
8
+ config.include WebMock::API
9
+ end
5
10
 
6
11
  def configure_companies_house_gateway
7
12
  CompaniesHouseGateway.configure { |config| config[:sender_id] = "Grey" }
@@ -6,12 +6,12 @@ describe CompaniesHouseGateway::Validations do
6
6
 
7
7
  context "without a string" do
8
8
  let(:string) { nil }
9
- it { should == nil }
9
+ it { is_expected.to eq(nil) }
10
10
  end
11
11
 
12
12
  context "with a short string" do
13
13
  let(:string) { "A" * 160 }
14
- it { should == string }
14
+ it { is_expected.to eq(string) }
15
15
  end
16
16
 
17
17
  context "with a long string" do
@@ -28,17 +28,17 @@ describe CompaniesHouseGateway::Validations do
28
28
 
29
29
  context "without a date" do
30
30
  let(:date) { nil }
31
- it { should == nil }
31
+ it { is_expected.to eq(nil) }
32
32
  end
33
33
 
34
34
  context "with a date object" do
35
35
  let(:date) { Date.parse("01/01/2000") }
36
- it { should == date.strftime("%d/%m/%Y") }
36
+ it { is_expected.to eq(date.strftime("%d/%m/%Y")) }
37
37
  end
38
38
 
39
39
  context "with a parseable string" do
40
40
  let(:date) { "01-01-2000" }
41
- it { should == "01/01/2000" }
41
+ it { is_expected.to eq("01/01/2000") }
42
42
  end
43
43
 
44
44
  context "with a load of rubbish" do
@@ -55,12 +55,12 @@ describe CompaniesHouseGateway::Validations do
55
55
 
56
56
  context "without a boolean" do
57
57
  let(:bool) { nil }
58
- it { should == nil }
58
+ it { is_expected.to eq(nil) }
59
59
  end
60
60
 
61
61
  context "with a boolean" do
62
62
  let(:bool) { true }
63
- it { should == bool }
63
+ it { is_expected.to eq(bool) }
64
64
  end
65
65
 
66
66
  context "with a load of rubbish" do
@@ -77,17 +77,17 @@ describe CompaniesHouseGateway::Validations do
77
77
 
78
78
  context "without a number" do
79
79
  let(:number) { nil }
80
- it { should == nil }
80
+ it { is_expected.to eq(nil) }
81
81
  end
82
82
 
83
83
  context "with a number" do
84
84
  let(:number) { 9 }
85
- it { should == number.to_s }
85
+ it { is_expected.to eq(number.to_s) }
86
86
  end
87
87
 
88
88
  context "with a string that looks like a number" do
89
89
  let(:number) { "91" }
90
- it { should == number }
90
+ it { is_expected.to eq(number) }
91
91
  end
92
92
 
93
93
  context "with a load of rubbish" do
@@ -104,17 +104,17 @@ describe CompaniesHouseGateway::Validations do
104
104
 
105
105
  context "without a data_set" do
106
106
  let(:data_set) { nil }
107
- it { should == nil }
107
+ it { is_expected.to eq(nil) }
108
108
  end
109
109
 
110
110
  context "with a valid symbol" do
111
111
  let(:data_set) { :live }
112
- it { should == "LIVE" }
112
+ it { is_expected.to eq("LIVE") }
113
113
  end
114
114
 
115
115
  context "with a valid string" do
116
116
  let(:data_set) { "LIVE" }
117
- it { should == "LIVE" }
117
+ it { is_expected.to eq("LIVE") }
118
118
  end
119
119
 
120
120
  context "with a load of rubbish" do
@@ -133,17 +133,17 @@ describe CompaniesHouseGateway::Validations do
133
133
 
134
134
  context "without an officer_type" do
135
135
  let(:officer_type) { nil }
136
- it { should == nil }
136
+ it { is_expected.to eq(nil) }
137
137
  end
138
138
 
139
139
  context "with a valid symbol" do
140
140
  let(:officer_type) { :dis }
141
- it { should == "DIS" }
141
+ it { is_expected.to eq("DIS") }
142
142
  end
143
143
 
144
144
  context "with a valid string" do
145
145
  let(:officer_type) { "DIS" }
146
- it { should == "DIS" }
146
+ it { is_expected.to eq("DIS") }
147
147
  end
148
148
 
149
149
  context "with a load of rubbish" do
@@ -196,28 +196,33 @@ describe CompaniesHouseGateway::Validations do
196
196
  context "allows a company number starting with #{prefix}" do
197
197
  prefix = (prefix == '\d\d') ? '07' : prefix
198
198
  let(:number) { "#{prefix}112233" }
199
- it { should == "#{prefix}112233" }
199
+ it { is_expected.to eq("#{prefix}112233") }
200
200
  end
201
201
  end
202
202
 
203
203
  context "does not 0-pads 8 digit registration numbers" do
204
204
  let(:number) { "17495895" }
205
- it { should == "17495895" }
205
+ it { is_expected.to eq("17495895") }
206
206
  end
207
207
 
208
208
  context "0-pads 7 digit registration numbers" do
209
209
  let(:number) { "7495895" }
210
- it { should == "07495895" }
210
+ it { is_expected.to eq("07495895") }
211
211
  end
212
212
 
213
213
  context "0-pads 5 digit NI registration numbers" do
214
214
  let(:number) { "NI27768" }
215
- it { should == "NI027768" }
215
+ it { is_expected.to eq("NI027768") }
216
216
  end
217
217
 
218
- context "does not 0-pads 6 digit NI registration numbers" do
218
+ context "does not 0-pad 6 digit NI registration numbers" do
219
219
  let(:number) { "NI127768" }
220
- it { should == "NI127768" }
220
+ it { is_expected.to eq("NI127768") }
221
+ end
222
+
223
+ context "upcases prefixes" do
224
+ let(:number) { "sc127768" }
225
+ it { is_expected.to eq("SC127768") }
221
226
  end
222
227
  end
223
228
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: companies-house-gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.11
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-06-03 00:00:00.000000000 Z
11
+ date: 2015-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday_middleware
@@ -64,28 +64,28 @@ dependencies:
64
64
  requirements:
65
65
  - - ~>
66
66
  - !ruby/object:Gem::Version
67
- version: 2.14.1
67
+ version: '3.0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ~>
73
73
  - !ruby/object:Gem::Version
74
- version: 2.14.1
74
+ version: '3.0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: webmock
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ~>
80
80
  - !ruby/object:Gem::Version
81
- version: 1.17.2
81
+ version: '1.21'
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: 1.17.2
88
+ version: '1.21'
89
89
  description: Ruby wrapper for the Companies House XML Gateway
90
90
  email:
91
91
  - grey@gocardless.com