picturehouse_uk 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -1
  3. data/CHANGELOG.md +18 -0
  4. data/README.md +7 -10
  5. data/Rakefile +20 -7
  6. data/lib/picturehouse_uk.rb +4 -1
  7. data/lib/picturehouse_uk/cinema.rb +51 -100
  8. data/lib/picturehouse_uk/film.rb +22 -8
  9. data/lib/picturehouse_uk/internal/address_parser.rb +72 -0
  10. data/lib/picturehouse_uk/internal/cinema_page.rb +35 -0
  11. data/lib/picturehouse_uk/internal/film_with_screenings_parser.rb +87 -37
  12. data/lib/picturehouse_uk/internal/title_sanitizer.rb +49 -0
  13. data/lib/picturehouse_uk/internal/website.rb +39 -0
  14. data/lib/picturehouse_uk/screening.rb +63 -19
  15. data/lib/picturehouse_uk/version.rb +2 -2
  16. data/picturehouse_uk.gemspec +11 -11
  17. data/test/fixture_updater.rb +43 -0
  18. data/test/fixtures/address-fragments/duke-of-yorks.html +39 -0
  19. data/test/fixtures/address-fragments/hackney-picturehouse.html +12 -0
  20. data/test/fixtures/cinema/Duke_Of_Yorks.html +4370 -0
  21. data/test/fixtures/cinema/Duke_Of_Yorks/film_last.html +45 -0
  22. data/test/fixtures/cinema/Duke_Of_Yorks/film_second.html +37 -0
  23. data/test/fixtures/{abbeygate-contact-us.html → contact_us/Duke_Of_Yorks.html} +635 -156
  24. data/test/fixtures/{dukes-at-komedia-contact-us.html → contact_us/Dukes_At_Komedia.html} +582 -98
  25. data/test/fixtures/{picturehouses-homepage.html → home.html} +642 -146
  26. data/test/lib/picturehouse_uk/cinema_test.rb +127 -307
  27. data/test/lib/picturehouse_uk/film_test.rb +65 -16
  28. data/test/lib/picturehouse_uk/internal/address_parser_test.rb +55 -0
  29. data/test/lib/picturehouse_uk/internal/cinema_page_test.rb +51 -0
  30. data/test/lib/picturehouse_uk/internal/film_with_screenings_parser_test.rb +44 -151
  31. data/test/lib/picturehouse_uk/internal/title_sanitizer_test.rb +131 -0
  32. data/test/lib/picturehouse_uk/internal/website_test.rb +64 -0
  33. data/test/lib/picturehouse_uk/screening_test.rb +149 -21
  34. data/test/live/integration_test.rb +68 -0
  35. data/test/test_helper.rb +3 -1
  36. metadata +40 -43
  37. data/test/fixtures/dukes-at-komedia-cinema.html +0 -7148
  38. data/test/fixtures/film_node/blue-jasmine-done.html +0 -53
  39. data/test/fixtures/film_node/blue-jasmine-future.html +0 -55
  40. data/test/fixtures/film_node/bolshoi-spartacus.html +0 -26
  41. data/test/fixtures/film_node/captain-phillips-with-silver-screen-and-subtitles.html +0 -103
  42. data/test/fixtures/film_node/fifth-estate-with-big-scream.html +0 -73
  43. data/test/fixtures/film_node/london-film-festival-with-toddler-time.html +0 -46
  44. data/test/fixtures/film_node/met-encore-rusalka-as-live.html +0 -26
  45. data/test/fixtures/film_node/nt-encore-hamlet.html +0 -26
  46. data/test/fixtures/film_node/planes-with-kids-club.html +0 -77
  47. data/test/fixtures/film_node/royal-opera-house-don-quixote.html +0 -26
  48. data/test/fixtures/film_node/rsc-encore-richard-ii.html +0 -28
  49. data/test/fixtures/film_node/rsc-live-richard-ii.html +0 -41
  50. data/test/fixtures/film_node/rsc-live-the-two-gentlemen-of-verona-zero-cert.html +0 -19
  51. data/test/fixtures/hackney-contact-us.html +0 -998
@@ -1,47 +1,69 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
3
  describe PicturehouseUk::Cinema do
4
+ let(:described_class) { PicturehouseUk::Cinema }
5
+ let(:website) { MockWebsite.new }
4
6
 
5
- before { WebMock.disable_net_connect! }
7
+ before do
8
+ WebMock.disable_net_connect!
9
+ end
6
10
 
7
11
  describe '.all' do
8
- subject { PicturehouseUk::Cinema.all }
9
-
10
- before do
11
- homepage_body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'picturehouses-homepage.html') )
12
- stub_request(:get, 'http://www.picturehouses.co.uk/').to_return( status: 200, body: homepage_body, headers: {} )
13
- end
12
+ subject { described_class.all }
14
13
 
15
- it 'returns an Array of PicturehouseUk::Cinemas' do
16
- subject.must_be_instance_of(Array)
17
- subject.each do |value|
18
- value.must_be_instance_of(PicturehouseUk::Cinema)
14
+ it 'returns an Array of CineworldUK::Cinemas' do
15
+ PicturehouseUk::Internal::Website.stub :new, website do
16
+ subject.must_be_instance_of(Array)
17
+ subject.each do |value|
18
+ value.must_be_instance_of(PicturehouseUk::Cinema)
19
+ end
19
20
  end
20
21
  end
21
22
 
22
23
  it 'returns the correctly sized array' do
23
- subject.size.must_equal 21
24
+ PicturehouseUk::Internal::Website.stub :new, website do
25
+ subject.size.must_equal 22
26
+ end
24
27
  end
25
28
 
26
29
  it 'returns the right cinemas' do
27
- subject.first.name.must_equal 'Clapham Picturehouse'
28
- subject.last.name.must_equal 'City Screen Picturehouse'
30
+ PicturehouseUk::Internal::Website.stub :new, website do
31
+ subject.first.name.must_equal 'Clapham Picturehouse'
32
+ subject.last.name.must_equal 'City Screen Picturehouse'
33
+ end
29
34
  end
30
35
  end
31
36
 
32
37
  describe '.find(id)' do
33
- let(:id) { 'Dukes_At_Komedia' }
38
+ subject { described_class.find(id) }
39
+
40
+ let(:id) { 'Duke_Of_Yorks' }
41
+
42
+ it 'returns a cinema' do
43
+ PicturehouseUk::Internal::Website.stub :new, website do
44
+ subject.must_be_instance_of(PicturehouseUk::Cinema)
34
45
 
35
- subject { PicturehouseUk::Cinema.find(id) }
46
+ subject.id.must_equal id
47
+ subject.brand.must_equal 'Picturehouse'
48
+ subject.name.must_equal "Duke of York's Picturehouse"
49
+ subject.slug.must_equal 'duke-of-yorks-picturehouse'
50
+ subject.url.must_equal "http://www.picturehouses.co.uk/cinema/#{id}/"
51
+ end
52
+ end
53
+ end
36
54
 
37
- before do
38
- homepage_body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'picturehouses-homepage.html') )
39
- stub_request(:get, 'http://www.picturehouses.co.uk/').to_return( status: 200, body: homepage_body, headers: {} )
55
+ describe '.new(options)' do
56
+ let(:options) do
57
+ {
58
+ id: 'Dukes_At_Komedia',
59
+ name: "Duke's At Komedia",
60
+ url: '/cinema/Dukes_At_Komedia/'
61
+ }
40
62
  end
41
63
 
42
- it 'returns a cinema' do
43
- subject.must_be_instance_of(PicturehouseUk::Cinema)
64
+ subject { described_class.new(options) }
44
65
 
66
+ it 'stores id, name, slug and url' do
45
67
  subject.id.must_equal 'Dukes_At_Komedia'
46
68
  subject.brand.must_equal 'Picturehouse'
47
69
  subject.name.must_equal "Duke's At Komedia"
@@ -50,346 +72,144 @@ describe PicturehouseUk::Cinema do
50
72
  end
51
73
  end
52
74
 
53
- describe '.new id, name, url' do
54
- it 'stores id, name, slug and url' do
55
- cinema = PicturehouseUk::Cinema.new 'Dukes_At_Komedia', "Duke's At Komedia", '/cinema/Dukes_At_Komedia/'
56
- cinema.id.must_equal 'Dukes_At_Komedia'
57
- cinema.brand.must_equal 'Picturehouse'
58
- cinema.name.must_equal "Duke's At Komedia"
59
- cinema.slug.must_equal 'dukes-at-komedia'
60
- cinema.url.must_equal 'http://www.picturehouses.co.uk/cinema/Dukes_At_Komedia/'
75
+ describe 'integration-y address tests' do
76
+ let(:options) do
77
+ {
78
+ id: 'Dukes_At_Komedia',
79
+ name: "Duke's At Komedia",
80
+ url: '/cinema/Dukes_At_Komedia/'
81
+ }
61
82
  end
62
- end
63
-
64
- describe '#adr' do
65
- subject { cinema.adr }
66
83
 
67
- describe '(abbeygate)' do
68
- let(:cinema) { PicturehouseUk::Cinema.new('Abbeygate_Picturehouse', 'Abbeygate Picturehouse', '/cinema/Abbeygate_Picturehouse/') }
69
-
70
- before do
71
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'abbeygate-contact-us.html') )
72
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Abbeygate_Picturehouse/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
73
- end
74
-
75
- it 'returns a Hash' do
76
- subject.must_be_instance_of Hash
77
- end
84
+ describe '#adr' do
85
+ subject { described_class.new(options).adr }
78
86
 
79
87
  it 'returns address hash' do
80
- subject.must_equal({
81
- :street_address=>"4 Hatter Street",
82
- :extended_address=>nil,
83
- :locality=>"Bury St Edmunds",
84
- :postal_code=>"IP33 1NE",
85
- :country=>"United Kingdom"
86
- })
88
+ PicturehouseUk::Internal::Website.stub :new, website do
89
+ subject.must_equal(
90
+ street_address: '44-47 Gardner Street',
91
+ extended_address: 'North Laine',
92
+ locality: 'Brighton',
93
+ postal_code: 'BN1 1UN',
94
+ country: 'United Kingdom'
95
+ )
96
+ end
87
97
  end
88
98
  end
89
99
 
90
- describe '(hackney)' do
91
- let(:cinema) { PicturehouseUk::Cinema.new('Hackney_Picturehouse', 'Hackney Picturehouse', '/cinema/Hackney_Picturehouse/') }
92
-
93
- before do
94
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'hackney-contact-us.html') )
95
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Hackney_Picturehouse/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
96
- end
100
+ describe '#street_address' do
101
+ subject { described_class.new(options).street_address }
97
102
 
98
- it 'returns address hash' do
99
- subject.must_equal({
100
- :street_address=>"270 Mare Street",
101
- :extended_address=>nil,
102
- :locality=>"London",
103
- :postal_code=>"E8 1HE",
104
- :country=>"United Kingdom"
105
- })
103
+ it 'returns first line of address' do
104
+ PicturehouseUk::Internal::Website.stub :new, website do
105
+ subject.must_equal('44-47 Gardner Street')
106
+ end
106
107
  end
107
108
  end
108
109
 
109
- describe '(komedia)' do
110
- let(:cinema) { PicturehouseUk::Cinema.new('Dukes_At_Komedia', "Duke's At Komedia", '/cinema/Dukes_At_Komedia/') }
110
+ describe '#extended_address' do
111
+ subject { described_class.new(options).extended_address }
111
112
 
112
- before do
113
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'dukes-at-komedia-contact-us.html') )
114
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Dukes_At_Komedia/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
115
- end
116
-
117
- it 'returns address hash' do
118
- subject.must_equal({
119
- :street_address=>"44-47 Gardner Street",
120
- :extended_address=>"North Laine",
121
- :locality=>"Brighton",
122
- :postal_code=>"BN1 1UN",
123
- :country=>"United Kingdom"
124
- })
113
+ it 'returns second line of address' do
114
+ PicturehouseUk::Internal::Website.stub :new, website do
115
+ subject.must_equal('North Laine')
116
+ end
125
117
  end
126
118
  end
127
- end
128
-
129
- describe '#extended_address' do
130
- subject { cinema.extended_address }
131
119
 
132
- describe '(abbeygate)' do
133
- let(:cinema) { PicturehouseUk::Cinema.new('Abbeygate_Picturehouse', 'Abbeygate Picturehouse', '/cinema/Abbeygate_Picturehouse/') }
120
+ describe '#locality' do
121
+ subject { described_class.new(options).locality }
134
122
 
135
- before do
136
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'abbeygate-contact-us.html') )
137
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Abbeygate_Picturehouse/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
138
- end
139
-
140
- it 'returns nil when no second line' do
141
- subject.must_be_nil
123
+ it 'returns second line of address' do
124
+ PicturehouseUk::Internal::Website.stub :new, website do
125
+ subject.must_equal('Brighton')
126
+ end
142
127
  end
143
128
  end
144
129
 
145
- describe '(hackney)' do
146
- let(:cinema) { PicturehouseUk::Cinema.new('Hackney_Picturehouse', 'Hackney Picturehouse', '/cinema/Hackney_Picturehouse/') }
147
-
148
- before do
149
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'hackney-contact-us.html') )
150
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Hackney_Picturehouse/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
151
- end
130
+ describe '#postal_code' do
131
+ subject { described_class.new(options).postal_code }
152
132
 
153
- it 'returns nil when no second line' do
154
- subject.must_be_nil
133
+ it 'returns second line of address' do
134
+ PicturehouseUk::Internal::Website.stub :new, website do
135
+ subject.must_equal('BN1 1UN')
136
+ end
155
137
  end
156
138
  end
157
139
 
158
- describe '(komedia)' do
159
- let(:cinema) { PicturehouseUk::Cinema.new('Dukes_At_Komedia', "Duke's At Komedia", '/cinema/Dukes_At_Komedia/') }
160
-
161
- before do
162
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'dukes-at-komedia-contact-us.html') )
163
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Dukes_At_Komedia/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
164
- end
165
-
166
- it 'returns the second line of the address' do
167
- subject.must_equal 'North Laine'
168
- end
169
- end
170
140
  end
171
141
 
172
142
  describe '#films' do
173
- let(:cinema) { PicturehouseUk::Cinema.new 'Dukes_At_Komedia', "Duke's At Komedia", '/cinema/Dukes_At_Komedia/' }
174
- subject { cinema.films }
175
-
176
- before do
177
- dukes_cinema_body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'dukes-at-komedia-cinema.html') )
178
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Dukes_At_Komedia/').to_return( status: 200, body: dukes_cinema_body, headers: {} )
179
- end
180
-
181
- it 'returns an array of films' do
182
- subject.must_be_instance_of(Array)
183
- subject.each do |item|
184
- item.must_be_instance_of(PicturehouseUk::Film)
185
- end
186
- end
187
-
188
- it 'returns correct number of films' do
189
- subject.count.must_equal 37
190
- end
191
-
192
- it 'returns uniquely named films' do
193
- first_name = subject.first.name
194
- first = subject.first
195
-
196
- subject[1..-1].each { |item| item.name.wont_equal first_name }
197
- subject[1..-1].each { |item| item.wont_equal first }
143
+ let(:options) do
144
+ {
145
+ id: 'Dukes_At_Komedia',
146
+ name: "Duke's At Komedia",
147
+ url: '/cinema/Dukes_At_Komedia/'
148
+ }
198
149
  end
199
150
 
200
- it 'returns film objects with correct names' do
201
- subject.first.name.must_equal 'Blue Jasmine'
202
- subject.last.name.must_equal 'Royal Opera House: Manon Lescaut'
203
- end
204
- end
205
-
206
- describe '#full_name' do
207
- subject { cinema.full_name }
208
-
209
- describe '(abbeygate)' do
210
- let(:cinema) { PicturehouseUk::Cinema.new('Abbeygate_Picturehouse', 'Abbeygate Picturehouse', '/cinema/Abbeygate_Picturehouse/') }
211
-
212
- before do
213
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'abbeygate-contact-us.html') )
214
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Abbeygate_Picturehouse/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
215
- end
151
+ subject { described_class.new(options).films }
216
152
 
217
- it 'returns the cinema name' do
218
- subject.must_equal 'Abbeygate Picturehouse'
219
- end
220
- end
221
-
222
- describe '(komedia)' do
223
- let(:cinema) { PicturehouseUk::Cinema.new('Dukes_At_Komedia', "Duke's At Komedia", '/cinema/Dukes_At_Komedia/') }
224
-
225
- before do
226
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'dukes-at-komedia-contact-us.html') )
227
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Dukes_At_Komedia/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
228
- end
229
-
230
- it 'returns the cinema name' do
231
- subject.must_equal "Duke's At Komedia"
153
+ it 'calls out to Film object' do
154
+ PicturehouseUk::Film.stub :at, [:film] do
155
+ subject.must_equal([:film])
232
156
  end
233
157
  end
234
158
  end
235
159
 
236
- describe '#locality' do
237
- subject { cinema.locality }
238
-
239
- describe '(abbeygate)' do
240
- let(:cinema) { PicturehouseUk::Cinema.new('Abbeygate_Picturehouse', 'Abbeygate Picturehouse', '/cinema/Abbeygate_Picturehouse/') }
241
-
242
- before do
243
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'abbeygate-contact-us.html') )
244
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Abbeygate_Picturehouse/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
245
- end
246
-
247
- it 'returns the town' do
248
- subject.must_equal 'Bury St Edmunds'
249
- end
250
- end
251
-
252
- describe '(hackney)' do
253
- let(:cinema) { PicturehouseUk::Cinema.new('Hackney_Picturehouse', 'Hackney Picturehouse', '/cinema/Hackney_Picturehouse/') }
254
-
255
- before do
256
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'hackney-contact-us.html') )
257
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Hackney_Picturehouse/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
258
- end
259
-
260
- it 'returns the town' do
261
- subject.must_equal 'London'
262
- end
160
+ describe '#full_name' do
161
+ let(:options) do
162
+ {
163
+ id: 'Dukes_At_Komedia',
164
+ name: "Duke's At Komedia",
165
+ url: '/cinema/Dukes_At_Komedia/'
166
+ }
263
167
  end
264
168
 
265
- describe '(komedia)' do
266
- let(:cinema) { PicturehouseUk::Cinema.new('Dukes_At_Komedia', "Duke's At Komedia", '/cinema/Dukes_At_Komedia/') }
267
-
268
- before do
269
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'dukes-at-komedia-contact-us.html') )
270
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Dukes_At_Komedia/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
271
- end
169
+ subject { described_class.new(options).full_name }
272
170
 
273
- it 'returns the town' do
274
- subject.must_equal 'Brighton'
275
- end
171
+ it 'returns the cinema name' do
172
+ subject.must_equal "Duke's At Komedia"
276
173
  end
277
174
  end
278
175
 
279
- describe '#postal_code' do
280
- subject { cinema.postal_code }
281
-
282
- describe '(abbeygate)' do
283
- let(:cinema) { PicturehouseUk::Cinema.new('Abbeygate_Picturehouse', 'Abbeygate Picturehouse', '/cinema/Abbeygate_Picturehouse/') }
284
-
285
- before do
286
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'abbeygate-contact-us.html') )
287
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Abbeygate_Picturehouse/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
288
- end
289
-
290
- it 'returns the post code' do
291
- subject.must_equal 'IP33 1NE'
292
- end
293
- end
294
-
295
- describe '(hackney)' do
296
- let(:cinema) { PicturehouseUk::Cinema.new('Hackney_Picturehouse', 'Hackney Picturehouse', '/cinema/Hackney_Picturehouse/') }
297
-
298
- before do
299
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'hackney-contact-us.html') )
300
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Hackney_Picturehouse/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
301
- end
302
-
303
- it 'returns the post code' do
304
- subject.must_equal 'E8 1HE'
305
- end
176
+ describe '#screenings' do
177
+ let(:options) do
178
+ {
179
+ id: 'Dukes_At_Komedia',
180
+ name: "Duke's At Komedia",
181
+ url: '/cinema/Dukes_At_Komedia/'
182
+ }
306
183
  end
307
184
 
308
- describe '(komedia)' do
309
- let(:cinema) { PicturehouseUk::Cinema.new('Dukes_At_Komedia', "Duke's At Komedia", '/cinema/Dukes_At_Komedia/') }
310
-
311
- before do
312
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'dukes-at-komedia-contact-us.html') )
313
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Dukes_At_Komedia/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
314
- end
185
+ subject { described_class.new(options).screenings }
315
186
 
316
- it 'returns the post code' do
317
- subject.must_equal 'BN1 1UN'
187
+ it 'calls out to Screening object' do
188
+ PicturehouseUk::Screening.stub :at, [:screening] do
189
+ subject.must_equal([:screening])
318
190
  end
319
191
  end
320
192
  end
321
193
 
322
- describe '#screenings' do
323
- let(:cinema) { PicturehouseUk::Cinema.new('Dukes_At_Komedia', "Duke's At Komedia", '/cinema/Dukes_At_Komedia/') }
324
- subject { cinema.screenings }
325
-
326
- before do
327
- dukes_cinema_body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'dukes-at-komedia-cinema.html') )
328
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Dukes_At_Komedia/').to_return( status: 200, body: dukes_cinema_body, headers: {} )
329
- end
330
-
331
- it 'returns an array of screenings' do
332
- subject.must_be_instance_of(Array)
333
- subject.each do |item|
334
- item.must_be_instance_of(PicturehouseUk::Screening)
335
- end
336
- end
194
+ private
337
195
 
338
- it 'returns screening objects with correct film names' do
339
- subject.first.film_name.must_equal 'Blue Jasmine'
340
- subject.last.film_name.must_equal 'Royal Opera House: Manon Lescaut'
196
+ class MockWebsite
197
+ def home
198
+ read_file('../../../fixtures/home.html')
341
199
  end
342
200
 
343
- it 'returns screening objects with correct cinema name' do
344
- subject.each { |s| s.cinema_name.must_equal "Duke's At Komedia" }
201
+ def cinema(filename)
202
+ read_file("../../../fixtures/cinema/#{filename}.html")
345
203
  end
346
204
 
347
- it 'returns screening objects with correct UTC times' do
348
- subject.first.when.must_equal Time.utc(2013, 10, 14, 20, 0, 0)
349
- subject.last.when.must_equal Time.utc(2014, 6, 24, 17, 45, 0)
205
+ def contact_us(filename)
206
+ read_file("../../../fixtures/contact_us/#{filename}.html")
350
207
  end
351
- end
352
208
 
353
- describe '#street_address' do
354
- subject { cinema.street_address }
355
-
356
- describe '(abbeygate)' do
357
- let(:cinema) { PicturehouseUk::Cinema.new('Abbeygate_Picturehouse', 'Abbeygate Picturehouse', '/cinema/Abbeygate_Picturehouse/') }
358
-
359
- before do
360
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'abbeygate-contact-us.html') )
361
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Abbeygate_Picturehouse/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
362
- end
209
+ private
363
210
 
364
- it 'returns the street address' do
365
- subject.must_equal '4 Hatter Street'
366
- end
367
- end
368
-
369
- describe '(hackney)' do
370
- let(:cinema) { PicturehouseUk::Cinema.new('Hackney_Picturehouse', 'Hackney Picturehouse', '/cinema/Hackney_Picturehouse/') }
371
-
372
- before do
373
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'hackney-contact-us.html') )
374
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Hackney_Picturehouse/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
375
- end
376
-
377
- it 'returns the street address' do
378
- subject.must_equal '270 Mare Street'
379
- end
380
- end
381
-
382
- describe '(komedia)' do
383
- let(:cinema) { PicturehouseUk::Cinema.new('Dukes_At_Komedia', "Duke's At Komedia", '/cinema/Dukes_At_Komedia/') }
384
-
385
- before do
386
- body = File.read( File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'dukes-at-komedia-contact-us.html') )
387
- stub_request(:get, 'http://www.picturehouses.co.uk/cinema/Dukes_At_Komedia/Hires_Info/Contact_Us/').to_return( status: 200, body: body, headers: {} )
388
- end
389
-
390
- it 'returns the street address' do
391
- subject.must_equal '44-47 Gardner Street'
392
- end
211
+ def read_file(filepath)
212
+ File.read(File.expand_path(filepath, __FILE__))
393
213
  end
394
214
  end
395
215
  end