cineworld_uk 2.1.6 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -3
- data/README.md +56 -14
- data/Rakefile +57 -1
- data/cineworld_uk.gemspec +1 -2
- data/lib/cineworld_uk/cinema.rb +113 -182
- data/lib/cineworld_uk/internal/api_response.rb +74 -0
- data/lib/cineworld_uk/internal/parser/api/cinema_address.rb +81 -0
- data/lib/cineworld_uk/internal/parser/api/film.rb +46 -0
- data/lib/cineworld_uk/internal/parser/api/film_lookup.rb +38 -0
- data/lib/cineworld_uk/internal/parser/api/performance.rb +46 -0
- data/lib/cineworld_uk/internal/parser/api/performances_by_day.rb +50 -0
- data/lib/cineworld_uk/internal/title_sanitizer.rb +56 -52
- data/lib/cineworld_uk/performance.rb +78 -0
- data/lib/cineworld_uk/version.rb +2 -2
- data/lib/cineworld_uk.rb +11 -8
- data/test/fixtures/api/cinema-detail-10.json +1 -0
- data/test/fixtures/api/cinema-detail-21.json +1 -0
- data/test/fixtures/api/cinema-detail-3.json +1 -0
- data/test/fixtures/api/cinema-detail-96.json +1 -0
- data/test/fixtures/api/cinema-list.json +1 -0
- data/test/fixtures/api/dates-3.json +1 -0
- data/test/fixtures/api/film-list-comingsoon.json +1 -0
- data/test/fixtures/api/film-list.json +1 -0
- data/test/fixtures/api/performances-tomorrow-3.json +1 -0
- data/test/lib/cineworld_uk/cinema_test.rb +96 -197
- data/test/lib/cineworld_uk/internal/api_response_test.rb +85 -0
- data/test/lib/cineworld_uk/internal/parser/api/cinema_address_test.rb +93 -0
- data/test/lib/cineworld_uk/internal/parser/api/film_lookup_test.rb +30 -0
- data/test/lib/cineworld_uk/internal/parser/api/film_test.rb +169 -0
- data/test/lib/cineworld_uk/internal/parser/api/performance_test.rb +62 -0
- data/test/lib/cineworld_uk/internal/title_sanitizer_test.rb +1 -1
- data/test/lib/cineworld_uk/{screening_test.rb → performance_test.rb} +36 -48
- data/test/support/fixture_reader.rb +44 -0
- metadata +48 -59
- data/lib/cineworld_uk/film.rb +0 -65
- data/lib/cineworld_uk/internal/film_with_screenings_parser.rb +0 -69
- data/lib/cineworld_uk/internal/screening_parser.rb +0 -132
- data/lib/cineworld_uk/internal/website.rb +0 -35
- data/lib/cineworld_uk/internal/whatson_parser.rb +0 -36
- data/lib/cineworld_uk/screening.rb +0 -87
- data/test/fixture_updater.rb +0 -64
- data/test/fixtures/cinemas.html +0 -513
- data/test/fixtures/information/brighton.html +0 -1268
- data/test/fixtures/information/bristol.html +0 -1265
- data/test/fixtures/whatson/brighton/film_first.html +0 -207
- data/test/fixtures/whatson/brighton/film_last.html +0 -62
- data/test/fixtures/whatson/brighton/film_second.html +0 -347
- data/test/fixtures/whatson/brighton.html +0 -7508
- data/test/fixtures/whatson/glasgow-imax-at-gsc/film_first.html +0 -182
- data/test/fixtures/whatson/the-o2-greenwich/film_first.html +0 -167
- data/test/lib/cineworld_uk/film_test.rb +0 -142
- data/test/lib/cineworld_uk/internal/film_with_screenings_parser_test.rb +0 -101
- data/test/lib/cineworld_uk/internal/website_test.rb +0 -57
- data/test/lib/cineworld_uk/internal/whatson_parser_test.rb +0 -58
@@ -1,21 +1,21 @@
|
|
1
1
|
require_relative '../../test_helper'
|
2
|
+
require_relative '../../support/fixture_reader'
|
2
3
|
|
3
4
|
describe CineworldUk::Cinema do
|
4
|
-
|
5
|
+
include Support::FixtureReader
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
let(:described_class) { CineworldUk::Cinema }
|
8
|
+
let(:api_response) { Minitest::Mock.new }
|
9
|
+
|
10
|
+
before { WebMock.disable_net_connect! }
|
9
11
|
|
10
12
|
describe '.all' do
|
11
|
-
subject {
|
13
|
+
subject { described_class.all }
|
12
14
|
|
13
|
-
before
|
14
|
-
website.expect(:cinemas, cinemas_html)
|
15
|
-
end
|
15
|
+
before { api_response.expect(:cinema_list, cinema_list_json) }
|
16
16
|
|
17
17
|
it 'returns an Array of CineworldUK::Cinemas' do
|
18
|
-
CineworldUk::Internal::
|
18
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
19
19
|
subject.must_be_instance_of(Array)
|
20
20
|
subject.each do |value|
|
21
21
|
value.must_be_instance_of(CineworldUk::Cinema)
|
@@ -24,89 +24,30 @@ describe CineworldUk::Cinema do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'returns the correctly sized array' do
|
27
|
-
CineworldUk::Internal::
|
28
|
-
subject.size.must_equal
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '.find(id)' do
|
34
|
-
subject { CineworldUk::Cinema.find(id) }
|
35
|
-
|
36
|
-
describe 'Brighton' do
|
37
|
-
let(:id) { 3 }
|
38
|
-
|
39
|
-
before do
|
40
|
-
website.expect(:cinemas, cinemas_html)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'returns a cinema' do
|
44
|
-
CineworldUk::Internal::Website.stub :new, website do
|
45
|
-
subject.must_be_instance_of(CineworldUk::Cinema)
|
46
|
-
|
47
|
-
subject.id.must_equal 3
|
48
|
-
subject.brand.must_equal 'Cineworld'
|
49
|
-
subject.name.must_equal 'Brighton'
|
50
|
-
end
|
27
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
28
|
+
subject.size.must_equal(88)
|
51
29
|
end
|
52
30
|
end
|
53
31
|
end
|
54
32
|
|
55
|
-
describe '.new' do
|
56
|
-
it 'removes "London - " name prefix' do
|
57
|
-
cinema = CineworldUk::Cinema.new 79, 'London - The O2, Greenwich'
|
58
|
-
cinema.id.must_equal 79
|
59
|
-
cinema.name.must_equal 'The O2, Greenwich'
|
60
|
-
cinema.slug.must_equal 'the-o2-greenwich'
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'removes " - " and replaces it with a colon ": "' do
|
64
|
-
cinema = CineworldUk::Cinema.new 88, 'Glasgow - IMAX at GSC'
|
65
|
-
cinema.id.must_equal 88
|
66
|
-
cinema.name.must_equal 'Glasgow: IMAX at GSC'
|
67
|
-
cinema.slug.must_equal 'glasgow-imax-at-gsc'
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
33
|
describe '#adr' do
|
72
|
-
subject {
|
34
|
+
subject { described_class.new(id).adr }
|
73
35
|
|
74
|
-
|
75
|
-
|
36
|
+
before do
|
37
|
+
api_response.expect(:cinema_detail, cinema_detail_json(id), [id])
|
38
|
+
end
|
76
39
|
|
77
|
-
|
78
|
-
|
79
|
-
end
|
40
|
+
describe 'Brighton (3)' do
|
41
|
+
let(:id) { 3 }
|
80
42
|
|
81
43
|
it 'returns the address hash' do
|
82
|
-
CineworldUk::Internal::
|
44
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
83
45
|
subject.must_equal(
|
84
|
-
street_address: 'Brighton Marina',
|
46
|
+
street_address: 'Brighton Marina Village',
|
85
47
|
extended_address: nil,
|
86
48
|
locality: 'Brighton',
|
87
|
-
region: 'East Sussex',
|
88
|
-
postal_code: 'BN2 5UF',
|
89
|
-
country: 'United Kingdom'
|
90
|
-
)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe '(bristol)' do
|
96
|
-
let(:cinema) { CineworldUk::Cinema.new('4', 'Bristol') }
|
97
|
-
|
98
|
-
before do
|
99
|
-
website.expect(:cinema_information, information_html('bristol'), [4])
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'returns the address hash' do
|
103
|
-
CineworldUk::Internal::Website.stub :new, website do
|
104
|
-
subject.must_equal(
|
105
|
-
street_address: 'Hengrove Leisure Park',
|
106
|
-
extended_address: 'Hengrove Way',
|
107
|
-
locality: 'Bristol',
|
108
49
|
region: nil,
|
109
|
-
postal_code: '
|
50
|
+
postal_code: 'BN2 5UF',
|
110
51
|
country: 'United Kingdom'
|
111
52
|
)
|
112
53
|
end
|
@@ -115,111 +56,89 @@ describe CineworldUk::Cinema do
|
|
115
56
|
end
|
116
57
|
|
117
58
|
describe '#extended_address' do
|
118
|
-
subject {
|
119
|
-
|
120
|
-
describe '(brighton)' do
|
121
|
-
let(:cinema) { CineworldUk::Cinema.new('3', 'Brighton') }
|
122
|
-
|
123
|
-
before do
|
124
|
-
website.expect(:cinema_information, information_html('brighton'), [3])
|
125
|
-
end
|
59
|
+
subject { described_class.new(id).extended_address }
|
126
60
|
|
127
|
-
|
128
|
-
|
129
|
-
subject.must_be_nil
|
130
|
-
end
|
131
|
-
end
|
61
|
+
before do
|
62
|
+
api_response.expect(:cinema_detail, cinema_detail_json(id), [id])
|
132
63
|
end
|
133
64
|
|
134
|
-
describe '(
|
135
|
-
let(:
|
136
|
-
|
137
|
-
before do
|
138
|
-
website.expect(:cinema_information, information_html('bristol'), [4])
|
139
|
-
end
|
65
|
+
describe 'Brighton (3)' do
|
66
|
+
let(:id) { 3 }
|
140
67
|
|
141
|
-
it 'returns the
|
142
|
-
CineworldUk::Internal::
|
143
|
-
subject.must_equal
|
68
|
+
it 'returns the address hash' do
|
69
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
70
|
+
subject.must_equal('')
|
144
71
|
end
|
145
72
|
end
|
146
73
|
end
|
147
74
|
end
|
148
75
|
|
149
|
-
describe '#films' do
|
150
|
-
subject { CineworldUk::Cinema.new('3', 'Brighton').films }
|
151
|
-
|
152
|
-
it 'calls out to Screening object' do
|
153
|
-
CineworldUk::Film.stub :at, [:film] do
|
154
|
-
subject.must_equal([:film])
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
76
|
describe '#full_name' do
|
160
|
-
subject {
|
77
|
+
subject { described_class.new(id).full_name }
|
78
|
+
|
79
|
+
before { api_response.expect(:cinema_list, cinema_list_json) }
|
161
80
|
|
162
|
-
describe 'simple name (
|
163
|
-
let(:
|
81
|
+
describe 'simple name (Brighton)' do
|
82
|
+
let(:id) { 3 }
|
164
83
|
|
165
84
|
it 'returns the brand in the name' do
|
166
|
-
|
85
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
86
|
+
subject.must_equal 'Cineworld Brighton'
|
87
|
+
end
|
167
88
|
end
|
168
89
|
end
|
169
90
|
|
170
|
-
describe 'complex name (
|
171
|
-
let(:
|
91
|
+
describe 'complex name (Glasgow IMAX)' do
|
92
|
+
let(:id) { 88 }
|
172
93
|
|
173
94
|
it 'returns the brand in the name' do
|
174
|
-
|
95
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
96
|
+
subject.must_equal 'Cineworld Glasgow: IMAX at GSC'
|
97
|
+
end
|
175
98
|
end
|
176
99
|
end
|
177
100
|
end
|
178
101
|
|
179
102
|
describe '#locality' do
|
180
|
-
subject {
|
103
|
+
subject { described_class.new(id).locality }
|
181
104
|
|
182
|
-
|
183
|
-
|
105
|
+
before do
|
106
|
+
api_response.expect(:cinema_detail, cinema_detail_json(id), [id])
|
107
|
+
end
|
184
108
|
|
185
|
-
|
186
|
-
|
187
|
-
end
|
109
|
+
describe 'Brighton (3)' do
|
110
|
+
let(:id) { 3 }
|
188
111
|
|
189
112
|
it 'returns the town/city' do
|
190
|
-
CineworldUk::Internal::
|
113
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
191
114
|
subject.must_equal 'Brighton'
|
192
115
|
end
|
193
116
|
end
|
194
117
|
end
|
195
118
|
|
196
|
-
describe '(
|
197
|
-
let(:
|
119
|
+
describe 'London - 10 (Chelsea)' do
|
120
|
+
let(:id) { 10 }
|
198
121
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
it 'returns the town/city' do
|
204
|
-
CineworldUk::Internal::Website.stub :new, website do
|
205
|
-
subject.must_equal 'Bristol'
|
122
|
+
it 'returns borough of London' do
|
123
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
124
|
+
subject.must_equal 'Chelsea'
|
206
125
|
end
|
207
126
|
end
|
208
127
|
end
|
209
128
|
end
|
210
129
|
|
211
130
|
describe '#postal_code' do
|
212
|
-
subject {
|
131
|
+
subject { described_class.new(id).postal_code }
|
213
132
|
|
214
|
-
|
215
|
-
|
133
|
+
before do
|
134
|
+
api_response.expect(:cinema_detail, cinema_detail_json(id), [id])
|
135
|
+
end
|
216
136
|
|
217
|
-
|
218
|
-
|
219
|
-
end
|
137
|
+
describe 'Brighton (3)' do
|
138
|
+
let(:id) { 3 }
|
220
139
|
|
221
140
|
it 'returns the post code' do
|
222
|
-
CineworldUk::Internal::
|
141
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
223
142
|
subject.must_equal 'BN2 5UF'
|
224
143
|
end
|
225
144
|
end
|
@@ -227,88 +146,68 @@ describe CineworldUk::Cinema do
|
|
227
146
|
end
|
228
147
|
|
229
148
|
describe '#region' do
|
230
|
-
subject {
|
231
|
-
|
232
|
-
describe '(brighton)' do
|
233
|
-
let(:cinema) { CineworldUk::Cinema.new('3', 'Brighton') }
|
234
|
-
|
235
|
-
before do
|
236
|
-
website.expect(:cinema_information, information_html('brighton'), [3])
|
237
|
-
end
|
149
|
+
subject { described_class.new(id).region }
|
238
150
|
|
239
|
-
|
240
|
-
|
241
|
-
subject.must_equal 'East Sussex'
|
242
|
-
end
|
243
|
-
end
|
151
|
+
before do
|
152
|
+
api_response.expect(:cinema_detail, cinema_detail_json(id), [id])
|
244
153
|
end
|
245
154
|
|
246
|
-
describe '(
|
247
|
-
let(:
|
248
|
-
|
249
|
-
before do
|
250
|
-
website.expect(:cinema_information, information_html('bristol'), [4])
|
251
|
-
end
|
155
|
+
describe 'no region - Brighton (3)' do
|
156
|
+
let(:id) { 3 }
|
252
157
|
|
253
|
-
it 'returns
|
254
|
-
CineworldUk::Internal::
|
255
|
-
subject.
|
158
|
+
it 'returns the empty string is none exists' do
|
159
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
160
|
+
subject.must_equal ''
|
256
161
|
end
|
257
162
|
end
|
258
163
|
end
|
259
|
-
end
|
260
164
|
|
261
|
-
|
262
|
-
|
165
|
+
describe 'London - Chelsea (10)' do
|
166
|
+
let(:id) { 10 }
|
263
167
|
|
264
|
-
|
265
|
-
|
266
|
-
|
168
|
+
it 'returns "London"' do
|
169
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
170
|
+
subject.must_equal 'London'
|
171
|
+
end
|
267
172
|
end
|
268
173
|
end
|
269
174
|
end
|
270
175
|
|
271
176
|
describe '#street_address' do
|
272
|
-
subject {
|
177
|
+
subject { described_class.new(id).street_address }
|
273
178
|
|
274
|
-
|
275
|
-
|
179
|
+
before do
|
180
|
+
api_response.expect(:cinema_detail, cinema_detail_json(id), [id])
|
181
|
+
end
|
276
182
|
|
277
|
-
|
278
|
-
|
279
|
-
end
|
183
|
+
describe 'Brighton (3)' do
|
184
|
+
let(:id) { 3 }
|
280
185
|
|
281
|
-
it 'returns the
|
282
|
-
CineworldUk::Internal::
|
283
|
-
subject.must_equal 'Brighton Marina'
|
186
|
+
it 'returns the first line of the Address' do
|
187
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
188
|
+
subject.must_equal 'Brighton Marina Village'
|
284
189
|
end
|
285
190
|
end
|
286
191
|
end
|
287
192
|
end
|
288
193
|
|
289
194
|
describe '#url' do
|
290
|
-
subject {
|
291
|
-
|
292
|
-
describe '(brighton)' do
|
293
|
-
let(:cinema) { CineworldUk::Cinema.new('3', 'Brighton') }
|
195
|
+
subject { described_class.new(id).url }
|
294
196
|
|
295
|
-
|
296
|
-
|
297
|
-
end
|
197
|
+
before do
|
198
|
+
api_response.expect(:cinema_detail, cinema_detail_json(id), [id])
|
298
199
|
end
|
299
|
-
end
|
300
|
-
|
301
|
-
private
|
302
200
|
|
303
|
-
|
304
|
-
|
305
|
-
end
|
306
|
-
|
307
|
-
def cinemas_html
|
308
|
-
read_file('../../../fixtures/cinemas.html')
|
309
|
-
end
|
201
|
+
describe 'Brighton (3)' do
|
202
|
+
let(:id) { 3 }
|
310
203
|
|
311
|
-
|
312
|
-
|
204
|
+
it 'returns the url' do
|
205
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
206
|
+
subject.must_equal(
|
207
|
+
"http://www.cineworld.co.uk/cinemas/#{id}/information"
|
208
|
+
)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
313
212
|
end
|
314
213
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
require_relative '../../../support/fixture_reader'
|
3
|
+
|
4
|
+
describe CineworldUk::Internal::ApiResponse do
|
5
|
+
include Support::FixtureReader
|
6
|
+
|
7
|
+
let(:described_class) { CineworldUk::Internal::ApiResponse }
|
8
|
+
let(:standard) { 'key=ios&territory=GB' }
|
9
|
+
|
10
|
+
describe '#cinema_list' do
|
11
|
+
subject { described_class.new.cinema_list }
|
12
|
+
|
13
|
+
before { stub_get("cinema/list?full=true&#{standard}", cinema_list_json) }
|
14
|
+
|
15
|
+
it 'returns a string' do
|
16
|
+
subject.class.must_equal String
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#cinema_detail(cinema_id, date)' do
|
21
|
+
subject { described_class.new.cinema_detail(3) }
|
22
|
+
|
23
|
+
before do
|
24
|
+
stub_get("cinema/detail?cinema=3&#{standard}", cinema_detail_json(3))
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns a string' do
|
28
|
+
subject.class.must_equal String
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#dates(cinema_id)' do
|
33
|
+
subject { described_class.new.dates(3) }
|
34
|
+
|
35
|
+
before { stub_get("dates?cinema=3&#{standard}", dates_json(3)) }
|
36
|
+
|
37
|
+
it 'returns a string' do
|
38
|
+
subject.class.must_equal String
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#film_list' do
|
43
|
+
subject { described_class.new.film_list }
|
44
|
+
|
45
|
+
before { stub_get("film/list?full=true&#{standard}", film_list_json) }
|
46
|
+
|
47
|
+
it 'returns a string' do
|
48
|
+
subject.class.must_equal String
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#film_list_comingsoon' do
|
53
|
+
subject { described_class.new.film_list_comingsoon }
|
54
|
+
|
55
|
+
before do
|
56
|
+
stub_get("film/list/comingsoon?full=true&#{standard}",
|
57
|
+
film_list_comingsoon_json)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'returns a string' do
|
61
|
+
subject.class.must_equal String
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#performances(cinema_id, date)' do
|
66
|
+
subject { described_class.new.performances(3, Date.today + 1) }
|
67
|
+
|
68
|
+
before do
|
69
|
+
stub_get("performances?cinema=3&date=#{tomorrow_s}&#{standard}",
|
70
|
+
performances_tomorrow_json(3))
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'returns a string' do
|
74
|
+
subject.class.must_equal String
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def stub_get(site_path, response_body)
|
81
|
+
url = "http://www2.cineworld.co.uk/api/#{site_path}"
|
82
|
+
response = { status: 200, body: response_body, headers: {} }
|
83
|
+
stub_request(:get, url).to_return(response)
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require_relative '../../../../../test_helper'
|
2
|
+
require_relative '../../../../../support/fixture_reader'
|
3
|
+
|
4
|
+
describe CineworldUk::Internal::Parser::Api::CinemaAddress do
|
5
|
+
include Support::FixtureReader
|
6
|
+
|
7
|
+
let(:described_class) { CineworldUk::Internal::Parser::Api::CinemaAddress }
|
8
|
+
let(:api_response) { Minitest::Mock.new }
|
9
|
+
|
10
|
+
before { WebMock.disable_net_connect! }
|
11
|
+
|
12
|
+
describe '#to_hash' do
|
13
|
+
subject { described_class.new(id).to_hash }
|
14
|
+
|
15
|
+
before do
|
16
|
+
api_response.expect(:cinema_detail, cinema_detail_json(id), [id])
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'passed simple (Brighton)' do
|
20
|
+
let(:id) { 3 }
|
21
|
+
|
22
|
+
it 'returns address hash' do
|
23
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
24
|
+
subject.must_equal(street_address: 'Brighton Marina Village',
|
25
|
+
extended_address: nil,
|
26
|
+
locality: 'Brighton',
|
27
|
+
region: nil,
|
28
|
+
postal_code: 'BN2 5UF',
|
29
|
+
country: 'United Kingdom')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'passed three line (NEC)' do
|
35
|
+
let(:id) { 96 }
|
36
|
+
|
37
|
+
it 'returns address hash' do
|
38
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
39
|
+
subject.must_equal(street_address: 'Resorts World',
|
40
|
+
extended_address: 'Pendigo Way',
|
41
|
+
locality: 'Birmingham',
|
42
|
+
region: nil,
|
43
|
+
postal_code: 'B40 1PU',
|
44
|
+
country: 'United Kingdom')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'passed three line (Edinburgh)' do
|
50
|
+
let(:id) { 21 }
|
51
|
+
|
52
|
+
it 'returns address hash' do
|
53
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
54
|
+
subject.must_equal(street_address: 'Fountain Park',
|
55
|
+
extended_address: '130/3 Dundee Street',
|
56
|
+
locality: 'Edinburgh',
|
57
|
+
region: nil,
|
58
|
+
postal_code: 'EH11 1AF',
|
59
|
+
country: 'United Kingdom')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'passed three line (Chelsea)' do
|
65
|
+
let(:id) { 10 }
|
66
|
+
|
67
|
+
it 'returns address hash' do
|
68
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
69
|
+
subject.must_equal(street_address: '279 Kings Road',
|
70
|
+
extended_address: nil,
|
71
|
+
locality: 'Chelsea',
|
72
|
+
region: 'London',
|
73
|
+
postal_code: 'SW3 5EW',
|
74
|
+
country: 'United Kingdom')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# describe 'passed non-existant api' do
|
80
|
+
# let(:id) { 0 }
|
81
|
+
#
|
82
|
+
# it 'returns hash of nils' do
|
83
|
+
# subject.must_be_instance_of(Hash)
|
84
|
+
# subject.must_equal(street_address: nil,
|
85
|
+
# extended_address: nil,
|
86
|
+
# locality: "not an address",
|
87
|
+
# region: nil,
|
88
|
+
# postal_code: "not an address",
|
89
|
+
# country: "United Kingdom")
|
90
|
+
# end
|
91
|
+
# end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative '../../../../../test_helper'
|
2
|
+
require_relative '../../../../../support/fixture_reader'
|
3
|
+
|
4
|
+
describe CineworldUk::Internal::Parser::Api::FilmLookup do
|
5
|
+
include Support::FixtureReader
|
6
|
+
|
7
|
+
let(:described_class) { CineworldUk::Internal::Parser::Api::FilmLookup }
|
8
|
+
let(:api_response) { Minitest::Mock.new }
|
9
|
+
|
10
|
+
before { WebMock.disable_net_connect! }
|
11
|
+
|
12
|
+
before do
|
13
|
+
api_response.expect(:film_list, film_list_json)
|
14
|
+
api_response.expect(:film_list_comingsoon, film_list_comingsoon_json)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#to_hash' do
|
18
|
+
subject { described_class.new.to_hash }
|
19
|
+
|
20
|
+
it 'returns a Hash of Film objects, keyed by Integers' do
|
21
|
+
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
22
|
+
subject.must_be_instance_of(Hash)
|
23
|
+
subject.each do |key, value|
|
24
|
+
key.must_be_instance_of(Fixnum)
|
25
|
+
value.must_be_instance_of(CineworldUk::Internal::Parser::Api::Film)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|