odeon_uk 2.0.4 → 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/.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
@@ -0,0 +1,149 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
|
3
|
+
describe OdeonUk::Api::Cinema do
|
4
|
+
include ApiFixturesHelper
|
5
|
+
|
6
|
+
let(:described_class) { OdeonUk::Api::Cinema }
|
7
|
+
|
8
|
+
let(:response) { Minitest::Mock.new }
|
9
|
+
|
10
|
+
before do
|
11
|
+
WebMock.disable_net_connect!
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.ids' do
|
15
|
+
subject { described_class.ids }
|
16
|
+
|
17
|
+
before do
|
18
|
+
response.expect(:all_cinemas, parse(all_cinemas_plist))
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'returns an Array of integers' do
|
22
|
+
OdeonUk::Api::Response.stub :new, response do
|
23
|
+
subject.must_be_instance_of(Array)
|
24
|
+
subject.each do |value|
|
25
|
+
value.must_be_instance_of(Fixnum)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns the correctly sized array' do
|
31
|
+
OdeonUk::Api::Response.stub :new, response do
|
32
|
+
subject.size.must_equal 115
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '.new(id)' do
|
38
|
+
subject { described_class.new(id) }
|
39
|
+
|
40
|
+
describe 'Brighton' do
|
41
|
+
let(:id) { 71 }
|
42
|
+
|
43
|
+
it 'returns a cinema' do
|
44
|
+
subject.must_be_instance_of(described_class)
|
45
|
+
subject.id.must_equal(id)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#name' do
|
51
|
+
subject { described_class.new(id).name }
|
52
|
+
|
53
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
54
|
+
|
55
|
+
describe 'Brighton' do
|
56
|
+
let(:id) { 71 }
|
57
|
+
|
58
|
+
it 'returns cinema name' do
|
59
|
+
OdeonUk::Api::Response.stub :new, response do
|
60
|
+
subject.must_equal 'Brighton'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'Leicester Square' do
|
66
|
+
let(:id) { 105 }
|
67
|
+
|
68
|
+
it 'returns cinema name' do
|
69
|
+
OdeonUk::Api::Response.stub :new, response do
|
70
|
+
subject.must_equal 'London - Leicester Square'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#locality' do
|
77
|
+
subject { described_class.new(id).locality }
|
78
|
+
|
79
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
80
|
+
|
81
|
+
describe 'Short Address (Brighton)' do
|
82
|
+
let(:id) { 71 }
|
83
|
+
|
84
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
85
|
+
|
86
|
+
it 'returns town name' do
|
87
|
+
OdeonUk::Api::Response.stub :new, response do
|
88
|
+
subject.must_equal 'Brighton'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#postal_code' do
|
95
|
+
subject { described_class.new(id).postal_code }
|
96
|
+
|
97
|
+
describe 'short address' do
|
98
|
+
let(:id) { 71 }
|
99
|
+
|
100
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
101
|
+
|
102
|
+
it 'returns the postcode' do
|
103
|
+
OdeonUk::Api::Response.stub :new, response do
|
104
|
+
subject.must_equal 'BN1 2RE'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'short address (London)' do
|
110
|
+
let(:id) { 211 }
|
111
|
+
|
112
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
113
|
+
|
114
|
+
it 'returns the postcode' do
|
115
|
+
OdeonUk::Api::Response.stub :new, response do
|
116
|
+
subject.must_equal 'SE1 8XR'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe 'short address (extra London Postcode)' do
|
122
|
+
let(:id) { 105 }
|
123
|
+
|
124
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
125
|
+
|
126
|
+
it 'returns the postcode' do
|
127
|
+
OdeonUk::Api::Response.stub :new, response do
|
128
|
+
subject.must_equal 'WC2H 7LQ'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe '#street_address' do
|
135
|
+
subject { described_class.new(id).street_address }
|
136
|
+
|
137
|
+
describe 'short address' do
|
138
|
+
let(:id) { 71 }
|
139
|
+
|
140
|
+
before { response.expect(:all_cinemas, parse(all_cinemas_plist)) }
|
141
|
+
|
142
|
+
it 'returns first line of address' do
|
143
|
+
OdeonUk::Api::Response.stub :new, response do
|
144
|
+
subject.must_equal 'Kingswest'
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
|
3
|
+
describe OdeonUk::Api::Response do
|
4
|
+
include ApiFixturesHelper
|
5
|
+
|
6
|
+
let(:described_class) { OdeonUk::Api::Response }
|
7
|
+
|
8
|
+
describe '#app_init' do
|
9
|
+
subject { described_class.new.app_init }
|
10
|
+
|
11
|
+
before { stub_post('app-init', nil, app_init_plist) }
|
12
|
+
|
13
|
+
it 'returns a hash' do
|
14
|
+
subject.class.must_equal Hash
|
15
|
+
subject.keys.must_equal(%w(films offers))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#all_cinemas' do
|
20
|
+
subject { described_class.new.all_cinemas }
|
21
|
+
|
22
|
+
before { stub_post('all-cinemas', nil, all_cinemas_plist) }
|
23
|
+
|
24
|
+
it 'returns a hash' do
|
25
|
+
subject.class.must_equal Hash
|
26
|
+
subject.keys.must_equal(%w(sites))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#showtimes(id)' do
|
31
|
+
subject { described_class.new.film_times(71, 15130) }
|
32
|
+
|
33
|
+
before do
|
34
|
+
stub_post('film-times',
|
35
|
+
{ s: '71', m: '15130' },
|
36
|
+
film_times_plist(71, 15130))
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns an array' do
|
40
|
+
subject.class.must_equal Array
|
41
|
+
subject.each { |group| group.keys.must_equal(%w(date attributes)) }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
|
3
|
+
describe OdeonUk::Api::Screenings do
|
4
|
+
include ApiFixturesHelper
|
5
|
+
|
6
|
+
let(:described_class) { OdeonUk::Api::Screenings }
|
7
|
+
|
8
|
+
before { WebMock.disable_net_connect! }
|
9
|
+
|
10
|
+
describe '.at(cinema_id)' do
|
11
|
+
subject { described_class.at(71) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
stub_post('app-init', nil, app_init_plist)
|
15
|
+
film_times_plists(71).each do |name|
|
16
|
+
film_id = name.match(/(\d+)\.plist/)[1]
|
17
|
+
stub_post('film-times',
|
18
|
+
{ s: '71', m: film_id },
|
19
|
+
film_times_plist(71, film_id))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns an array of screening attributes as hashes' do
|
24
|
+
subject.must_be_instance_of(Array)
|
25
|
+
subject.each do |screening|
|
26
|
+
screening.must_be_instance_of(Hash)
|
27
|
+
screening.keys.must_include(:film_name)
|
28
|
+
|
29
|
+
screening.keys.must_include(:time)
|
30
|
+
screening[:time].must_be_instance_of(Time)
|
31
|
+
|
32
|
+
screening.keys.must_include(:variant)
|
33
|
+
|
34
|
+
screening.keys.must_include(:dimension)
|
35
|
+
screening[:dimension].must_match(/[23]d/)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns correct number of screenings' do
|
40
|
+
subject.count.must_equal 159
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|