chrome_data 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +114 -0
- data/Rakefile +8 -0
- data/chrome_data.gemspec +31 -0
- data/lib/chrome_data/base_request.rb +88 -0
- data/lib/chrome_data/caching.rb +31 -0
- data/lib/chrome_data/collection_request.rb +19 -0
- data/lib/chrome_data/division.rb +14 -0
- data/lib/chrome_data/model.rb +13 -0
- data/lib/chrome_data/model_year.rb +16 -0
- data/lib/chrome_data/style.rb +15 -0
- data/lib/chrome_data/vehicle.rb +43 -0
- data/lib/chrome_data/version.rb +3 -0
- data/lib/chrome_data.rb +32 -0
- data/test/chrome_data/caching_test.rb +74 -0
- data/test/chrome_data/division_test.rb +57 -0
- data/test/chrome_data/model_test.rb +57 -0
- data/test/chrome_data/model_year_test.rb +13 -0
- data/test/chrome_data/style_test.rb +49 -0
- data/test/chrome_data/vehicle_test.rb +78 -0
- data/test/chrome_data_test.rb +13 -0
- data/test/fixtures/vcr_cassettes/2013/divisions/13/models/24997/styles.yml +55 -0
- data/test/fixtures/vcr_cassettes/2013/divisions/13/models.yml +70 -0
- data/test/fixtures/vcr_cassettes/2013/divisions.yml +63 -0
- data/test/fixtures/vcr_cassettes/vehicles/WDDGF4HB1CR000000.yml +276 -0
- data/test/fixtures/vcr_cassettes/wsdl.yml +757 -0
- data/test/minitest_helper.rb +13 -0
- metadata +213 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative '../minitest_helper'
|
2
|
+
|
3
|
+
describe ChromeData::ModelYear do
|
4
|
+
describe '.all' do
|
5
|
+
it 'starts with next year' do
|
6
|
+
ChromeData::ModelYear.all.first.must_equal Time.now.year + 1
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'ends with 1981' do
|
10
|
+
ChromeData::ModelYear.all.last.must_equal 1981
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative '../minitest_helper'
|
2
|
+
|
3
|
+
describe ChromeData::Style do
|
4
|
+
it 'returns a proper request name' do
|
5
|
+
ChromeData::Style.request_name.must_equal 'getStyles'
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '.find_all_by_model_id' do
|
9
|
+
before do
|
10
|
+
ChromeData.configure do |c|
|
11
|
+
c.account_number = '123456'
|
12
|
+
c.account_secret = '1111111111111111'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def find_styles
|
17
|
+
VCR.use_cassette('wsdl') do
|
18
|
+
VCR.use_cassette('2013/divisions/13/models/24997/styles') do
|
19
|
+
@models = ChromeData::Style.find_all_by_model_id(24997) # 2013 Ford Mustang
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns array of Style objects' do
|
25
|
+
find_styles
|
26
|
+
|
27
|
+
@models.first.must_be_instance_of ChromeData::Style
|
28
|
+
@models.size.must_equal 11
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'sets ID on Style objects' do
|
32
|
+
find_styles
|
33
|
+
|
34
|
+
@models.first.id.must_equal 349411
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'sets name on Style objects' do
|
38
|
+
find_styles
|
39
|
+
|
40
|
+
@models.first.name.must_equal '2dr Conv GT'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'caches with proper key' do
|
44
|
+
ChromeData.expects(:cache).with('get_styles-model_id-24997')
|
45
|
+
|
46
|
+
find_styles
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require_relative '../minitest_helper'
|
2
|
+
|
3
|
+
describe ChromeData::Vehicle do
|
4
|
+
it 'returns a proper request name' do
|
5
|
+
ChromeData::Vehicle.request_name.must_equal 'describeVehicle'
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '.find_by_vin' do
|
9
|
+
before do
|
10
|
+
ChromeData.configure do |c|
|
11
|
+
c.account_number = '123456'
|
12
|
+
c.account_secret = '1111111111111111'
|
13
|
+
end
|
14
|
+
|
15
|
+
VCR.use_cassette('wsdl') do
|
16
|
+
VCR.use_cassette('vehicles/WDDGF4HB1CR000000') do
|
17
|
+
@vehicle = ChromeData::Vehicle.find_by_vin('WDDGF4HB1CR000000')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a Vehicle object' do
|
23
|
+
@vehicle.must_be_instance_of ChromeData::Vehicle
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'sets model year on Vehicle' do
|
27
|
+
@vehicle.model_year.must_equal 2012
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'sets division on Vehicle' do
|
31
|
+
@vehicle.division.must_equal 'Mercedes-Benz'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'sets model on Vehicle' do
|
35
|
+
@vehicle.model.must_equal 'C-Class'
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'styles' do
|
39
|
+
it 'sets id' do
|
40
|
+
@vehicle.styles[0].id.must_equal 337364
|
41
|
+
@vehicle.styles[1].id.must_equal 337365
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'sets name' do
|
45
|
+
@vehicle.styles[0].name.must_equal '4dr Sdn C250 Sport RWD'
|
46
|
+
@vehicle.styles[1].name.must_equal '4dr Sdn C250 Luxury RWD'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'sets trim' do
|
50
|
+
@vehicle.styles[0].trim.must_equal 'C250 Sport'
|
51
|
+
@vehicle.styles[1].trim.must_equal 'C250 Luxury'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'sets name_without_trim' do
|
55
|
+
@vehicle.styles[0].name_without_trim.must_equal '4dr Sdn RWD'
|
56
|
+
@vehicle.styles[1].name_without_trim.must_equal '4dr Sdn RWD'
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'body_types' do
|
60
|
+
it 'sets name' do
|
61
|
+
@vehicle.styles[0].body_types[0].name.must_equal '4dr Car'
|
62
|
+
@vehicle.styles[1].body_types[0].name.must_equal '4dr Car'
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'sets id' do
|
66
|
+
@vehicle.styles[0].body_types[0].id.must_equal 2
|
67
|
+
@vehicle.styles[1].body_types[0].id.must_equal 2
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'engines' do
|
73
|
+
it 'sets type' do
|
74
|
+
@vehicle.engines[0].type.must_equal '4 Cylinder Engine'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'minitest_helper'
|
2
|
+
|
3
|
+
describe ChromeData do
|
4
|
+
before { ChromeData.remove_class_variable :@@config if ChromeData.class_variable_defined? :@@config }
|
5
|
+
|
6
|
+
it 'yields configuration object to block' do
|
7
|
+
ChromeData.configure do |config|
|
8
|
+
config.foo = 'bar'
|
9
|
+
end
|
10
|
+
|
11
|
+
ChromeData.config.foo.must_equal 'bar'
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://services.chromedata.com/Description/7a
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ! "<?xml version=\"1.0\"?>\n<soap:Envelope xmlns:dtns=\"urn:description7a.services.chrome.com\"
|
9
|
+
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soap:Header/>\n
|
10
|
+
\ <soap:Body>\n <dtns:StylesRequest modelId=\"24997\">\n <dtns:accountInfo
|
11
|
+
number=\"123456\" secret=\"1111111111111111\" country=\"US\" language=\"en\"/>\n
|
12
|
+
\ </dtns:StylesRequest>\n </soap:Body>\n</soap:Envelope>\n"
|
13
|
+
headers:
|
14
|
+
Content-Type:
|
15
|
+
- text/xml;charset=UTF-8
|
16
|
+
Content-Length:
|
17
|
+
- '369'
|
18
|
+
Soapaction:
|
19
|
+
- ''
|
20
|
+
Accept:
|
21
|
+
- ! '*/*'
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 200
|
27
|
+
message: OK
|
28
|
+
headers:
|
29
|
+
Date:
|
30
|
+
- Wed, 20 Mar 2013 02:06:50 GMT
|
31
|
+
Server:
|
32
|
+
- Apache
|
33
|
+
Content-Length:
|
34
|
+
- '733'
|
35
|
+
P3p:
|
36
|
+
- CP="NOI ADMa CUR DEVa OUR IND TAI BUS UNI"
|
37
|
+
Connection:
|
38
|
+
- close
|
39
|
+
Content-Type:
|
40
|
+
- text/xml;charset=utf-8
|
41
|
+
Chrome:
|
42
|
+
- '198'
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><Styles
|
46
|
+
xmlns="urn:description7a.services.chrome.com"><responseStatus responseCode="Successful"
|
47
|
+
description="Successful"/><style id="349411">2dr Conv GT</style><style id="349412">2dr
|
48
|
+
Conv GT Premium</style><style id="349413">2dr Conv Shelby GT500</style><style
|
49
|
+
id="349409">2dr Conv V6</style><style id="349410">2dr Conv V6 Premium</style><style
|
50
|
+
id="349407">2dr Cpe Boss 302</style><style id="349405">2dr Cpe GT</style><style
|
51
|
+
id="349406">2dr Cpe GT Premium</style><style id="349408">2dr Cpe Shelby GT500</style><style
|
52
|
+
id="349403">2dr Cpe V6</style><style id="349404">2dr Cpe V6 Premium</style></Styles></S:Body></S:Envelope>
|
53
|
+
http_version:
|
54
|
+
recorded_at: Wed, 20 Mar 2013 02:06:51 GMT
|
55
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,70 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://services.chromedata.com/Description/7a
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ! "<?xml version=\"1.0\"?>\n<soap:Envelope xmlns:dtns=\"urn:description7a.services.chrome.com\"
|
9
|
+
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soap:Header/>\n
|
10
|
+
\ <soap:Body>\n <dtns:ModelsRequest>\n <dtns:accountInfo number=\"123456\"
|
11
|
+
secret=\"1111111111111111\" country=\"US\" language=\"en\"/>\n <dtns:modelYear>2013</dtns:modelYear>\n
|
12
|
+
\ <dtns:divisionId>13</dtns:divisionId>\n </dtns:ModelsRequest>\n </soap:Body>\n</soap:Envelope>\n"
|
13
|
+
headers:
|
14
|
+
Content-Type:
|
15
|
+
- text/xml;charset=UTF-8
|
16
|
+
Content-Length:
|
17
|
+
- '441'
|
18
|
+
Soapaction:
|
19
|
+
- ''
|
20
|
+
Accept:
|
21
|
+
- ! '*/*'
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 200
|
27
|
+
message: OK
|
28
|
+
headers:
|
29
|
+
Date:
|
30
|
+
- Wed, 20 Mar 2013 01:43:28 GMT
|
31
|
+
Server:
|
32
|
+
- Apache
|
33
|
+
Content-Length:
|
34
|
+
- '1956'
|
35
|
+
P3p:
|
36
|
+
- CP="NOI ADMa CUR DEVa OUR IND TAI BUS UNI"
|
37
|
+
Connection:
|
38
|
+
- close
|
39
|
+
Content-Type:
|
40
|
+
- text/xml;charset=utf-8
|
41
|
+
Chrome:
|
42
|
+
- '198'
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><Models
|
46
|
+
xmlns="urn:description7a.services.chrome.com"><responseStatus responseCode="Successful"
|
47
|
+
description="Successful"/><model id="25459">C-Max Energi</model><model id="25455">C-Max
|
48
|
+
Hybrid</model><model id="25134">Econoline Cargo Van</model><model id="25567">Econoline
|
49
|
+
Commercial Chassis</model><model id="25568">Econoline Commercial Cutaway</model><model
|
50
|
+
id="25565">Econoline Wagon</model><model id="24937">Edge</model><model id="25055">Escape</model><model
|
51
|
+
id="25572">Expedition</model><model id="25573">Expedition EL</model><model
|
52
|
+
id="24934">Explorer</model><model id="25621">F-150</model><model id="25199">Fiesta</model><model
|
53
|
+
id="24973">Flex</model><model id="25451">Focus</model><model id="25458">Focus
|
54
|
+
Electric</model><model id="25457">Fusion</model><model id="25886">Fusion Energi</model><model
|
55
|
+
id="24997">Mustang</model><model id="21803">Sedan Police Interceptor</model><model
|
56
|
+
id="25801">Super Duty F-250 SRW</model><model id="25777">Super Duty F-350
|
57
|
+
DRW</model><model id="25802">Super Duty F-350 DRW</model><model id="25805">Super
|
58
|
+
Duty F-350 SRW</model><model id="25776">Super Duty F-350 SRW</model><model
|
59
|
+
id="25790">Super Duty F-450 DRW</model><model id="25778">Super Duty F-450
|
60
|
+
DRW</model><model id="25341">Super Duty F-53 Motorhome</model><model id="25779">Super
|
61
|
+
Duty F-550 DRW</model><model id="25342">Super Duty F-59 Stripped Chassis</model><model
|
62
|
+
id="25914">Super Duty F-650 Pro Loader</model><model id="25915">Super Duty
|
63
|
+
F-650 Pro Loader Gas</model><model id="25916">Super Duty F-650 Straight Frame</model><model
|
64
|
+
id="25917">Super Duty F-650 Straight Frame Gas</model><model id="25918">Super
|
65
|
+
Duty F-750 Straight Frame</model><model id="24933">Taurus</model><model id="25135">Transit
|
66
|
+
Connect</model><model id="25345">Transit Connect Wagon</model><model id="21811">Utility
|
67
|
+
Police Interceptor</model></Models></S:Body></S:Envelope>
|
68
|
+
http_version:
|
69
|
+
recorded_at: Wed, 20 Mar 2013 01:43:28 GMT
|
70
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,63 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://services.chromedata.com/Description/7a
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ! "<?xml version=\"1.0\"?>\n<soap:Envelope xmlns:dtns=\"urn:description7a.services.chrome.com\"
|
9
|
+
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soap:Header/>\n
|
10
|
+
\ <soap:Body>\n <dtns:DivisionsRequest modelYear=\"2013\">\n <dtns:accountInfo
|
11
|
+
number=\"123456\" secret=\"1111111111111111\" country=\"US\" language=\"en\"/>\n
|
12
|
+
\ </dtns:DivisionsRequest>\n </soap:Body>\n</soap:Envelope>\n"
|
13
|
+
headers:
|
14
|
+
Content-Type:
|
15
|
+
- text/xml;charset=UTF-8
|
16
|
+
Content-Length:
|
17
|
+
- '376'
|
18
|
+
Soapaction:
|
19
|
+
- ''
|
20
|
+
Accept:
|
21
|
+
- ! '*/*'
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 200
|
27
|
+
message: OK
|
28
|
+
headers:
|
29
|
+
Date:
|
30
|
+
- Tue, 19 Mar 2013 23:50:43 GMT
|
31
|
+
Server:
|
32
|
+
- Apache
|
33
|
+
Content-Length:
|
34
|
+
- '1595'
|
35
|
+
P3p:
|
36
|
+
- CP="NOI ADMa CUR DEVa OUR IND TAI BUS UNI"
|
37
|
+
Connection:
|
38
|
+
- close
|
39
|
+
Content-Type:
|
40
|
+
- text/xml;charset=utf-8
|
41
|
+
Chrome:
|
42
|
+
- '218'
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><Divisions
|
46
|
+
xmlns="urn:description7a.services.chrome.com"><responseStatus responseCode="Successful"
|
47
|
+
description="Successful"/><division id="1">Acura</division><division id="4">Audi</division><division
|
48
|
+
id="45">Bentley</division><division id="5">BMW</division><division id="6">Buick</division><division
|
49
|
+
id="7">Cadillac</division><division id="8">Chevrolet</division><division id="9">Chrysler</division><division
|
50
|
+
id="11">Dodge</division><division id="59">FIAT</division><division id="13">Ford</division><division
|
51
|
+
id="15">GMC</division><division id="16">Honda</division><division id="17">Hyundai</division><division
|
52
|
+
id="18">Infiniti</division><division id="19">Isuzu</division><division id="20">Jaguar</division><division
|
53
|
+
id="21">Jeep</division><division id="22">Kia</division><division id="23">Land
|
54
|
+
Rover</division><division id="24">Lexus</division><division id="25">Lincoln</division><division
|
55
|
+
id="26">Mazda</division><division id="27">Mercedes-Benz</division><division
|
56
|
+
id="2">MINI</division><division id="29">Mitsubishi</division><division id="30">Nissan</division><division
|
57
|
+
id="34">Porsche</division><division id="57">Ram</division><division id="49">Rolls-Royce</division><division
|
58
|
+
id="52">Scion</division><division id="42">Smart</division><division id="37">Subaru</division><division
|
59
|
+
id="38">Suzuki</division><division id="56">Tesla</division><division id="39">Toyota</division><division
|
60
|
+
id="40">Volkswagen</division><division id="41">Volvo</division></Divisions></S:Body></S:Envelope>
|
61
|
+
http_version:
|
62
|
+
recorded_at: Tue, 19 Mar 2013 23:50:43 GMT
|
63
|
+
recorded_with: VCR 2.4.0
|