brickset_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +145 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/brickset.gemspec +30 -0
- data/lib/brickset.rb +55 -0
- data/lib/brickset/api/auth.rb +22 -0
- data/lib/brickset/api/collection/advanced.rb +34 -0
- data/lib/brickset/api/collection/minifig.rb +35 -0
- data/lib/brickset/api/collection/set.rb +117 -0
- data/lib/brickset/api/set.rb +157 -0
- data/lib/brickset/client.rb +56 -0
- data/lib/brickset/configuration.rb +9 -0
- data/lib/brickset/elements/additional_image.rb +13 -0
- data/lib/brickset/elements/collection_detail.rb +28 -0
- data/lib/brickset/elements/collection_total.rb +15 -0
- data/lib/brickset/elements/condition.rb +11 -0
- data/lib/brickset/elements/instruction.rb +12 -0
- data/lib/brickset/elements/minifig_collection.rb +15 -0
- data/lib/brickset/elements/review.rb +20 -0
- data/lib/brickset/elements/set.rb +67 -0
- data/lib/brickset/elements/subtheme.rb +15 -0
- data/lib/brickset/elements/theme.rb +15 -0
- data/lib/brickset/elements/user_note.rb +12 -0
- data/lib/brickset/elements/year.rb +13 -0
- data/lib/brickset/version.rb +3 -0
- data/spec/brickset/api/auth_spec.rb +84 -0
- data/spec/brickset/api/collection/advanced_spec.rb +59 -0
- data/spec/brickset/api/collection/minifig_spec.rb +95 -0
- data/spec/brickset/api/collection/set_spec.rb +350 -0
- data/spec/brickset/api/set_spec.rb +658 -0
- data/spec/brickset/client_spec.rb +155 -0
- data/spec/brickset/configuration_spec.rb +9 -0
- data/spec/brickset/elements/additional_image_spec.rb +26 -0
- data/spec/brickset/elements/collection_detail_spec.rb +40 -0
- data/spec/brickset/elements/collection_total_spec.rb +27 -0
- data/spec/brickset/elements/condition_spec.rb +23 -0
- data/spec/brickset/elements/instruction_spec.rb +24 -0
- data/spec/brickset/elements/minifig_collection_spec.rb +27 -0
- data/spec/brickset/elements/review_spec.rb +32 -0
- data/spec/brickset/elements/set_spec.rb +72 -0
- data/spec/brickset/elements/subtheme_spec.rb +27 -0
- data/spec/brickset/elements/theme_spec.rb +27 -0
- data/spec/brickset/elements/user_note_spec.rb +24 -0
- data/spec/brickset/elements/year_spec.rb +25 -0
- data/spec/brickset_spec.rb +59 -0
- data/spec/fixtures/api_key_invalid.xml +2 -0
- data/spec/fixtures/api_key_valid.xml +2 -0
- data/spec/fixtures/get_additional_images.xml +24 -0
- data/spec/fixtures/get_additional_images_no_result.xml +2 -0
- data/spec/fixtures/get_collection_detail.xml +23 -0
- data/spec/fixtures/get_collection_detail_conditions.xml +24 -0
- data/spec/fixtures/get_collection_detail_no_result.xml +2 -0
- data/spec/fixtures/get_collection_totals.xml +8 -0
- data/spec/fixtures/get_collection_totals_no_result.xml +8 -0
- data/spec/fixtures/get_instructions.xml +7 -0
- data/spec/fixtures/get_instructions_no_result.xml +2 -0
- data/spec/fixtures/get_minifig_collection.xml +31 -0
- data/spec/fixtures/get_minifig_collection_owned.xml +17 -0
- data/spec/fixtures/get_minifig_collection_wanted.xml +10 -0
- data/spec/fixtures/get_recently_updated_sets.xml +52 -0
- data/spec/fixtures/get_recently_updated_sets_invalid_key.xml +1 -0
- data/spec/fixtures/get_reviews.xml +28 -0
- data/spec/fixtures/get_reviews_no_result.xml +2 -0
- data/spec/fixtures/get_set.xml +52 -0
- data/spec/fixtures/get_set_no_result.xml +2 -0
- data/spec/fixtures/get_sets.xml +101 -0
- data/spec/fixtures/get_sets_no_result.xml +2 -0
- data/spec/fixtures/get_subthemes.xml +24 -0
- data/spec/fixtures/get_subthemes_for_user.xml +24 -0
- data/spec/fixtures/get_subthemes_for_user_no_result.xml +2 -0
- data/spec/fixtures/get_subthemes_for_user_owned.xml +24 -0
- data/spec/fixtures/get_subthemes_for_user_wanted.xml +31 -0
- data/spec/fixtures/get_subthemes_no_result.xml +2 -0
- data/spec/fixtures/get_themes.xml +17 -0
- data/spec/fixtures/get_themes_for_user.xml +17 -0
- data/spec/fixtures/get_themes_for_user_no_result.xml +2 -0
- data/spec/fixtures/get_themes_for_user_owned.xml +17 -0
- data/spec/fixtures/get_themes_for_user_wanted.xml +25 -0
- data/spec/fixtures/get_themes_no_result.xml +2 -0
- data/spec/fixtures/get_user_notes.xml +11 -0
- data/spec/fixtures/get_user_notes_no_result.xml +2 -0
- data/spec/fixtures/get_years.xml +18 -0
- data/spec/fixtures/get_years_for_user.xml +18 -0
- data/spec/fixtures/get_years_for_user_no_result.xml +2 -0
- data/spec/fixtures/get_years_for_user_owned.xml +13 -0
- data/spec/fixtures/get_years_for_user_wanted.xml +13 -0
- data/spec/fixtures/get_years_no_result.xml +2 -0
- data/spec/fixtures/login.xml +2 -0
- data/spec/fixtures/login_invalid_credentials.xml +2 -0
- data/spec/fixtures/login_invalid_key.xml +2 -0
- data/spec/fixtures/set_collection.xml +2 -0
- data/spec/fixtures/set_collection_invalid.xml +2 -0
- data/spec/fixtures/set_collection_owns.xml +2 -0
- data/spec/fixtures/set_collection_owns_invalid.xml +2 -0
- data/spec/fixtures/set_collection_qty_owned.xml +2 -0
- data/spec/fixtures/set_collection_qty_owned_invalid.xml +2 -0
- data/spec/fixtures/set_collection_user_notes.xml +2 -0
- data/spec/fixtures/set_collection_user_notes_invalid.xml +2 -0
- data/spec/fixtures/set_collection_wants.xml +2 -0
- data/spec/fixtures/set_collection_wants_invalid.xml +2 -0
- data/spec/fixtures/set_minifig_collection.xml +2 -0
- data/spec/fixtures/set_minifig_collection_invalid.xml +2 -0
- data/spec/fixtures/set_user_rating.xml +2 -0
- data/spec/fixtures/set_user_rating_invalid.xml +2 -0
- data/spec/fixtures/token_invalid.xml +2 -0
- data/spec/fixtures/token_valid.xml +2 -0
- data/spec/spec_helper.rb +43 -0
- metadata +355 -0
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Brickset::Client do
|
4
|
+
it 'knows its ancestors' do
|
5
|
+
aggregate_failures do
|
6
|
+
expect(described_class.ancestors).to include HTTParty
|
7
|
+
expect(described_class.ancestors).to include ActiveModel::Validations
|
8
|
+
|
9
|
+
expect(described_class.ancestors).to include Brickset::Api::Auth
|
10
|
+
expect(described_class.ancestors).to include Brickset::Api::Set
|
11
|
+
expect(described_class.ancestors).to include Brickset::Api::Collection::Set
|
12
|
+
expect(described_class.ancestors).to include Brickset::Api::Collection::Minifig
|
13
|
+
expect(described_class.ancestors).to include Brickset::Api::Collection::Advanced
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'knows its base_uri' do
|
18
|
+
expect(described_class.base_uri).to eq 'https://brickset.com/api/v2.asmx'
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#initialize' do
|
22
|
+
context 'when a token is specified' do
|
23
|
+
subject { described_class.new(token: 'access-token') }
|
24
|
+
|
25
|
+
it 'sets the token attribute' do
|
26
|
+
expect(subject.token).to eq 'access-token'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when no token is specified' do
|
31
|
+
subject { described_class.new }
|
32
|
+
|
33
|
+
it 'does not set the token attribute' do
|
34
|
+
expect(subject.token).to be_nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#call' do
|
40
|
+
let(:options) do
|
41
|
+
{}
|
42
|
+
end
|
43
|
+
let(:body) { 'apiKey=super-secret' }
|
44
|
+
let(:call) { subject.send(:call, '/method', options) }
|
45
|
+
|
46
|
+
before { stub_post('/method').with(body: body).to_return body: fixture('api_key_valid.xml') }
|
47
|
+
|
48
|
+
context 'when additional options have been set' do
|
49
|
+
let(:options) do
|
50
|
+
{ attribute: 'value' }
|
51
|
+
end
|
52
|
+
|
53
|
+
let(:body) { 'attribute=value&apiKey=super-secret' }
|
54
|
+
|
55
|
+
it 'makes a POST request with the additional options and default options as the body' do
|
56
|
+
expect(described_class).to receive(:post).with('/method', { body: { attribute: 'value', apiKey: 'super-secret' } }).and_call_original
|
57
|
+
call
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when no additional options have been set' do
|
62
|
+
it 'makes a POST request with the default options as the body' do
|
63
|
+
expect(described_class).to receive(:post).with('/method', { body: { apiKey: 'super-secret' } }).and_call_original
|
64
|
+
call
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when the response is OK' do
|
69
|
+
it 'returns the response body' do
|
70
|
+
expect(call).to eq "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<string xmlns=\"https://brickset.com/api/\">OK</string>\n"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when the response is not OK' do
|
75
|
+
before { stub_post('/method').with(body: body).to_return body: 'Error 500: Internal Server Error', status: 500 }
|
76
|
+
|
77
|
+
it 'raises the response body' do
|
78
|
+
expect { call }.to raise_error 'Error 500: Internal Server Error'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#handle_update' do
|
84
|
+
let(:handle_update) { subject.send(:handle_update, response) }
|
85
|
+
|
86
|
+
let(:response) { fixture('api_key_valid.xml') }
|
87
|
+
|
88
|
+
it 'parses the specified response' do
|
89
|
+
expect(HappyMapper).to receive(:parse).with(response).and_call_original
|
90
|
+
handle_update
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when the content is OK' do
|
94
|
+
it 'returns true' do
|
95
|
+
expect(handle_update).to eq true
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'when the content is not OK' do
|
100
|
+
let(:response) { fixture('api_key_invalid.xml') }
|
101
|
+
|
102
|
+
it 'saves a reference to the error' do
|
103
|
+
handle_update
|
104
|
+
expect(subject.errors[:base]).to match_array [ 'INVALIDKEY' ]
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'returns false' do
|
108
|
+
expect(handle_update).to eq false
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '#extract_attributes_from_options' do
|
114
|
+
let(:extract_attributes_from_options) { subject.send(:extract_attributes_from_options, options) }
|
115
|
+
|
116
|
+
context 'when there is a known attribute in the options hash' do
|
117
|
+
let(:options) do
|
118
|
+
{ owned: 0 }
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'sets its value to the known attribute' do
|
122
|
+
extract_attributes_from_options
|
123
|
+
expect(subject.owned).to eq 0
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context 'when there is an unknown attribute in the options hash' do
|
128
|
+
let(:options) do
|
129
|
+
{ unknown: 'value' }
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'raises a KeyError' do
|
133
|
+
expect { extract_attributes_from_options }.to raise_error KeyError, "Attribute key 'unknown' is not supported"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '#default_options' do
|
139
|
+
let(:default_options) { subject.send(:default_options) }
|
140
|
+
|
141
|
+
context 'when the token has not been set' do
|
142
|
+
it 'knows its default options' do
|
143
|
+
expect(default_options).to eq apiKey: 'super-secret'
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'when the token has been set' do
|
148
|
+
subject { described_class.new(token: 'access-token') }
|
149
|
+
|
150
|
+
it 'knows its default options' do
|
151
|
+
expect(default_options).to eq apiKey: 'super-secret', userHash: 'access-token'
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Brickset::Elements::AdditionalImage do
|
4
|
+
|
5
|
+
it 'knows its ancestors' do
|
6
|
+
expect(described_class.ancestors).to include HappyMapper
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'knows its tag' do
|
10
|
+
expect(described_class.tag_name).to eq 'additionalImages'
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#parse' do
|
14
|
+
let(:xml) { fixture('get_additional_images.xml') }
|
15
|
+
let(:parsed) { described_class.parse(xml, single: true) }
|
16
|
+
|
17
|
+
it 'knows its attributes' do
|
18
|
+
aggregate_failures do
|
19
|
+
expect(parsed.thumbnail_url).to eq 'https://images.brickset.com/sets/AdditionalImages/10179-1/tn_10179-0000-xx-13-1_jpg.jpg'
|
20
|
+
expect(parsed.thumbnail_url).to eq 'https://images.brickset.com/sets/AdditionalImages/10179-1/tn_10179-0000-xx-13-1_jpg.jpg'
|
21
|
+
expect(parsed.image_url).to eq 'https://images.brickset.com/sets/AdditionalImages/10179-1/10179-0000-xx-13-1.jpg'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Brickset::Elements::CollectionDetail do
|
4
|
+
|
5
|
+
it 'knows its ancestors' do
|
6
|
+
expect(described_class.ancestors).to include HappyMapper
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'knows its tag' do
|
10
|
+
expect(described_class.tag_name).to eq 'collectionDetails'
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#parse' do
|
14
|
+
let(:xml) { fixture('get_collection_detail.xml') }
|
15
|
+
let(:parsed) { described_class.parse(xml, single: true) }
|
16
|
+
|
17
|
+
it 'knows its attributes' do
|
18
|
+
aggregate_failures do
|
19
|
+
expect(parsed.collection_id).to eq 12712521
|
20
|
+
expect(parsed.date_acquired).to eq '21-08-18'
|
21
|
+
expect(parsed.currency).to eq 'EUR'
|
22
|
+
expect(parsed.price_paid).to eq 3.0
|
23
|
+
expect(parsed.additional_price_paid).to eq 0.49
|
24
|
+
expect(parsed.current_estimated_value).to eq 3.49
|
25
|
+
expect(parsed.condition_when_acquired).to eq 'As new'
|
26
|
+
expect(parsed.acquired_from).to eq 'Mos Eisley'
|
27
|
+
expect(parsed.condition_now).to eq 'Assembled'
|
28
|
+
expect(parsed.location).to eq 'In a galaxy far, far away...'
|
29
|
+
expect(parsed.notes).to eq 'A long time ago...'
|
30
|
+
expect(parsed.parts).to eq true
|
31
|
+
expect(parsed.minifigs).to eq false
|
32
|
+
expect(parsed.instructions).to eq true
|
33
|
+
expect(parsed.box).to eq true
|
34
|
+
expect(parsed.modified).to eq true
|
35
|
+
expect(parsed.will_trade).to eq false
|
36
|
+
expect(parsed.deleted).to eq false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Brickset::Elements::CollectionTotal do
|
4
|
+
|
5
|
+
it 'knows its ancestors' do
|
6
|
+
expect(described_class.ancestors).to include HappyMapper
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'knows its tag' do
|
10
|
+
expect(described_class.tag_name).to eq 'collectionTotals'
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#parse' do
|
14
|
+
let(:xml) { fixture('get_collection_totals.xml') }
|
15
|
+
let(:parsed) { described_class.parse(xml, single: true) }
|
16
|
+
|
17
|
+
it 'knows its attributes' do
|
18
|
+
aggregate_failures do
|
19
|
+
expect(parsed.total_sets_owned).to eq 126
|
20
|
+
expect(parsed.total_sets_wanted).to eq 85
|
21
|
+
expect(parsed.total_distinct_sets_owned).to eq 121
|
22
|
+
expect(parsed.total_minifigs_owned).to eq 156
|
23
|
+
expect(parsed.total_minifigs_wanted).to eq 40
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Brickset::Elements::Condition do
|
4
|
+
|
5
|
+
it 'knows its ancestors' do
|
6
|
+
expect(described_class.ancestors).to include HappyMapper
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'knows its tag' do
|
10
|
+
expect(described_class.tag_name).to eq 'conditions'
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#parse' do
|
14
|
+
let(:xml) { fixture('get_collection_detail_conditions.xml') }
|
15
|
+
let(:parsed) { described_class.parse(xml, single: true) }
|
16
|
+
|
17
|
+
it 'knows its attributes' do
|
18
|
+
aggregate_failures do
|
19
|
+
expect(parsed.condition).to eq 'Assembled'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Brickset::Elements::Instruction do
|
4
|
+
|
5
|
+
it 'knows its ancestors' do
|
6
|
+
expect(described_class.ancestors).to include HappyMapper
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'knows its tag' do
|
10
|
+
expect(described_class.tag_name).to eq 'instructions'
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#parse' do
|
14
|
+
let(:xml) { fixture('get_instructions.xml') }
|
15
|
+
let(:parsed) { described_class.parse(xml, single: true) }
|
16
|
+
|
17
|
+
it 'knows its attributes' do
|
18
|
+
aggregate_failures do
|
19
|
+
expect(parsed.url).to eq 'https://www.lego.com/biassets/bi/4525430.pdf'
|
20
|
+
expect(parsed.description).to eq 'Building instruction 10179'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Brickset::Elements::MinifigCollection do
|
4
|
+
|
5
|
+
it 'knows its ancestors' do
|
6
|
+
expect(described_class.ancestors).to include HappyMapper
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'knows its tag' do
|
10
|
+
expect(described_class.tag_name).to eq 'minifigCollection'
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#parse' do
|
14
|
+
let(:xml) { fixture('get_minifig_collection.xml') }
|
15
|
+
let(:parsed) { described_class.parse(xml, single: true) }
|
16
|
+
|
17
|
+
it 'knows its attributes' do
|
18
|
+
aggregate_failures do
|
19
|
+
expect(parsed.minifig_number).to eq '85863pb076'
|
20
|
+
expect(parsed.owned_in_sets).to eq 1
|
21
|
+
expect(parsed.owned_loose).to eq 0
|
22
|
+
expect(parsed.owned_total).to eq 1
|
23
|
+
expect(parsed.wanted).to eq true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Brickset::Elements::Review do
|
4
|
+
|
5
|
+
it 'knows its ancestors' do
|
6
|
+
expect(described_class.ancestors).to include HappyMapper
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'knows its tag' do
|
10
|
+
expect(described_class.tag_name).to eq 'reviews'
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#parse' do
|
14
|
+
let(:xml) { fixture('get_reviews.xml') }
|
15
|
+
let(:parsed) { described_class.parse(xml, single: true) }
|
16
|
+
|
17
|
+
it 'knows its attributes' do
|
18
|
+
aggregate_failures do
|
19
|
+
expect(parsed.author).to eq 'darth-vader'
|
20
|
+
expect(parsed.title).to eq 'Ultimate Collector Series Millennium Falcon'
|
21
|
+
expect(parsed.review).to match(/^A long time ago, in a Lego factory far, far away.../)
|
22
|
+
expect(parsed.date_posted).to eq Date.parse('2010-10-01')
|
23
|
+
expect(parsed.overall_rating).to eq 5
|
24
|
+
expect(parsed.parts).to eq 5
|
25
|
+
expect(parsed.building_experience).to eq 5
|
26
|
+
expect(parsed.playability).to eq 3
|
27
|
+
expect(parsed.value_for_money).to eq 4
|
28
|
+
expect(parsed.html).to eq false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Brickset::Elements::Set do
|
4
|
+
|
5
|
+
it 'knows its ancestors' do
|
6
|
+
expect(described_class.ancestors).to include HappyMapper
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'knows its tag' do
|
10
|
+
expect(described_class.tag_name).to eq 'sets'
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#parse' do
|
14
|
+
let(:xml) { fixture('get_sets.xml') }
|
15
|
+
let(:parsed) { described_class.parse(xml, single: true) }
|
16
|
+
|
17
|
+
it 'knows its attributes' do
|
18
|
+
aggregate_failures do
|
19
|
+
expect(parsed.id).to eq 5860
|
20
|
+
expect(parsed.number).to eq '10179'
|
21
|
+
expect(parsed.number_variant).to eq 1
|
22
|
+
expect(parsed.name).to eq "Ultimate Collector's Millennium Falcon"
|
23
|
+
expect(parsed.year).to eq '2007'
|
24
|
+
expect(parsed.description).to be_nil
|
25
|
+
expect(parsed.category).to eq 'Normal'
|
26
|
+
expect(parsed.theme).to eq 'Star Wars'
|
27
|
+
expect(parsed.theme_group).to eq 'Licensed'
|
28
|
+
expect(parsed.subtheme).to eq 'Ultimate Collector Series'
|
29
|
+
expect(parsed.pieces).to eq '5197'
|
30
|
+
expect(parsed.minifigs).to eq '5'
|
31
|
+
expect(parsed.image).to eq true
|
32
|
+
expect(parsed.image_url).to eq 'https://images.brickset.com/sets/images/10179-1.jpg'
|
33
|
+
expect(parsed.image_filename).to eq '10179-1'
|
34
|
+
expect(parsed.thumbnail_url).to eq 'https://images.brickset.com/sets/thumbs/tn_10179-1_jpg.jpg'
|
35
|
+
expect(parsed.thumbnail_url_large).to eq 'https://images.brickset.com/sets/small/10179-1.jpg'
|
36
|
+
expect(parsed.brickset_url).to eq 'https://brickset.com/sets/10179-1'
|
37
|
+
expect(parsed.owned_by_total).to eq 3807
|
38
|
+
expect(parsed.wanted_by_total).to eq 9349
|
39
|
+
expect(parsed.released).to eq true
|
40
|
+
expect(parsed.rating).to eq 4.76190476190476
|
41
|
+
expect(parsed.user_rating).to eq 0
|
42
|
+
expect(parsed.review_count).to eq 21
|
43
|
+
expect(parsed.instructions_count).to eq 1
|
44
|
+
expect(parsed.additional_image_count).to eq 5
|
45
|
+
expect(parsed.last_updated).to eq Date.parse('2017-08-23')
|
46
|
+
expect(parsed.age_minimum).to eq 16
|
47
|
+
expect(parsed.age_maximum).to be_nil
|
48
|
+
expect(parsed.notes).to be_nil
|
49
|
+
expect(parsed.tags).to be_nil
|
50
|
+
expect(parsed.retail_price_uk).to eq '342.49'
|
51
|
+
expect(parsed.retail_price_us).to eq '499.99'
|
52
|
+
expect(parsed.retail_price_ca).to eq ''
|
53
|
+
expect(parsed.retail_price_eu).to eq ''
|
54
|
+
expect(parsed.date_added_to_shop).to eq '2007-10-24'
|
55
|
+
expect(parsed.date_removed_from_shop).to eq '2010-05-04'
|
56
|
+
expect(parsed.packaging_type).to eq 'Box'
|
57
|
+
expect(parsed.height).to eq 0.0
|
58
|
+
expect(parsed.width).to eq 0.0
|
59
|
+
expect(parsed.depth).to eq 0.0
|
60
|
+
expect(parsed.weight).to eq 0.0
|
61
|
+
expect(parsed.availability).to eq 'LEGO exclusive'
|
62
|
+
expect(parsed.ean).to eq ''
|
63
|
+
expect(parsed.upc).to eq ''
|
64
|
+
expect(parsed.acm_data_count).to eq 0
|
65
|
+
expect(parsed.owned).to eq false
|
66
|
+
expect(parsed.wanted).to eq true
|
67
|
+
expect(parsed.number_owned).to eq 0
|
68
|
+
expect(parsed.user_notes).to eq 'A long time ago in a galaxy far, far away...'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|