whos_got_dirt 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/.travis.yml +20 -0
- data/.yardopts +3 -0
- data/Gemfile +7 -0
- data/LICENSE +20 -0
- data/README.md +61 -0
- data/Rakefile +69 -0
- data/lib/whos_got_dirt/renderer.rb +66 -0
- data/lib/whos_got_dirt/request.rb +218 -0
- data/lib/whos_got_dirt/requests/entity/corp_watch.rb +123 -0
- data/lib/whos_got_dirt/requests/entity/little_sis.rb +52 -0
- data/lib/whos_got_dirt/requests/entity/open_corporates.rb +104 -0
- data/lib/whos_got_dirt/requests/entity/open_duka.rb +33 -0
- data/lib/whos_got_dirt/requests/entity/poderopedia.rb +48 -0
- data/lib/whos_got_dirt/requests/entity.rb +54 -0
- data/lib/whos_got_dirt/requests/list/little_sis.rb +37 -0
- data/lib/whos_got_dirt/requests/list/open_corporates.rb +36 -0
- data/lib/whos_got_dirt/requests/list.rb +16 -0
- data/lib/whos_got_dirt/requests/relation/open_corporates.rb +72 -0
- data/lib/whos_got_dirt/requests/relation/open_oil.rb +49 -0
- data/lib/whos_got_dirt/requests/relation.rb +51 -0
- data/lib/whos_got_dirt/response.rb +79 -0
- data/lib/whos_got_dirt/responses/entity/corp_watch.rb +72 -0
- data/lib/whos_got_dirt/responses/entity/little_sis.rb +66 -0
- data/lib/whos_got_dirt/responses/entity/open_corporates.rb +61 -0
- data/lib/whos_got_dirt/responses/entity/open_duka.rb +42 -0
- data/lib/whos_got_dirt/responses/entity/poderopedia.rb +44 -0
- data/lib/whos_got_dirt/responses/entity.rb +7 -0
- data/lib/whos_got_dirt/responses/helpers/little_sis.rb +34 -0
- data/lib/whos_got_dirt/responses/helpers/open_corporates.rb +28 -0
- data/lib/whos_got_dirt/responses/list/little_sis.rb +42 -0
- data/lib/whos_got_dirt/responses/list/open_corporates.rb +34 -0
- data/lib/whos_got_dirt/responses/list.rb +7 -0
- data/lib/whos_got_dirt/responses/relation/open_corporates.rb +66 -0
- data/lib/whos_got_dirt/responses/relation/open_oil.rb +70 -0
- data/lib/whos_got_dirt/responses/relation.rb +7 -0
- data/lib/whos_got_dirt/result.rb +106 -0
- data/lib/whos_got_dirt/validator.rb +52 -0
- data/lib/whos_got_dirt/version.rb +3 -0
- data/lib/whos_got_dirt.rb +43 -0
- data/schemas/popolo.json +1619 -0
- data/spec/cassettes/corp_watch_entity.yml +35 -0
- data/spec/cassettes/little_sis_entity.yml +98 -0
- data/spec/cassettes/little_sis_list.yml +159 -0
- data/spec/cassettes/open_corporates_entity.yml +137 -0
- data/spec/cassettes/open_corporates_list.yml +60 -0
- data/spec/cassettes/open_corporates_relation.yml +121 -0
- data/spec/cassettes/open_duka_entity.yml +1149 -0
- data/spec/cassettes/open_oil_relation.yml +640 -0
- data/spec/cassettes/poderopedia_entity.yml +43 -0
- data/spec/renderer_spec.rb +48 -0
- data/spec/request_spec.rb +205 -0
- data/spec/requests/entity/corp_watch_spec.rb +99 -0
- data/spec/requests/entity/little_sis_spec.rb +33 -0
- data/spec/requests/entity/open_corporates_spec.rb +81 -0
- data/spec/requests/entity/open_duka_spec.rb +21 -0
- data/spec/requests/entity/poderopedia_spec.rb +21 -0
- data/spec/requests/list/little_sis_spec.rb +25 -0
- data/spec/requests/list/open_corporates_spec.rb +33 -0
- data/spec/requests/relation/open_corporates_spec.rb +53 -0
- data/spec/requests/relation/open_oil_spec.rb +37 -0
- data/spec/response_spec.rb +119 -0
- data/spec/responses/entity/corp_watch_spec.rb +31 -0
- data/spec/responses/entity/little_sis_spec.rb +31 -0
- data/spec/responses/entity/open_corporates_spec.rb +31 -0
- data/spec/responses/entity/open_duka_spec.rb +25 -0
- data/spec/responses/entity/poderopedia_spec.rb +25 -0
- data/spec/responses/list/little_sis_spec.rb +31 -0
- data/spec/responses/list/open_corporates_spec.rb +31 -0
- data/spec/responses/relation/open_corporates_spec.rb +31 -0
- data/spec/responses/relation/open_oil_spec.rb +31 -0
- data/spec/result_spec.rb +90 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/shared_examples_for_requests.rb +155 -0
- data/spec/validator_spec.rb +43 -0
- data/whos_got_dirt.gemspec +28 -0
- metadata +281 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://api.poderopedia.org/visualizacion/search?alias=juan&entity=persona&user_key=dd88190daab4754b60b77c5db71b4e96
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message:
|
16
|
+
headers:
|
17
|
+
date:
|
18
|
+
- Mon, 19 Oct 2015 19:48:08 GMT
|
19
|
+
server:
|
20
|
+
- Apache/2.2.15 (CentOS)
|
21
|
+
x-powered-by:
|
22
|
+
- web2py
|
23
|
+
expires:
|
24
|
+
- Mon, 19 Oct 2015 19:48:09 GMT
|
25
|
+
pragma:
|
26
|
+
- no-cache
|
27
|
+
cache-control:
|
28
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
29
|
+
set-cookie:
|
30
|
+
- session_id_api=198.48.204.118-b57a83b1-b473-40bd-a0eb-87db8846f187; Path=/
|
31
|
+
content-length:
|
32
|
+
- '3249'
|
33
|
+
connection:
|
34
|
+
- close
|
35
|
+
content-type:
|
36
|
+
- text/html; charset=utf-8
|
37
|
+
body:
|
38
|
+
encoding: UTF-8
|
39
|
+
string: |
|
40
|
+
{"person": [{"shortBio": "Abogado. Actual senador de la Uni\u00f3n Dem\u00f3crata Independiente (UDI) por la Circunscripci\u00f3n X, VII Regi\u00f3n del Maule desde 2002 por dos periodos consecutivos. \r\nAntes hab\u00eda sido diputado por el Distrito N\u00b0 31 (Alhu\u00e9, Curacav\u00ed, El Monte, Isla de Maipo, Mar\u00eda Pinto Melipilla, Pe\u00f1aflor, San Pedro y Talagante) durante tres periodos legislativos desde desde 1990 a 2002. En el a\u00f1o 2008 fue elegido presidente de su partido. Hermano de Fernando Coloma, superintendente de Valores y Seguros durante el Gobierno de Sebasti\u00e1n Pi\u00f1era, y de Pablo Coloma, militante PPD que lider\u00f3 el Fosis bajo la presidencia de Michelle Bachelet. Su hijo Juan Antonio Coloma \u00c1lamos fue jefe territorial del ex ministro de Obras P\u00fablicas, Laurence Golborne, despu\u00e9s ejerci\u00f3 el mismo cargo en el comando del ex candidato presidencial de la UDI, Pablo Longueira y actualmente es diputado por el distrito 31. El senador Coloma est\u00e1 casado con Mar\u00eda Cecilia \u00c1lamos, hermana de Jimena \u00c1lamos, esposa del diputado UDI Ernesto Silva.", "id": 2657, "alias": "Juan Antonio Coloma"}, {"shortBio": "Senador del Partido Socialista por la 9\u00aa Circunscripci\u00f3n, Regi\u00f3n de O`Higgins,\r\ndesde 2006 a la fecha por dos periodos consecutivos. Diputado por el Distrito N\u00ba 33, Regi\u00f3n de O'Higgins, por cuatro periodo consecutivos, entre 1990 y 2006. Es hijo del ex canciller y\r\nex embajador chileno en Washington DC, Orlando Letelier del Solar, quien fue asesinado por agentes de la Direcci\u00f3n de Inteligencia Nacional (DINA), el 21 de septiembre de 1976 en Washington DC, Estados Unidos.\r\n\r\n", "id": 2671, "alias": "Juan Pablo Letelier"}, {"shortBio": "Abogado. Hijo del senador y ex presidente de la UDI, Juan Antonio Coloma. Es diputado por el Distrito N\u00ba 31, Regi\u00f3n Metropolitana (Alhue, Curacav\u00ed, El Monte, Isla De Maipo, Mar\u00eda Pinto, Melipilla, Padre Hurtado, Pe\u00f1aflor, San Pedro, Talagante), por el per\u00edodo 2014-2018. Participa en las comisiones permanentes de Constituci\u00f3n, Legislaci\u00f3n y Justicia y Derechos Humanos y Pueblos Originarios. Trabaj\u00f3 de forma determinante en el rescate de los 33 mineros atrapados en una mina de Copiap\u00f3, cuando era el hombre de confianza del ex presidenciable Laurence Golborne, llegando a ser su jefe de campa\u00f1a. Dentro de su curr\u00edculo pol\u00edtico, resalta el haber sido por 3 a\u00f1os consecutivos vicepresidente de las Juventud UDI. Adem\u00e1s de ser en el a\u00f1o 2012, la primera mayor\u00eda de la Comisi\u00f3n Pol\u00edtica del gremialismo.", "id": 2713, "alias": "Juan Antonio Coloma \u00c1lamos"}, {"shortBio": null, "id": 2768, "alias": "Juan de Dios Larra\u00edn Matte"}, {"shortBio": null, "id": 2785, "alias": "Juan Andr\u00e9s Prokurica de Las Heras"}, {"shortBio": null, "id": 2796, "alias": "Juan Tuma Masso"}, {"shortBio": null, "id": 2835, "alias": "Juana Guerrero Y\u00e1\u00f1ez"}, {"shortBio": null, "id": 2839, "alias": "Juan Arenas"}, {"shortBio": null, "id": 2889, "alias": "Juan Francisco Calder\u00f3n Quezada"}, {"shortBio": null, "id": 2898, "alias": "Juan Crist\u00f3bal Cardemil Palacios"}]}
|
41
|
+
http_version:
|
42
|
+
recorded_at: Mon, 19 Oct 2015 19:48:08 GMT
|
43
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
module WhosGotDirt
|
4
|
+
RSpec.describe Renderer do
|
5
|
+
describe '#initialize' do
|
6
|
+
it 'should set the template' do
|
7
|
+
expect(Renderer.new('name' => 'John Smith').template).to eq('name' => 'John Smith')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#result' do
|
12
|
+
it 'should render a result' do
|
13
|
+
expect(Renderer.new({
|
14
|
+
'id' => 123,
|
15
|
+
'name' => '/fn',
|
16
|
+
'identifiers' => [{
|
17
|
+
'identifier' => '/id',
|
18
|
+
'scheme' => 'ACME',
|
19
|
+
}],
|
20
|
+
'delete' => '/blank',
|
21
|
+
}).result({
|
22
|
+
'id' => 456,
|
23
|
+
'fn' => 'John Smith',
|
24
|
+
'blank' => nil,
|
25
|
+
})).to eq({
|
26
|
+
'id' => 123,
|
27
|
+
'name' => 'John Smith',
|
28
|
+
'identifiers' => [{
|
29
|
+
'identifier' => 456,
|
30
|
+
'scheme' => 'ACME',
|
31
|
+
}],
|
32
|
+
})
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should render a result using lambdas' do
|
36
|
+
expect(Renderer.new({
|
37
|
+
'lambda' => lambda{|data|
|
38
|
+
['key', 'value']
|
39
|
+
},
|
40
|
+
}).result({
|
41
|
+
'lambda' => 123,
|
42
|
+
})).to eq({
|
43
|
+
'key' => 'value',
|
44
|
+
})
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
module WhosGotDirt
|
4
|
+
RSpec.describe Request do
|
5
|
+
let :klass do
|
6
|
+
Class.new(Request) do
|
7
|
+
@base_url = 'https://api.example.com/endpoint'
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
"#{base_url}?#{to_query(input)}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def and_operator
|
14
|
+
','
|
15
|
+
end
|
16
|
+
|
17
|
+
def or_operator
|
18
|
+
'|'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
let :instance do
|
24
|
+
klass.new(q: 'foo', bar: false, baz: nil)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '.to_query' do
|
28
|
+
it 'should return a query string' do
|
29
|
+
expect(klass.to_query(foo: '/', bar: false, baz: nil)).to eq('foo=%2F&bar=false&baz=')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#initialize' do
|
34
|
+
it 'should set the query and parameters' do
|
35
|
+
expect(instance.input).to eq('q' => 'foo', 'bar' => false, 'baz' => nil)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should accept no arguments' do
|
39
|
+
expect{klass.new}.to_not raise_error
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '.base_url' do
|
44
|
+
it 'should return the base URL' do
|
45
|
+
expect(klass.base_url).to eq('https://api.example.com/endpoint')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#base_url' do
|
50
|
+
it 'should return the base URL' do
|
51
|
+
expect(instance.base_url).to eq('https://api.example.com/endpoint')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#equal' do
|
56
|
+
it 'should return a criterion' do
|
57
|
+
expect(klass.new('source' => 'John Smith').equal('target', 'source')).to eq('target' => 'John Smith')
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should return a criterion when input is overridden' do
|
61
|
+
expect(klass.new(nil).equal('target', 'source', input: {'source' => 'John Smith'})).to eq('target' => 'John Smith')
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should return a criterion when value is transformed' do
|
65
|
+
expect(klass.new('source' => 'John Smith').equal('target', 'source', transform: lambda{|v| v.upcase})).to eq('target' => 'JOHN SMITH')
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should accept valid values' do
|
69
|
+
expect(klass.new('source' => true).equal('target', 'source', valid: [true, false])).to eq('target' => true)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should ignore invalid values' do
|
73
|
+
expect(klass.new('source' => 'John Smith').equal('target', 'source', valid: [true, false])).to eq({})
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#match' do
|
78
|
+
let :fuzzy do
|
79
|
+
{'source~=' => 'Smith John'}
|
80
|
+
end
|
81
|
+
|
82
|
+
let :exact do
|
83
|
+
fuzzy.merge('source' => 'John Smith')
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should return a criterion' do
|
87
|
+
expect(klass.new(fuzzy).match('target', 'source')).to eq('target' => 'Smith John')
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should return a criterion when input is overridden' do
|
91
|
+
expect(klass.new(nil).match('target', 'source', input: fuzzy)).to eq('target' => 'Smith John')
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should return a criterion when value is transformed' do
|
95
|
+
expect(klass.new(fuzzy).match('target', 'source', transform: lambda{|v| v.upcase})).to eq('target' => 'SMITH JOHN')
|
96
|
+
expect(klass.new(exact).match('target', 'source', transform: lambda{|v| v.upcase})).to eq('target' => 'JOHN SMITH')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should prioritize exact match' do
|
100
|
+
expect(klass.new(exact).match('target', 'source')).to eq('target' => 'John Smith')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '#one_of' do
|
105
|
+
let :many do
|
106
|
+
{'source|=' => ['one', 'two']}
|
107
|
+
end
|
108
|
+
|
109
|
+
let :one do
|
110
|
+
many.merge('source' => 'three')
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should return a criterion' do
|
114
|
+
expect(klass.new(many).one_of('target', 'source')).to eq('target' => 'one|two')
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should return a criterion when input is overridden' do
|
118
|
+
expect(klass.new(nil).one_of('target', 'source', input: many)).to eq('target' => 'one|two')
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should return a criterion when values are transformed' do
|
122
|
+
expect(klass.new(many).one_of('target', 'source', transform: lambda{|v| v.upcase})).to eq('target' => 'ONE|TWO')
|
123
|
+
expect(klass.new(one).one_of('target', 'source', transform: lambda{|v| v.upcase})).to eq('target' => 'THREE')
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should prioritize exact match' do
|
127
|
+
expect(klass.new(one).one_of('target', 'source')).to eq('target' => 'three')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#all_of' do
|
132
|
+
let :many do
|
133
|
+
{
|
134
|
+
'a:source' => 'one',
|
135
|
+
'b:source' => 'two',
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
let :one do
|
140
|
+
many.merge('source' => 'three')
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should return a criterion' do
|
144
|
+
expect(klass.new(many).all_of('target', 'source')).to eq('target' => 'one,two')
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'should return a criterion when input is overridden' do
|
148
|
+
expect(klass.new(nil).all_of('target', 'source', input: many)).to eq('target' => 'one,two')
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should return a criterion when values are transformed' do
|
152
|
+
expect(klass.new(many).all_of('target', 'source', transform: lambda{|v| v.upcase})).to eq('target' => 'ONE,TWO')
|
153
|
+
expect(klass.new(one).all_of('target', 'source', transform: lambda{|v| v.upcase})).to eq('target' => 'THREE')
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should prioritize exact match' do
|
157
|
+
expect(klass.new(one).all_of('target', 'source')).to eq('target' => 'three')
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe '#date_range' do
|
162
|
+
let :strict do
|
163
|
+
{
|
164
|
+
'source>' => '2010-01-02',
|
165
|
+
'source<' => '2010-01-05',
|
166
|
+
}
|
167
|
+
end
|
168
|
+
|
169
|
+
let :nonstrict do
|
170
|
+
strict.merge({
|
171
|
+
'source>=' => '2010-01-03',
|
172
|
+
'source<=' => '2010-01-04',
|
173
|
+
})
|
174
|
+
end
|
175
|
+
|
176
|
+
let :exact do
|
177
|
+
nonstrict.merge({
|
178
|
+
'source' => '2010-01-01',
|
179
|
+
})
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should return a criterion' do
|
183
|
+
expect(klass.new(strict).date_range('target', 'source')).to eq('target' => '2010-01-02:2010-01-05')
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'should return a criterion when input is overridden' do
|
187
|
+
expect(klass.new(nil).date_range('target', 'source', input: strict)).to eq('target' => '2010-01-02:2010-01-05')
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should prioritize or-equal dates' do
|
191
|
+
expect(klass.new(nonstrict).date_range('target', 'source')).to eq('target' => '2010-01-03:2010-01-04')
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'should prioritize exact date' do
|
195
|
+
expect(klass.new(exact).date_range('target', 'source')).to eq('target' => '2010-01-01:2010-01-01')
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '#to_s' do
|
200
|
+
it 'should return the query as a string' do
|
201
|
+
expect(instance.to_s).to eq('https://api.example.com/endpoint?q=foo&bar=false&baz=')
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
module WhosGotDirt::Requests::Entity
|
4
|
+
RSpec.describe CorpWatch do
|
5
|
+
describe '#to_s' do
|
6
|
+
it 'should return the URL to request' do
|
7
|
+
expect(CorpWatch.new(name: 'ACME Inc.').to_s).to eq('http://api.corpwatch.org/companies.json?company_name=ACME+Inc.')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#convert' do
|
12
|
+
context 'when given a name' do
|
13
|
+
include_examples 'match', 'company_name', 'name', ['ACME Inc.', 'Inc. ACME']
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when given a limit' do
|
17
|
+
include_examples 'equal', 'limit', 'limit', 5
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when given an IRS identifier' do
|
21
|
+
it 'should return a criterion' do
|
22
|
+
expect(CorpWatch.new({
|
23
|
+
'identifiers' => [{
|
24
|
+
'identifier' => '911653725',
|
25
|
+
'scheme' => 'IRS Employer Identification Number',
|
26
|
+
}],
|
27
|
+
}).convert).to eq('irs_number' => '911653725')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when given an SEC identifier' do
|
32
|
+
it 'should return a criterion' do
|
33
|
+
expect(CorpWatch.new({
|
34
|
+
'identifiers' => [{
|
35
|
+
'identifier' => '37996',
|
36
|
+
'scheme' => 'SEC Central Index Key',
|
37
|
+
}],
|
38
|
+
}).convert).to eq('cik' => '37996')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when given a contact detail' do
|
43
|
+
include_examples 'contact_details', 'raw_address', 'address', ['52 London', 'London 52']
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when given an API key' do
|
47
|
+
include_examples 'equal', 'key', 'corp_watch_api_key', 123
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when given an industry code' do
|
51
|
+
include_examples 'equal', 'sic_code', 'industry_code', '2011'
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when given a sector code' do
|
55
|
+
include_examples 'equal', 'sic_sector', 'sector_code', '4100'
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when given a "substring_match all" flag' do
|
59
|
+
include_examples 'equal', 'substring_match', 'substring_match', 1, valid: [1]
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when given a country code' do
|
63
|
+
include_examples 'equal', 'country_code', 'country_code', 'us', transformed: 'US'
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when given a country subdivision code' do
|
67
|
+
include_examples 'equal', 'subdiv_code', 'subdiv_code', 'or', transformed: 'OR'
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'when given a year' do
|
71
|
+
include_examples 'equal', 'year', 'year', '2005'
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when given a minimum year' do
|
75
|
+
include_examples 'equal', 'min_year', 'year>=', '2003'
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when given a maximum year' do
|
79
|
+
include_examples 'equal', 'max_year', 'year<=', '2007'
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when given a source type' do
|
83
|
+
include_examples 'equal', 'source_type', 'source_type', 'filers'
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when given a number of children' do
|
87
|
+
include_examples 'equal', 'num_children', 'num_children', 3
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'when given a number of parents' do
|
91
|
+
include_examples 'equal', 'num_parents', 'num_parents', 2
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'when given a root company identifier' do
|
95
|
+
include_examples 'equal', 'top_parent_id', 'top_parent_id', 'cw_7324'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
module WhosGotDirt::Requests::Entity
|
4
|
+
RSpec.describe LittleSis do
|
5
|
+
describe '#to_s' do
|
6
|
+
it 'should return the URL to request' do
|
7
|
+
expect(LittleSis.new(name: 'ACME Inc.').to_s).to eq('https://api.littlesis.org/entities.xml?q=ACME+Inc.')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#convert' do
|
12
|
+
context 'when given a name' do
|
13
|
+
include_examples 'match', 'q', 'name', ['ACME Inc.', 'Inc. ACME']
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when given a classification' do
|
17
|
+
include_examples 'one_of', 'type_ids', 'classification', [1, 2], ','
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when given a limit' do
|
21
|
+
include_examples 'equal', 'num', 'limit', 5
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when given an API key' do
|
25
|
+
include_examples 'equal', '_key', 'little_sis_api_key', 123
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when given a "search all" flag' do
|
29
|
+
include_examples 'equal', 'search_all', 'search_all', 1, valid: [1]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
module WhosGotDirt::Requests::Entity
|
4
|
+
RSpec.describe OpenCorporates do
|
5
|
+
describe '#to_s' do
|
6
|
+
it 'should return the URL to request' do
|
7
|
+
expect(OpenCorporates.new(name: 'ACME Inc.').to_s).to eq('https://api.opencorporates.com/companies/search?q=ACME+Inc.&order=score')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#convert' do
|
12
|
+
context 'when given a name' do
|
13
|
+
include_examples 'match', 'q', 'name', ['ACME Inc.', 'Inc. ACME']
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when given a classification' do
|
17
|
+
include_examples 'equal', 'company_type', 'classification', 'Private Limited Company'
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when given a creation timestamp' do
|
21
|
+
include_examples 'equal', 'created_since', 'created_at>=', '2010-01-01'
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when given a founding date' do
|
25
|
+
include_examples 'date_range', 'incorporation_date', 'founding_date'
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when given a founding date' do
|
29
|
+
include_examples 'date_range', 'dissolution_date', 'dissolution_date'
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when given a contact detail' do
|
33
|
+
include_examples 'contact_details', 'registered_address', 'address', ['52 London', 'London 52']
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when given a limit' do
|
37
|
+
it 'should return a per-page limit' do
|
38
|
+
expect(OpenCorporates.new('limit' => 5).convert).to eq('per_page' => 5)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should override the default authenticated per-page limit' do
|
42
|
+
expect(OpenCorporates.new('limit' => 5, 'open_corporates_api_key' => 123).convert).to eq('per_page' => 5, 'api_token' => 123)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when given an API key' do
|
47
|
+
it 'should return an API key parameter' do
|
48
|
+
expect(OpenCorporates.new('open_corporates_api_key' => 123).convert).to eq('api_token' => 123, 'per_page' => 100)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when given a jurisdiction' do
|
53
|
+
include_examples 'one_of', 'jurisdiction_code', 'jurisdiction_code', ['GB', 'IE'], '|', transformed: ['gb', 'ie']
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when given a country' do
|
57
|
+
include_examples 'one_of', 'country_code', 'country_code', ['GB', 'IE'], '|', transformed: ['gb', 'ie']
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when given a status' do
|
61
|
+
include_examples 'equal', 'current_status', 'current_status', 'Dissolved'
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when given an industry' do
|
65
|
+
include_examples 'one_of', 'industry_codes', 'industry_code', ['be_nace_2008-66191', 'be_nace_2008-66199'], '|'
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when given an inactivity status' do
|
69
|
+
include_examples 'equal', 'inactive', 'inactive', true, valid: [true, false]
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when given a branch status' do
|
73
|
+
include_examples 'equal', 'branch', 'branch', true, valid: [true, false]
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when given a nonprofit status' do
|
77
|
+
include_examples 'equal', 'nonprofit', 'nonprofit', true, valid: [true, false]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
module WhosGotDirt::Requests::Entity
|
4
|
+
RSpec.describe OpenDuka do
|
5
|
+
describe '#to_s' do
|
6
|
+
it 'should return the URL to request' do
|
7
|
+
expect(OpenDuka.new(name: 'ACME Inc.').to_s).to eq('http://www.openduka.org/index.php/api/search?term=ACME+Inc.')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#convert' do
|
12
|
+
context 'when given a name' do
|
13
|
+
include_examples 'match', 'term', 'name', ['ACME Inc.', 'Inc. ACME']
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when given an API key' do
|
17
|
+
include_examples 'equal', 'key', 'open_duka_api_key', 123
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
module WhosGotDirt::Requests::Entity
|
4
|
+
RSpec.describe Poderopedia do
|
5
|
+
describe '#to_s' do
|
6
|
+
it 'should return the URL to request' do
|
7
|
+
expect(Poderopedia.new(name: 'ACME Inc.').to_s).to eq('http://api.poderopedia.org/visualizacion/search?alias=ACME+Inc.')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#convert' do
|
12
|
+
context 'when given a name' do
|
13
|
+
include_examples 'match', 'alias', 'name', ['ACME Inc.', 'Inc. ACME']
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when given an API key' do
|
17
|
+
include_examples 'equal', 'user_key', 'poderopedia_api_key', 123
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
module WhosGotDirt::Requests::List
|
4
|
+
RSpec.describe LittleSis do
|
5
|
+
describe '#to_s' do
|
6
|
+
it 'should return the URL to request' do
|
7
|
+
expect(LittleSis.new(name: 'forbes').to_s).to eq('https://api.littlesis.org/lists.xml?q=forbes')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#convert' do
|
12
|
+
context 'when given a name' do
|
13
|
+
include_examples 'match', 'q', 'name', ['forbes', 'forbe']
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when given a limit' do
|
17
|
+
include_examples 'equal', 'num', 'limit', 5
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when given an API key' do
|
21
|
+
include_examples 'equal', '_key', 'little_sis_api_key', 123
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
module WhosGotDirt::Requests::List
|
4
|
+
RSpec.describe OpenCorporates do
|
5
|
+
describe '#to_s' do
|
6
|
+
it 'should return the URL to request' do
|
7
|
+
expect(OpenCorporates.new(name: 'barclays').to_s).to eq('https://api.opencorporates.com/corporate_groupings/search?q=barclays')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#convert' do
|
12
|
+
context 'when given a name' do
|
13
|
+
include_examples 'match', 'q', 'name', ['barclays', 'bayclay']
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when given a limit' do
|
17
|
+
it 'should return a per-page limit' do
|
18
|
+
expect(OpenCorporates.new('limit' => 5).convert).to eq('per_page' => 5)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should override the default authenticated per-page limit' do
|
22
|
+
expect(OpenCorporates.new('limit' => 5, 'open_corporates_api_key' => 123).convert).to eq('per_page' => 5, 'api_token' => 123)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when given an API key' do
|
27
|
+
it 'should return an API key parameter' do
|
28
|
+
expect(OpenCorporates.new('open_corporates_api_key' => 123).convert).to eq('api_token' => 123, 'per_page' => 100)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
module WhosGotDirt::Requests::Relation
|
4
|
+
RSpec.describe OpenCorporates do
|
5
|
+
describe '#to_s' do
|
6
|
+
it 'should return the URL to request' do
|
7
|
+
expect(OpenCorporates.new(subject: [name: 'John Smith']).to_s).to eq('https://api.opencorporates.com/officers/search?q=John+Smith&order=score')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#convert' do
|
12
|
+
context 'when given a name' do
|
13
|
+
include_examples 'match', 'q', 'name', ['Smith John', 'John Smith'], scope: 'subject'
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when given a birth date' do
|
17
|
+
include_examples 'date_range', 'date_of_birth', 'birth_date', scope: 'subject'
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when given a contact detail' do
|
21
|
+
include_examples 'contact_details', 'address', 'address', ['52 London', 'London 52'], scope: 'subject'
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when given a limit' do
|
25
|
+
it 'should return a per-page limit' do
|
26
|
+
expect(OpenCorporates.new('limit' => 5).convert).to eq('per_page' => 5)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should override the default authenticated per-page limit' do
|
30
|
+
expect(OpenCorporates.new('limit' => 5, 'open_corporates_api_key' => 123).convert).to eq('per_page' => 5, 'api_token' => 123)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when given an API key' do
|
35
|
+
it 'should return an API key parameter' do
|
36
|
+
expect(OpenCorporates.new('open_corporates_api_key' => 123).convert).to eq('api_token' => 123, 'per_page' => 100)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when given a jurisdiction' do
|
41
|
+
include_examples 'one_of', 'jurisdiction_code', 'jurisdiction_code', ['GB', 'IE'], '|', transformed: ['gb', 'ie']
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when given a role' do
|
45
|
+
include_examples 'equal', 'position', 'role', 'ceo'
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when given an inactivity status' do
|
49
|
+
include_examples 'equal', 'inactive', 'inactive', false, valid: [true, false]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|