odeon_uk 2.0.4 → 3.0.0
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 +4 -4
- data/.travis.yml +2 -1
- data/CHANGELOG.md +6 -0
- data/Rakefile +29 -0
- data/lib/odeon_uk/api/cinema.rb +62 -0
- data/lib/odeon_uk/api/response.rb +55 -0
- data/lib/odeon_uk/api/screenings.rb +89 -0
- data/lib/odeon_uk/cinema.rb +53 -114
- data/lib/odeon_uk/configuration.rb +21 -0
- data/lib/odeon_uk/html/cinema.rb +101 -0
- data/lib/odeon_uk/html/parser/film_with_screenings.rb +160 -0
- data/lib/odeon_uk/html/screenings.rb +38 -0
- data/lib/odeon_uk/{internal → html}/website.rb +1 -1
- data/lib/odeon_uk/internal/title_sanitizer.rb +1 -0
- data/lib/odeon_uk/screening.rb +7 -15
- data/lib/odeon_uk/version.rb +2 -2
- data/lib/odeon_uk.rb +11 -4
- data/odeon_uk.gemspec +2 -0
- data/rake/fixture_creator.rb +98 -0
- data/test/fixtures/api/all_cinemas.plist +0 -0
- data/test/fixtures/api/app_init.plist +0 -0
- data/test/fixtures/api/film_times/71-100747.plist +0 -0
- data/test/fixtures/api/film_times/71-100750.plist +0 -0
- data/test/fixtures/api/film_times/71-100790.plist +0 -0
- data/test/fixtures/api/film_times/71-14646.plist +0 -0
- data/test/fixtures/api/film_times/71-14725.plist +0 -0
- data/test/fixtures/api/film_times/71-15086.plist +0 -0
- data/test/fixtures/api/film_times/71-15096.plist +0 -0
- data/test/fixtures/api/film_times/71-15122.plist +0 -0
- data/test/fixtures/api/film_times/71-15130.plist +0 -0
- data/test/fixtures/api/film_times/71-15141.plist +0 -0
- data/test/fixtures/api/film_times/71-15142.plist +0 -0
- data/test/fixtures/api/film_times/71-15143.plist +0 -0
- data/test/fixtures/api/film_times/71-15144.plist +0 -0
- data/test/fixtures/api/film_times/71-15145.plist +0 -0
- data/test/fixtures/api/film_times/71-15170.plist +0 -0
- data/test/fixtures/api/film_times/71-15172.plist +0 -0
- data/test/fixtures/api/film_times/71-15177.plist +0 -0
- data/test/fixtures/api/film_times/71-15179.plist +0 -0
- data/test/fixtures/api/film_times/71-15182.plist +0 -0
- data/test/fixtures/api/film_times/71-15286.plist +0 -0
- data/test/fixtures/api/film_times/71-15360.plist +0 -0
- data/test/fixtures/api/film_times/71-15586.plist +0 -0
- data/test/fixtures/api/film_times/71-15700.plist +0 -0
- data/test/fixtures/api/film_times/71-15718.plist +0 -0
- data/test/fixtures/api/film_times/71-15768.plist +0 -0
- data/test/fixtures/api/film_times/71-15788.plist +0 -0
- data/test/fixtures/api/film_times/71-15793.plist +0 -0
- data/test/fixtures/api/film_times/71-15794.plist +0 -0
- data/test/fixtures/api/film_times/71-15795.plist +0 -0
- data/test/fixtures/api/film_times/71-15796.plist +0 -0
- data/test/fixtures/api/film_times/71-15799.plist +0 -0
- data/test/fixtures/api/film_times/71-15802.plist +0 -0
- data/test/fixtures/api/film_times/71-15814.plist +0 -0
- data/test/fixtures/api/film_times/71-15817.plist +0 -0
- data/test/fixtures/api/film_times/71-15840.plist +0 -0
- data/test/fixtures/{cinema/leicester_square.html → html/cinema/105.html} +384 -313
- data/test/fixtures/{cinema/bfi_imax.html → html/cinema/211.html} +677 -355
- data/test/fixtures/{cinema/brighton.html → html/cinema/71.html} +899 -431
- data/test/fixtures/html/showtimes/11-imax.html +170 -0
- data/test/fixtures/html/showtimes/171-d-box.html +203 -0
- data/test/fixtures/html/showtimes/71-0.html +59 -0
- data/test/fixtures/html/showtimes/71.html +2395 -0
- data/test/fixtures/{sitemap.html → html/sitemap.html} +264 -352
- data/test/lib/odeon_uk/api/cinema_test.rb +149 -0
- data/test/lib/odeon_uk/api/response_test.rb +44 -0
- data/test/lib/odeon_uk/api/screenings_test.rb +43 -0
- data/test/lib/odeon_uk/cinema_test.rb +373 -148
- data/test/lib/odeon_uk/configuration_test.rb +29 -0
- data/test/lib/odeon_uk/html/cinema_test.rb +149 -0
- data/test/lib/odeon_uk/{internal/film_with_screenings_parser_test.rb → html/parser/film_with_screenings_test.rb} +12 -42
- data/test/lib/odeon_uk/html/screenings_test.rb +43 -0
- data/test/lib/odeon_uk/html/website_test.rb +37 -0
- data/test/lib/odeon_uk/screening_test.rb +17 -83
- data/test/support/api_fixtures_helper.rb +34 -0
- data/test/support/website_fixtures_helper.rb +25 -0
- data/test/test_helper.rb +7 -2
- metadata +149 -34
- data/lib/odeon_uk/film.rb +0 -65
- data/lib/odeon_uk/internal/film_with_screenings_parser.rb +0 -159
- data/lib/odeon_uk/internal/showtimes_page.rb +0 -36
- data/test/fixture_updater.rb +0 -72
- data/test/fixtures/showtimes/brighton/film_first.html +0 -92
- data/test/fixtures/showtimes/brighton/film_last.html +0 -100
- data/test/fixtures/showtimes/brighton.html +0 -2071
- data/test/fixtures/showtimes/liverpool_one/film_first_dbox.html +0 -188
- data/test/fixtures/showtimes/manchester/film_first_imax.html +0 -182
- data/test/lib/odeon_uk/film_test.rb +0 -142
- data/test/lib/odeon_uk/internal/showtimes_page_test.rb +0 -51
- data/test/lib/odeon_uk/internal/website_test.rb +0 -59
|
@@ -3,254 +3,479 @@ require_relative '../../test_helper'
|
|
|
3
3
|
describe OdeonUk::Cinema do
|
|
4
4
|
let(:described_class) { OdeonUk::Cinema }
|
|
5
5
|
|
|
6
|
-
let(:website) { Minitest::Mock.new }
|
|
7
|
-
|
|
8
6
|
before do
|
|
9
7
|
WebMock.disable_net_connect!
|
|
10
8
|
end
|
|
11
9
|
|
|
12
|
-
describe '
|
|
13
|
-
|
|
10
|
+
describe 'with HTML parsing' do
|
|
11
|
+
include WebsiteFixturesHelper
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
let(:website) { Minitest::Mock.new }
|
|
14
|
+
|
|
15
|
+
describe '.all' do
|
|
16
|
+
subject { described_class.all }
|
|
17
|
+
|
|
18
|
+
before do
|
|
19
|
+
website.expect(:sitemap, sitemap_html)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'returns an Array of OdeonUk::Cinemas' do
|
|
23
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
24
|
+
subject.must_be_instance_of(Array)
|
|
25
|
+
subject.each do |value|
|
|
26
|
+
value.must_be_instance_of(described_class)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'returns the correctly sized array' do
|
|
32
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
33
|
+
subject.size.must_equal 115
|
|
34
|
+
end
|
|
35
|
+
end
|
|
17
36
|
end
|
|
18
37
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
describe '.new(id)' do
|
|
39
|
+
subject { described_class.new(id) }
|
|
40
|
+
|
|
41
|
+
describe 'Brighton' do
|
|
42
|
+
let(:id) { 71 }
|
|
43
|
+
|
|
44
|
+
before do
|
|
45
|
+
website.expect(:sitemap, sitemap_html)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'returns a cinema' do
|
|
49
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
50
|
+
subject.must_be_instance_of(described_class)
|
|
51
|
+
|
|
52
|
+
subject.id.must_equal 71
|
|
53
|
+
subject.brand.must_equal 'Odeon'
|
|
54
|
+
subject.name.must_equal 'Brighton'
|
|
55
|
+
subject.slug.must_equal 'odeon-brighton'
|
|
56
|
+
subject.url.must_equal 'http://www.odeon.co.uk/cinemas/brighton/71/'
|
|
57
|
+
end
|
|
24
58
|
end
|
|
25
59
|
end
|
|
26
60
|
end
|
|
27
61
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
62
|
+
describe '#adr' do
|
|
63
|
+
subject { described_class.new(71).adr }
|
|
64
|
+
|
|
65
|
+
describe '(brighton)' do
|
|
66
|
+
before { website.expect(:cinema, cinema_html(71), [71]) }
|
|
67
|
+
|
|
68
|
+
it 'returns the address hash' do
|
|
69
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
70
|
+
subject.must_equal(
|
|
71
|
+
street_address: 'Kingswest',
|
|
72
|
+
locality: 'Brighton',
|
|
73
|
+
postal_code: 'BN1 2RE',
|
|
74
|
+
country_name: 'United Kingdom'
|
|
75
|
+
)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
31
78
|
end
|
|
32
79
|
end
|
|
33
|
-
end
|
|
34
80
|
|
|
35
|
-
|
|
36
|
-
|
|
81
|
+
describe '#brand' do
|
|
82
|
+
subject { described_class.new(id).brand }
|
|
37
83
|
|
|
38
|
-
|
|
39
|
-
|
|
84
|
+
describe 'cinema name with London' do
|
|
85
|
+
let(:id) { 105 }
|
|
40
86
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
87
|
+
it 'removes "London" name prefix' do
|
|
88
|
+
subject.must_equal 'Odeon'
|
|
89
|
+
end
|
|
44
90
|
end
|
|
91
|
+
end
|
|
45
92
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
subject.must_be_instance_of(described_class)
|
|
93
|
+
describe '#full_name' do
|
|
94
|
+
subject { described_class.new(71).full_name }
|
|
49
95
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
96
|
+
describe 'simple name (brighton)' do
|
|
97
|
+
before { website.expect(:sitemap, sitemap_html) }
|
|
98
|
+
|
|
99
|
+
it 'returns the brand in the name' do
|
|
100
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
101
|
+
subject.must_equal 'Odeon Brighton'
|
|
102
|
+
end
|
|
55
103
|
end
|
|
56
104
|
end
|
|
57
105
|
end
|
|
58
|
-
end
|
|
59
106
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
cinema
|
|
64
|
-
|
|
65
|
-
|
|
107
|
+
describe '#locality' do
|
|
108
|
+
subject { described_class.new(71).locality }
|
|
109
|
+
|
|
110
|
+
before { website.expect(:cinema, cinema_html(71), [71]) }
|
|
111
|
+
|
|
112
|
+
it 'returns town name' do
|
|
113
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
114
|
+
subject.must_equal 'Brighton'
|
|
115
|
+
end
|
|
116
|
+
end
|
|
66
117
|
end
|
|
67
118
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
119
|
+
describe '#name' do
|
|
120
|
+
subject { described_class.new(id).name }
|
|
121
|
+
|
|
122
|
+
before { website.expect(:sitemap, sitemap_html) }
|
|
123
|
+
|
|
124
|
+
describe 'cinema name with London' do
|
|
125
|
+
let(:id) { 105 }
|
|
126
|
+
|
|
127
|
+
it 'removes "London" name prefix' do
|
|
128
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
129
|
+
subject.must_equal 'Leicester Square'
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
describe 'cinema name with dashes' do
|
|
135
|
+
let(:id) { 208 }
|
|
136
|
+
|
|
137
|
+
it 'removes " - " and replaces it with a colon ": "' do
|
|
138
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
139
|
+
subject.must_equal 'Whiteleys: The Lounge'
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
73
143
|
end
|
|
74
|
-
end
|
|
75
144
|
|
|
76
|
-
|
|
77
|
-
|
|
145
|
+
describe '#postal_code' do
|
|
146
|
+
subject { described_class.new(id).postal_code }
|
|
147
|
+
|
|
148
|
+
describe 'short address' do
|
|
149
|
+
let(:id) { 71 }
|
|
78
150
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
151
|
+
before { website.expect(:cinema, cinema_html(71), [71]) }
|
|
152
|
+
|
|
153
|
+
it 'returns the postcode' do
|
|
154
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
155
|
+
subject.must_equal 'BN1 2RE'
|
|
156
|
+
end
|
|
157
|
+
end
|
|
82
158
|
end
|
|
83
159
|
|
|
84
|
-
|
|
85
|
-
|
|
160
|
+
describe 'short address (London)' do
|
|
161
|
+
let(:id) { 211 }
|
|
162
|
+
|
|
163
|
+
before { website.expect(:cinema, cinema_html(211), [211]) }
|
|
164
|
+
|
|
165
|
+
it 'returns the postcode' do
|
|
166
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
167
|
+
subject.must_equal 'SE1 8XR'
|
|
168
|
+
end
|
|
169
|
+
end
|
|
86
170
|
end
|
|
87
171
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
172
|
+
describe 'short address (extra London Postcode)' do
|
|
173
|
+
let(:id) { 105 }
|
|
174
|
+
|
|
175
|
+
before { website.expect(:cinema, cinema_html(105), [105]) }
|
|
176
|
+
|
|
177
|
+
it 'returns the postcode' do
|
|
178
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
179
|
+
subject.must_equal 'WC2H 7LQ'
|
|
180
|
+
end
|
|
96
181
|
end
|
|
97
182
|
end
|
|
98
183
|
end
|
|
99
|
-
end
|
|
100
184
|
|
|
101
|
-
|
|
102
|
-
|
|
185
|
+
describe '#screenings' do
|
|
186
|
+
subject { described_class.new(71).screenings }
|
|
103
187
|
|
|
104
|
-
|
|
105
|
-
|
|
188
|
+
it 'calls out to Screening object' do
|
|
189
|
+
OdeonUk::Screening.stub :at, [:screening] do
|
|
190
|
+
subject.must_equal([:screening])
|
|
191
|
+
end
|
|
192
|
+
end
|
|
106
193
|
end
|
|
107
194
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
195
|
+
describe '#slug' do
|
|
196
|
+
subject { described_class.new(71).slug }
|
|
197
|
+
|
|
198
|
+
describe 'simple name (brighton)' do
|
|
199
|
+
before { website.expect(:sitemap, sitemap_html) }
|
|
200
|
+
|
|
201
|
+
it 'returns the brand in the name' do
|
|
202
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
203
|
+
subject.must_equal 'odeon-brighton'
|
|
204
|
+
end
|
|
205
|
+
end
|
|
111
206
|
end
|
|
112
207
|
end
|
|
113
|
-
end
|
|
114
208
|
|
|
115
|
-
|
|
116
|
-
|
|
209
|
+
describe '#street_address' do
|
|
210
|
+
subject { described_class.new(id).street_address }
|
|
117
211
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
OdeonUk::Cinema.new('71', 'Brighton', '/cinemas/brighton/71/')
|
|
121
|
-
end
|
|
212
|
+
describe 'short address' do
|
|
213
|
+
let(:id) { 71 }
|
|
122
214
|
|
|
123
|
-
|
|
124
|
-
|
|
215
|
+
before { website.expect(:cinema, cinema_html(71), [71]) }
|
|
216
|
+
|
|
217
|
+
it 'returns first line of address' do
|
|
218
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
219
|
+
subject.must_equal 'Kingswest'
|
|
220
|
+
end
|
|
221
|
+
end
|
|
125
222
|
end
|
|
223
|
+
end
|
|
126
224
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
225
|
+
describe '#url' do
|
|
226
|
+
subject { described_class.new(71).url }
|
|
227
|
+
|
|
228
|
+
describe 'brighton' do
|
|
229
|
+
before { website.expect(:sitemap, sitemap_html) }
|
|
230
|
+
|
|
231
|
+
it 'returns the brand in the name' do
|
|
232
|
+
OdeonUk::Html::Website.stub :new, website do
|
|
233
|
+
subject.must_equal 'http://www.odeon.co.uk/cinemas/brighton/71/'
|
|
234
|
+
end
|
|
130
235
|
end
|
|
131
236
|
end
|
|
132
237
|
end
|
|
133
238
|
end
|
|
134
239
|
|
|
135
|
-
describe '
|
|
136
|
-
|
|
240
|
+
describe 'with API parsing' do
|
|
241
|
+
include ApiFixturesHelper
|
|
242
|
+
|
|
243
|
+
before do
|
|
244
|
+
OdeonUk.configure do |config|
|
|
245
|
+
config.method = :api
|
|
246
|
+
end
|
|
247
|
+
end
|
|
137
248
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
249
|
+
after do
|
|
250
|
+
OdeonUk.configure do |config|
|
|
251
|
+
config.method = :html
|
|
141
252
|
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
let(:response) { Minitest::Mock.new }
|
|
256
|
+
|
|
257
|
+
describe '.all' do
|
|
258
|
+
subject { described_class.all }
|
|
142
259
|
|
|
143
260
|
before do
|
|
144
|
-
|
|
261
|
+
response.expect(:all_cinemas, parse(all_cinemas_plist))
|
|
145
262
|
end
|
|
146
263
|
|
|
147
|
-
it 'returns
|
|
148
|
-
OdeonUk::
|
|
149
|
-
subject.
|
|
264
|
+
it 'returns an Array of OdeonUk::Cinemas' do
|
|
265
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
266
|
+
subject.must_be_instance_of(Array)
|
|
267
|
+
subject.each do |value|
|
|
268
|
+
value.must_be_instance_of(described_class)
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
it 'returns the correctly sized array' do
|
|
274
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
275
|
+
subject.size.must_equal 115
|
|
150
276
|
end
|
|
151
277
|
end
|
|
152
278
|
end
|
|
153
|
-
end
|
|
154
279
|
|
|
155
|
-
|
|
156
|
-
|
|
280
|
+
describe '.new(id)' do
|
|
281
|
+
subject { described_class.new(id) }
|
|
282
|
+
|
|
283
|
+
describe 'Brighton' do
|
|
284
|
+
let(:id) { 71 }
|
|
285
|
+
|
|
286
|
+
before do
|
|
287
|
+
response.expect(:all_cinemas, parse(all_cinemas_plist))
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
it 'returns a cinema' do
|
|
291
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
292
|
+
subject.must_be_instance_of(described_class)
|
|
157
293
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
294
|
+
subject.id.must_equal 71
|
|
295
|
+
subject.brand.must_equal 'Odeon'
|
|
296
|
+
subject.name.must_equal 'Brighton'
|
|
297
|
+
subject.slug.must_equal 'odeon-brighton'
|
|
298
|
+
subject.url.must_be_nil
|
|
299
|
+
end
|
|
300
|
+
end
|
|
161
301
|
end
|
|
302
|
+
end
|
|
162
303
|
|
|
163
|
-
|
|
164
|
-
|
|
304
|
+
describe '#adr' do
|
|
305
|
+
subject { described_class.new(71).adr }
|
|
306
|
+
|
|
307
|
+
describe '(brighton)' do
|
|
308
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
|
309
|
+
|
|
310
|
+
it 'returns the address hash' do
|
|
311
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
312
|
+
subject.must_equal(
|
|
313
|
+
street_address: 'Kingswest',
|
|
314
|
+
locality: 'Brighton',
|
|
315
|
+
postal_code: 'BN1 2RE',
|
|
316
|
+
country_name: 'United Kingdom'
|
|
317
|
+
)
|
|
318
|
+
end
|
|
319
|
+
end
|
|
165
320
|
end
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
describe '#brand' do
|
|
324
|
+
subject { described_class.new(id).brand }
|
|
325
|
+
|
|
326
|
+
describe 'cinema name with London' do
|
|
327
|
+
let(:id) { 105 }
|
|
166
328
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
subject.must_equal 'BN1 2RE'
|
|
329
|
+
it 'removes "London" name prefix' do
|
|
330
|
+
subject.must_equal 'Odeon'
|
|
170
331
|
end
|
|
171
332
|
end
|
|
172
333
|
end
|
|
173
334
|
|
|
174
|
-
describe '
|
|
175
|
-
|
|
176
|
-
|
|
335
|
+
describe '#full_name' do
|
|
336
|
+
subject { described_class.new(71).full_name }
|
|
337
|
+
|
|
338
|
+
describe 'simple name (brighton)' do
|
|
339
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
|
340
|
+
|
|
341
|
+
it 'returns the brand in the name' do
|
|
342
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
343
|
+
subject.must_equal 'Odeon Brighton'
|
|
344
|
+
end
|
|
345
|
+
end
|
|
177
346
|
end
|
|
347
|
+
end
|
|
178
348
|
|
|
179
|
-
|
|
180
|
-
|
|
349
|
+
describe '#locality' do
|
|
350
|
+
subject { described_class.new(71).locality }
|
|
351
|
+
|
|
352
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
|
353
|
+
|
|
354
|
+
it 'returns town name' do
|
|
355
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
356
|
+
subject.must_equal 'Brighton'
|
|
357
|
+
end
|
|
181
358
|
end
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
describe '#name' do
|
|
362
|
+
subject { described_class.new(id).name }
|
|
182
363
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
364
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
|
365
|
+
|
|
366
|
+
describe 'cinema name with London' do
|
|
367
|
+
let(:id) { 105 }
|
|
368
|
+
|
|
369
|
+
it 'removes "London" name prefix' do
|
|
370
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
371
|
+
subject.must_equal 'Leicester Square'
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
describe 'cinema name with dashes' do
|
|
377
|
+
let(:id) { 208 }
|
|
378
|
+
|
|
379
|
+
it 'removes " - " and replaces it with a colon ": "' do
|
|
380
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
381
|
+
subject.must_equal 'Whiteleys: The Lounge'
|
|
382
|
+
end
|
|
186
383
|
end
|
|
187
384
|
end
|
|
188
385
|
end
|
|
189
386
|
|
|
190
|
-
describe '
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
387
|
+
describe '#postal_code' do
|
|
388
|
+
subject { described_class.new(id).postal_code }
|
|
389
|
+
|
|
390
|
+
describe 'short address' do
|
|
391
|
+
let(:id) { 71 }
|
|
392
|
+
|
|
393
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
|
394
|
+
|
|
395
|
+
it 'returns the postcode' do
|
|
396
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
397
|
+
subject.must_equal 'BN1 2RE'
|
|
398
|
+
end
|
|
399
|
+
end
|
|
195
400
|
end
|
|
196
401
|
|
|
197
|
-
|
|
198
|
-
|
|
402
|
+
describe 'short address (London)' do
|
|
403
|
+
let(:id) { 211 }
|
|
404
|
+
|
|
405
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
|
406
|
+
|
|
407
|
+
it 'returns the postcode' do
|
|
408
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
409
|
+
subject.must_equal 'SE1 8XR'
|
|
410
|
+
end
|
|
411
|
+
end
|
|
199
412
|
end
|
|
200
413
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
414
|
+
describe 'short address (extra London Postcode)' do
|
|
415
|
+
let(:id) { 105 }
|
|
416
|
+
|
|
417
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
|
418
|
+
|
|
419
|
+
it 'returns the postcode' do
|
|
420
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
421
|
+
subject.must_equal 'WC2H 7LQ'
|
|
422
|
+
end
|
|
204
423
|
end
|
|
205
424
|
end
|
|
206
425
|
end
|
|
207
|
-
end
|
|
208
426
|
|
|
209
|
-
|
|
210
|
-
|
|
427
|
+
describe '#screenings' do
|
|
428
|
+
subject { described_class.new(71).screenings }
|
|
211
429
|
|
|
212
|
-
|
|
213
|
-
|
|
430
|
+
it 'calls out to Screening object' do
|
|
431
|
+
OdeonUk::Screening.stub :at, [:screening] do
|
|
432
|
+
subject.must_equal([:screening])
|
|
433
|
+
end
|
|
434
|
+
end
|
|
214
435
|
end
|
|
215
436
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
437
|
+
describe '#slug' do
|
|
438
|
+
subject { described_class.new(71).slug }
|
|
439
|
+
|
|
440
|
+
describe 'simple name (brighton)' do
|
|
441
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
|
442
|
+
|
|
443
|
+
it 'returns the brand in the name' do
|
|
444
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
445
|
+
subject.must_equal 'odeon-brighton'
|
|
446
|
+
end
|
|
447
|
+
end
|
|
219
448
|
end
|
|
220
449
|
end
|
|
221
|
-
end
|
|
222
450
|
|
|
223
|
-
|
|
224
|
-
|
|
451
|
+
describe '#street_address' do
|
|
452
|
+
subject { described_class.new(id).street_address }
|
|
225
453
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
OdeonUk::Cinema.new('71', 'Brighton', '/cinemas/brighton/71/')
|
|
229
|
-
end
|
|
454
|
+
describe 'short address' do
|
|
455
|
+
let(:id) { 71 }
|
|
230
456
|
|
|
231
|
-
|
|
232
|
-
website.expect(:cinema, cinema_html('brighton'), [71])
|
|
233
|
-
end
|
|
457
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
|
234
458
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
459
|
+
it 'returns first line of address' do
|
|
460
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
461
|
+
subject.must_equal 'Kingswest'
|
|
462
|
+
end
|
|
238
463
|
end
|
|
239
464
|
end
|
|
240
465
|
end
|
|
241
|
-
end
|
|
242
466
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
def read_file(filepath)
|
|
246
|
-
File.read(File.expand_path(filepath, __FILE__))
|
|
247
|
-
end
|
|
467
|
+
describe '#url' do
|
|
468
|
+
subject { described_class.new(71).url }
|
|
248
469
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
end
|
|
470
|
+
describe 'brighton' do
|
|
471
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
|
252
472
|
|
|
253
|
-
|
|
254
|
-
|
|
473
|
+
it 'returns the brand in the name' do
|
|
474
|
+
OdeonUk::Api::Response.stub :new, response do
|
|
475
|
+
subject.must_be_nil
|
|
476
|
+
end
|
|
477
|
+
end
|
|
478
|
+
end
|
|
479
|
+
end
|
|
255
480
|
end
|
|
256
481
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require_relative '../../test_helper'
|
|
2
|
+
|
|
3
|
+
describe OdeonUk do
|
|
4
|
+
describe '.configuration' do
|
|
5
|
+
describe '.method' do
|
|
6
|
+
it 'sets default value' do
|
|
7
|
+
OdeonUk.configuration.method.must_equal(:html)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe '.configure' do
|
|
13
|
+
before do
|
|
14
|
+
OdeonUk.configure do |config|
|
|
15
|
+
config.method = :api
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
after do
|
|
20
|
+
OdeonUk.configure do |config|
|
|
21
|
+
config.method = :html
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'sets the small words for the gem to downcase' do
|
|
26
|
+
OdeonUk.configuration.method.must_equal(:api)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|