odeon_uk 1.1.5 → 2.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 +1 -1
- data/CHANGELOG.md +8 -1
- data/README.md +1 -0
- data/Rakefile +13 -9
- data/lib/odeon_uk/cinema.rb +14 -42
- data/lib/odeon_uk/film.rb +23 -5
- data/lib/odeon_uk/internal/film_with_screenings_parser.rb +133 -46
- data/lib/odeon_uk/internal/showtimes_page.rb +36 -0
- data/lib/odeon_uk/internal/title_sanitizer.rb +49 -0
- data/lib/odeon_uk/internal/website.rb +36 -0
- data/lib/odeon_uk/screening.rb +56 -22
- data/lib/odeon_uk/version.rb +2 -2
- data/lib/odeon_uk.rb +4 -2
- data/odeon_uk.gemspec +0 -1
- data/test/fixture_updater.rb +72 -0
- data/test/fixtures/{odeon-bfi-imax.html → cinema/bfi_imax.html} +988 -1130
- data/test/fixtures/{odeon-brighton.html → cinema/brighton.html} +1035 -761
- data/test/fixtures/{odeon-london-leicester-square.html → cinema/leicester_square.html} +470 -766
- data/test/fixtures/showtimes/brighton/film_first.html +92 -0
- data/test/fixtures/showtimes/brighton/film_last.html +100 -0
- data/test/fixtures/showtimes/brighton.html +2071 -0
- data/test/fixtures/showtimes/liverpool_one/film_first_dbox.html +188 -0
- data/test/fixtures/showtimes/manchester/film_first_imax.html +182 -0
- data/test/fixtures/{odeon-sitemap.html → sitemap.html} +572 -444
- data/test/lib/odeon_uk/cinema_test.rb +129 -231
- data/test/lib/odeon_uk/film_test.rb +50 -3
- data/test/lib/odeon_uk/internal/film_with_screenings_parser_test.rb +79 -123
- data/test/lib/odeon_uk/internal/showtimes_page_test.rb +51 -0
- data/test/lib/odeon_uk/internal/title_sanitizer_test.rb +105 -0
- data/test/lib/odeon_uk/internal/website_test.rb +59 -0
- data/test/lib/odeon_uk/screening_test.rb +66 -32
- metadata +32 -53
- data/test/fixtures/brighton-showtimes/about-time.html +0 -175
- data/test/fixtures/brighton-showtimes/autism-friendly-planes.html +0 -75
- data/test/fixtures/brighton-showtimes/bolshoi-spartacus-live.html +0 -67
- data/test/fixtures/brighton-showtimes/cinemagic-echo-planet.html +0 -67
- data/test/fixtures/brighton-showtimes/globe-on-screen-twelfth-night.html +0 -67
- data/test/fixtures/brighton-showtimes/met-opera-eugene-onegin.html +0 -67
- data/test/fixtures/brighton-showtimes/national-theatre-live-frankenstein.html +0 -78
- data/test/fixtures/brighton-showtimes/nt-live-war-horse.html +0 -67
- data/test/fixtures/brighton-showtimes/royal-opera-house-turandot.html +0 -66
- data/test/fixtures/brighton-showtimes/rsc-richard-ii.html +0 -67
- data/test/fixtures/brighton-showtimes/star-trek-into-darkness-2d.html +0 -83
- data/test/fixtures/brighton-showtimes/ukjff-from-cable-street-to-brick-lane.html +0 -67
- data/test/fixtures/manchester-showtimes/thor-the-dark-world.html +0 -300
- data/test/fixtures/odeon-brighton-showtimes.html +0 -1238
@@ -1,358 +1,256 @@
|
|
1
1
|
require_relative '../../test_helper'
|
2
2
|
|
3
3
|
describe OdeonUk::Cinema do
|
4
|
+
let(:described_class) { OdeonUk::Cinema }
|
4
5
|
|
5
|
-
|
6
|
+
let(:website) { Minitest::Mock.new }
|
7
|
+
|
8
|
+
before do
|
9
|
+
WebMock.disable_net_connect!
|
10
|
+
end
|
6
11
|
|
7
12
|
describe '.all' do
|
8
|
-
subject {
|
13
|
+
subject { described_class.all }
|
9
14
|
|
10
15
|
before do
|
11
|
-
|
12
|
-
stub_request(:get, 'http://www.odeon.co.uk/sitemap/').to_return( status: 200, body: sitemap_body, headers: {} )
|
16
|
+
website.expect(:sitemap, sitemap_html)
|
13
17
|
end
|
14
18
|
|
15
|
-
it 'returns an Array of
|
16
|
-
|
17
|
-
|
18
|
-
value
|
19
|
+
it 'returns an Array of OdeonUk::Cinemas' do
|
20
|
+
OdeonUk::Internal::Website.stub :new, website do
|
21
|
+
subject.must_be_instance_of(Array)
|
22
|
+
subject.each do |value|
|
23
|
+
value.must_be_instance_of(described_class)
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
21
27
|
|
22
28
|
it 'returns the correctly sized array' do
|
23
|
-
|
29
|
+
OdeonUk::Internal::Website.stub :new, website do
|
30
|
+
subject.size.must_equal 115
|
31
|
+
end
|
24
32
|
end
|
25
33
|
end
|
26
34
|
|
27
35
|
describe '.find(id)' do
|
28
|
-
subject {
|
29
|
-
|
30
|
-
before do
|
31
|
-
sitemap_body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'odeon-sitemap.html') )
|
32
|
-
stub_request(:get, 'http://www.odeon.co.uk/sitemap/').to_return( status: 200, body: sitemap_body, headers: {} )
|
33
|
-
end
|
36
|
+
subject { described_class.find(id) }
|
34
37
|
|
35
38
|
describe 'Brighton' do
|
36
39
|
let(:id) { 71 }
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
subject.id.must_equal 71
|
42
|
-
subject.brand.must_equal 'Odeon'
|
43
|
-
subject.name.must_equal 'Brighton'
|
44
|
-
subject.slug.must_equal 'brighton'
|
45
|
-
subject.url.must_equal 'http://www.odeon.co.uk/cinemas/brighton/71/'
|
41
|
+
before do
|
42
|
+
website.expect(:sitemap, sitemap_html)
|
43
|
+
# website.expect(:cinemas, cinema_html('brighton'), [71])
|
46
44
|
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe 'Leicester Square' do
|
50
|
-
let(:id) { 105 }
|
51
45
|
|
52
|
-
it 'returns a cinema
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
46
|
+
it 'returns a cinema' do
|
47
|
+
OdeonUk::Internal::Website.stub :new, website do
|
48
|
+
subject.must_be_instance_of(described_class)
|
49
|
+
|
50
|
+
subject.id.must_equal 71
|
51
|
+
subject.brand.must_equal 'Odeon'
|
52
|
+
subject.name.must_equal 'Brighton'
|
53
|
+
subject.slug.must_equal 'brighton'
|
54
|
+
subject.url.must_equal 'http://www.odeon.co.uk/cinemas/brighton/71/'
|
55
|
+
end
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|
63
59
|
|
64
|
-
describe '.new
|
65
|
-
it '
|
66
|
-
cinema = OdeonUk::Cinema.new
|
67
|
-
cinema.id.must_equal
|
68
|
-
cinema.
|
69
|
-
cinema.
|
70
|
-
|
71
|
-
|
60
|
+
describe '.new' do
|
61
|
+
it 'removes "London" name prefix' do
|
62
|
+
cinema = OdeonUk::Cinema.new 79, 'London - Leicester Square', '/cinemas/london_leicester_square/105/'
|
63
|
+
cinema.id.must_equal 79
|
64
|
+
cinema.name.must_equal 'Leicester Square'
|
65
|
+
cinema.slug.must_equal 'leicester-square'
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'removes " - " and replaces it with a colon ": "' do
|
69
|
+
cinema = OdeonUk::Cinema.new 208, 'Whiteleys - The Lounge', '/cinemas/whiteleys_the_lounge/208/'
|
70
|
+
cinema.id.must_equal 208
|
71
|
+
cinema.name.must_equal 'Whiteleys: The Lounge'
|
72
|
+
cinema.slug.must_equal 'whiteleys-the-lounge'
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
76
|
describe '#adr' do
|
76
|
-
|
77
|
-
let(:cinema) { OdeonUk::Cinema.new('71', 'Brighton', '/cinemas/brighton/71/') }
|
78
|
-
subject { cinema.adr }
|
77
|
+
subject { cinema.adr }
|
79
78
|
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
describe '(brighton)' do
|
80
|
+
let(:cinema) do
|
81
|
+
described_class.new(71, 'Brighton', '/cinemas/brighton/71/')
|
83
82
|
end
|
84
83
|
|
85
|
-
|
86
|
-
|
84
|
+
before do
|
85
|
+
website.expect(:cinema, cinema_html('brighton'), [71])
|
87
86
|
end
|
88
87
|
|
89
|
-
it 'returns address hash' do
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
88
|
+
it 'returns the address hash' do
|
89
|
+
OdeonUk::Internal::Website.stub :new, website do
|
90
|
+
subject.must_equal(
|
91
|
+
street_address: 'Kingswest',
|
92
|
+
locality: 'Brighton',
|
93
|
+
postal_code: 'BN1 2RE',
|
94
|
+
country: 'United Kingdom'
|
95
|
+
)
|
96
|
+
end
|
96
97
|
end
|
97
98
|
end
|
98
99
|
end
|
99
100
|
|
100
101
|
describe '#films' do
|
101
|
-
let(:cinema) { OdeonUk::Cinema.new('71', 'Brighton & Hove', '/cinemas/brighton/71/') }
|
102
102
|
subject { cinema.films }
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
stub_request(:get, 'http://www.odeon.co.uk/showtimes/week/71?siteId=71').to_return( status: 200, body: brighton_screenings_body, headers: {} )
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'returns an array of films' do
|
110
|
-
subject.must_be_instance_of(Array)
|
111
|
-
subject.each do |item|
|
112
|
-
item.must_be_instance_of(OdeonUk::Film)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'returns correct number of films' do
|
117
|
-
subject.count.must_equal 16
|
104
|
+
let(:cinema) do
|
105
|
+
described_class.new(71, 'Brighton', '/cinemas/brighton/71/')
|
118
106
|
end
|
119
107
|
|
120
|
-
it '
|
121
|
-
|
122
|
-
subject.
|
123
|
-
if index != i
|
124
|
-
item.name.wont_equal jtem.name
|
125
|
-
item.wont_equal jtem
|
126
|
-
end
|
127
|
-
end
|
108
|
+
it 'calls out to Screening object' do
|
109
|
+
OdeonUk::Film.stub :at, [:film] do
|
110
|
+
subject.must_equal([:film])
|
128
111
|
end
|
129
112
|
end
|
130
|
-
|
131
|
-
it 'returns film objects with correct names' do
|
132
|
-
subject.first.name.must_equal 'About Time'
|
133
|
-
subject.last.name.must_equal 'White House Down'
|
134
|
-
end
|
135
113
|
end
|
136
114
|
|
137
115
|
describe '#full_name' do
|
138
116
|
subject { cinema.full_name }
|
139
117
|
|
140
118
|
describe 'simple name (brighton)' do
|
141
|
-
let(:cinema)
|
119
|
+
let(:cinema) do
|
120
|
+
OdeonUk::Cinema.new('71', 'Brighton', '/cinemas/brighton/71/')
|
121
|
+
end
|
142
122
|
|
143
123
|
before do
|
144
|
-
|
145
|
-
stub_request(:get, 'http://www.odeon.co.uk/cinemas/brighton/71/').to_return( status: 200, body: brighton_cinema_body, headers: {} )
|
124
|
+
website.expect(:cinema, cinema_html('brighton'), [71])
|
146
125
|
end
|
147
126
|
|
148
127
|
it 'returns the brand in the name' do
|
149
|
-
|
128
|
+
OdeonUk::Internal::Website.stub :new, website do
|
129
|
+
subject.must_equal 'Odeon Brighton'
|
130
|
+
end
|
150
131
|
end
|
151
132
|
end
|
152
133
|
end
|
153
134
|
|
154
135
|
describe '#locality' do
|
155
|
-
|
156
|
-
let(:cinema) { OdeonUk::Cinema.new('71', 'Brighton', '/cinemas/brighton/71/') }
|
157
|
-
subject { cinema.locality }
|
136
|
+
subject { cinema.locality }
|
158
137
|
|
159
|
-
|
160
|
-
|
161
|
-
|
138
|
+
describe 'short address' do
|
139
|
+
let(:cinema) do
|
140
|
+
OdeonUk::Cinema.new('71', 'Brighton', '/cinemas/brighton/71/')
|
162
141
|
end
|
163
142
|
|
164
|
-
|
165
|
-
|
143
|
+
before do
|
144
|
+
website.expect(:cinema, cinema_html('brighton'), [71])
|
166
145
|
end
|
167
146
|
|
168
147
|
it 'returns town name' do
|
169
|
-
|
148
|
+
OdeonUk::Internal::Website.stub :new, website do
|
149
|
+
subject.must_equal 'Brighton'
|
150
|
+
end
|
170
151
|
end
|
171
152
|
end
|
172
153
|
end
|
173
154
|
|
174
155
|
describe '#postal_code' do
|
175
|
-
|
176
|
-
let(:cinema) { OdeonUk::Cinema.new('71', 'Brighton', '/cinemas/brighton/71/') }
|
177
|
-
subject { cinema.postal_code }
|
156
|
+
subject { cinema.postal_code }
|
178
157
|
|
179
|
-
|
180
|
-
|
181
|
-
|
158
|
+
describe 'short address' do
|
159
|
+
let(:cinema) do
|
160
|
+
OdeonUk::Cinema.new('71', 'Brighton', '/cinemas/brighton/71/')
|
182
161
|
end
|
183
162
|
|
184
|
-
|
185
|
-
|
163
|
+
before do
|
164
|
+
website.expect(:cinema, cinema_html('brighton'), [71])
|
186
165
|
end
|
187
166
|
|
188
167
|
it 'returns the postcode' do
|
189
|
-
|
168
|
+
OdeonUk::Internal::Website.stub :new, website do
|
169
|
+
subject.must_equal 'BN1 2RE'
|
170
|
+
end
|
190
171
|
end
|
191
172
|
end
|
192
173
|
|
193
174
|
describe 'short address (London)' do
|
194
|
-
let(:cinema)
|
195
|
-
|
175
|
+
let(:cinema) do
|
176
|
+
OdeonUk::Cinema.new('211', 'BFI Imax', '/cinemas/bfi_imax/211/')
|
177
|
+
end
|
196
178
|
|
197
179
|
before do
|
198
|
-
|
199
|
-
stub_request(:get, 'http://www.odeon.co.uk/cinemas/bfi_imax/211/').to_return( status: 200, body: body, headers: {} )
|
180
|
+
website.expect(:cinema, cinema_html('bfi_imax'), [211])
|
200
181
|
end
|
201
182
|
|
202
183
|
it 'returns the postcode' do
|
203
|
-
|
184
|
+
OdeonUk::Internal::Website.stub :new, website do
|
185
|
+
subject.must_equal 'SE1 8XR'
|
186
|
+
end
|
204
187
|
end
|
205
188
|
end
|
206
189
|
|
207
190
|
describe 'short address (extra London Postcode)' do
|
208
|
-
let(:cinema)
|
209
|
-
|
191
|
+
let(:cinema) do
|
192
|
+
OdeonUk::Cinema.new('105',
|
193
|
+
'Leicester Square',
|
194
|
+
'/cinemas/london_leicester_square/105/')
|
195
|
+
end
|
210
196
|
|
211
197
|
before do
|
212
|
-
|
213
|
-
stub_request(:get, 'http://www.odeon.co.uk/cinemas/london_leicester_square/105/').to_return( status: 200, body: body, headers: {} )
|
198
|
+
website.expect(:cinema, cinema_html('leicester_square'), [105])
|
214
199
|
end
|
215
200
|
|
216
201
|
it 'returns the postcode' do
|
217
|
-
|
202
|
+
OdeonUk::Internal::Website.stub :new, website do
|
203
|
+
subject.must_equal 'WC2H 7LQ'
|
204
|
+
end
|
218
205
|
end
|
219
206
|
end
|
220
207
|
end
|
221
208
|
|
222
209
|
describe '#screenings' do
|
223
|
-
let(:cinema) { OdeonUk::Cinema.new('71', 'Brighton', '/cinemas/brighton/71/') }
|
224
210
|
subject { cinema.screenings }
|
225
211
|
|
226
|
-
|
227
|
-
|
228
|
-
stub_request(:get, 'http://www.odeon.co.uk/showtimes/week/71?siteId=71').to_return( status: 200, body: brighton_screenings_body, headers: {} )
|
212
|
+
let(:cinema) do
|
213
|
+
described_class.new(71, 'Brighton', '/cinemas/brighton/71/')
|
229
214
|
end
|
230
215
|
|
231
|
-
it '
|
232
|
-
|
233
|
-
|
234
|
-
item.must_be_instance_of(OdeonUk::Screening)
|
216
|
+
it 'calls out to Screening object' do
|
217
|
+
OdeonUk::Screening.stub :at, [:screening] do
|
218
|
+
subject.must_equal([:screening])
|
235
219
|
end
|
236
220
|
end
|
237
|
-
|
238
|
-
it 'returns screening objects with correct film names' do
|
239
|
-
subject.first.film_name.must_equal 'About Time'
|
240
|
-
subject.last.film_name.must_equal 'White House Down'
|
241
|
-
end
|
242
|
-
|
243
|
-
it 'returns screening objects with correct cinema name' do
|
244
|
-
subject.each { |s| s.cinema_name.must_equal 'Brighton' }
|
245
|
-
end
|
246
|
-
|
247
|
-
it 'returns screening objects with correct UTC times' do
|
248
|
-
subject.first.when.must_equal Time.utc(2013, 9, 14, 11, 20, 0)
|
249
|
-
subject.last.when.must_equal Time.utc(2013, 9, 19, 19, 40, 0)
|
250
|
-
end
|
251
|
-
|
252
|
-
it 'returns screening objects with correct variants' do
|
253
|
-
subject.each do |screening|
|
254
|
-
screening.variant.wont_be_nil
|
255
|
-
screening.variant.must_match /[23]D/
|
256
|
-
end
|
257
|
-
|
258
|
-
subject.first.variant.must_equal '2D'
|
259
|
-
subject.last.variant.must_equal '2D'
|
260
|
-
end
|
261
|
-
|
262
|
-
it 'returns screening objects with booking urls' do
|
263
|
-
subject.each do |screening|
|
264
|
-
screening.booking_url.wont_be_nil
|
265
|
-
screening.booking_url.must_be_instance_of String
|
266
|
-
end
|
267
|
-
|
268
|
-
subject.first.booking_url.must_equal 'http://www.odeon.co.uk/booking/init/MUZFRjAwMDAwMjNVRFBETVhHIzcxIzE0NDI2/'
|
269
|
-
subject.last.booking_url.must_equal 'http://www.odeon.co.uk/booking/init/RjhFRjAwMDAwMjNVRFBETVhHIzcxIzEzOTY3/'
|
270
|
-
end
|
271
221
|
end
|
272
222
|
|
273
|
-
describe '#
|
274
|
-
|
275
|
-
subject { cinema.screenings_of(film_or_string) }
|
276
|
-
|
277
|
-
before do
|
278
|
-
brighton_screenings_body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'odeon-brighton-showtimes.html') )
|
279
|
-
stub_request(:get, 'http://www.odeon.co.uk/showtimes/week/71?siteId=71').to_return( status: 200, body: brighton_screenings_body, headers: {} )
|
280
|
-
end
|
281
|
-
|
282
|
-
describe 'passed string' do
|
283
|
-
let(:film_or_string) { 'About Time' }
|
284
|
-
|
285
|
-
it 'returns an array of screenings' do
|
286
|
-
subject.must_be_instance_of(Array)
|
287
|
-
subject.each do |item|
|
288
|
-
item.must_be_instance_of(OdeonUk::Screening)
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
it 'returns the correct number of screening objects' do
|
293
|
-
subject.count.must_equal 21
|
294
|
-
end
|
295
|
-
|
296
|
-
it 'returns screening objects with correct film names' do
|
297
|
-
subject.each { |s| s.film_name.must_equal 'About Time' }
|
298
|
-
end
|
223
|
+
describe '#street_address' do
|
224
|
+
subject { cinema.street_address }
|
299
225
|
|
300
|
-
|
301
|
-
|
226
|
+
describe 'short address' do
|
227
|
+
let(:cinema) do
|
228
|
+
OdeonUk::Cinema.new('71', 'Brighton', '/cinemas/brighton/71/')
|
302
229
|
end
|
303
230
|
|
304
|
-
|
305
|
-
|
306
|
-
subject.last.when.must_equal Time.utc(2013, 9, 19, 19, 30, 0)
|
231
|
+
before do
|
232
|
+
website.expect(:cinema, cinema_html('brighton'), [71])
|
307
233
|
end
|
308
|
-
end
|
309
234
|
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
it 'returns an array of screenings' do
|
314
|
-
subject.must_be_instance_of(Array)
|
315
|
-
subject.each do |item|
|
316
|
-
item.must_be_instance_of(OdeonUk::Screening)
|
235
|
+
it 'returns first line of address' do
|
236
|
+
OdeonUk::Internal::Website.stub :new, website do
|
237
|
+
subject.must_equal 'Kingswest'
|
317
238
|
end
|
318
239
|
end
|
319
|
-
|
320
|
-
it 'returns the correct number of screening objects' do
|
321
|
-
subject.count.must_equal 21
|
322
|
-
end
|
323
|
-
|
324
|
-
it 'returns screening objects with correct film names' do
|
325
|
-
subject.each { |s| s.film_name.must_equal 'About Time' }
|
326
|
-
end
|
327
|
-
|
328
|
-
it 'returns screening objects with correct cinema name' do
|
329
|
-
subject.each { |s| s.cinema_name.must_equal 'Brighton' }
|
330
|
-
end
|
331
|
-
|
332
|
-
it 'returns screening objects with correct UTC times' do
|
333
|
-
subject.first.when.must_equal Time.utc(2013, 9, 14, 11, 20, 0)
|
334
|
-
subject.last.when.must_equal Time.utc(2013, 9, 19, 19, 30, 0)
|
335
|
-
end
|
336
240
|
end
|
337
241
|
end
|
338
242
|
|
339
|
-
|
340
|
-
describe 'short address' do
|
341
|
-
let(:cinema) { OdeonUk::Cinema.new('71', 'Brighton', '/cinemas/brighton/71/') }
|
342
|
-
subject { cinema.street_address }
|
243
|
+
private
|
343
244
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
end
|
245
|
+
def read_file(filepath)
|
246
|
+
File.read(File.expand_path(filepath, __FILE__))
|
247
|
+
end
|
348
248
|
|
349
|
-
|
350
|
-
|
351
|
-
|
249
|
+
def sitemap_html
|
250
|
+
read_file('../../../fixtures/sitemap.html')
|
251
|
+
end
|
352
252
|
|
353
|
-
|
354
|
-
|
355
|
-
end
|
356
|
-
end
|
253
|
+
def cinema_html(filename)
|
254
|
+
read_file("../../../fixtures/cinema/#{filename}.html")
|
357
255
|
end
|
358
256
|
end
|
@@ -11,7 +11,44 @@ describe OdeonUk::Film do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe '
|
14
|
+
describe '.at(cinema_id)' do # integration
|
15
|
+
let(:website) { Minitest::Mock.new }
|
16
|
+
|
17
|
+
subject { OdeonUk::Film.at(71) }
|
18
|
+
|
19
|
+
before do
|
20
|
+
website.expect(:showtimes, showtimes_html('brighton'), [71])
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns an array of films' do
|
24
|
+
OdeonUk::Internal::Website.stub :new, website do
|
25
|
+
subject.must_be_instance_of(Array)
|
26
|
+
subject.each do |film|
|
27
|
+
film.must_be_instance_of(OdeonUk::Film)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'returns a decent number of films' do
|
33
|
+
OdeonUk::Internal::Website.stub :new, website do
|
34
|
+
subject.count.must_be :>, 15
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'returns uniquely named films' do
|
39
|
+
OdeonUk::Internal::Website.stub :new, website do
|
40
|
+
subject.each_with_index do |item, index|
|
41
|
+
subject.each_with_index do |jtem, i|
|
42
|
+
next if index == i
|
43
|
+
item.name.wont_equal jtem.name
|
44
|
+
item.wont_equal jtem
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'comparable' do
|
15
52
|
it 'includes comparable methods' do
|
16
53
|
film = OdeonUk::Film.new 'AAAA'
|
17
54
|
film.methods.must_include :<
|
@@ -47,7 +84,7 @@ describe OdeonUk::Film do
|
|
47
84
|
it 'retuns only one' do
|
48
85
|
result = [film, otherfilm].uniq
|
49
86
|
result.count.must_equal 1
|
50
|
-
result.must_equal [
|
87
|
+
result.must_equal [OdeonUk::Film.new('AAAA')]
|
51
88
|
end
|
52
89
|
end
|
53
90
|
end
|
@@ -60,7 +97,7 @@ describe OdeonUk::Film do
|
|
60
97
|
let(:otherfilm) { OdeonUk::Film.new 'BBBB' }
|
61
98
|
|
62
99
|
it 'retuns -1' do
|
63
|
-
subject.must_equal
|
100
|
+
subject.must_equal(-1)
|
64
101
|
end
|
65
102
|
end
|
66
103
|
|
@@ -92,4 +129,14 @@ describe OdeonUk::Film do
|
|
92
129
|
end
|
93
130
|
end
|
94
131
|
end
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
def read_file(filepath)
|
136
|
+
File.read(File.expand_path(filepath, __FILE__))
|
137
|
+
end
|
138
|
+
|
139
|
+
def showtimes_html(filename)
|
140
|
+
read_file("../../../fixtures/showtimes/#{filename}.html")
|
141
|
+
end
|
95
142
|
end
|