cineworld_uk 4.1.0-aarch64-linux-gnu → 4.2.0-aarch64-linux-gnu

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +23 -1
  4. data/Rakefile +3 -24
  5. data/cineworld_uk.gemspec +2 -2
  6. data/lib/cineworld_uk/internal/api_response.rb +7 -30
  7. data/lib/cineworld_uk/internal/guest_token.rb +9 -52
  8. data/lib/cineworld_uk/internal/parser/api/film.rb +6 -0
  9. data/lib/cineworld_uk/internal/parser/api/performance.rb +5 -0
  10. data/lib/cineworld_uk/internal/title_sanitizer.rb +2 -10
  11. data/lib/cineworld_uk/performance.rb +4 -1
  12. data/lib/cineworld_uk/version.rb +2 -2
  13. data/lib/cineworld_uk.rb +2 -1
  14. data/test/fixtures/api/showtimes-014.json +67 -0
  15. data/test/fixtures/api/sites.json +52 -0
  16. data/test/lib/cineworld_uk/cinema_test.rb +63 -223
  17. data/test/lib/cineworld_uk/internal/api_response_test.rb +27 -182
  18. data/test/lib/cineworld_uk/internal/fixture_shape_test.rb +14 -0
  19. data/test/lib/cineworld_uk/internal/guest_token_test.rb +87 -0
  20. data/test/lib/cineworld_uk/internal/parser/api/cinema_address_test.rb +44 -85
  21. data/test/lib/cineworld_uk/internal/parser/api/film_test.rb +53 -131
  22. data/test/lib/cineworld_uk/internal/parser/api/performance_test.rb +27 -45
  23. data/test/lib/cineworld_uk/internal/title_sanitizer_test.rb +75 -126
  24. data/test/lib/cineworld_uk/performance_test.rb +153 -180
  25. data/test/lib/cineworld_uk/version_test.rb +3 -3
  26. data/test/live/api_shape_test.rb +22 -0
  27. data/test/live/integration_test.rb +13 -43
  28. data/test/live/live_helper.rb +11 -0
  29. data/test/package_test.rb +14 -7
  30. data/test/support/api_shapes.rb +48 -0
  31. data/test/support/vista_fixtures.rb +58 -0
  32. data/test/test_helper.rb +3 -0
  33. metadata +33 -28
  34. data/tasks/package.rake +0 -84
  35. data/test/fixtures/api/cinema-list.json +0 -1
  36. data/test/fixtures/api/dates-14.json +0 -1
  37. data/test/fixtures/api/performances-tomorrow-14.json +0 -1
  38. data/test/fixtures/api/vista-showtimes-brighton.json +0 -1
  39. data/test/support/fixture_reader.rb +0 -32
@@ -1,153 +1,102 @@
1
1
  require_relative '../../../test_helper'
2
2
 
3
- describe CineworldUk::Internal::TitleSanitizer do
4
- let(:described_class) { CineworldUk::Internal::TitleSanitizer }
5
-
6
- describe '#sanitized' do
7
- subject { described_class.new(title).sanitized }
8
-
9
- describe 'with 2d in title' do
10
- let(:title) { 'Iron Man 3 2D' }
11
-
12
- it 'removes dimension' do
13
- _(subject).must_equal('Iron Man 3')
14
- end
15
- end
16
-
17
- describe 'with 3d in title' do
18
- let(:title) { 'Iron Man 3 3d' }
19
-
20
- it 'removes dimension' do
21
- _(subject).must_equal('Iron Man 3')
22
- end
23
- end
24
-
25
- describe 'in hindi' do
26
- let(:title) { 'Bang Bang! (Hindi)' }
27
-
28
- it 'removes language' do
29
- _(subject).must_equal('Bang Bang!')
30
- end
31
- end
32
-
33
- describe 'Unlimited Screening' do
34
- let(:title) { 'Nightcrawler - Unlimited Screening' }
35
-
36
- it 'removes prefix' do
37
- _(subject).must_equal('Nightcrawler')
38
- end
39
- end
3
+ class CineworldUk::Internal::TitleSanitizerTest < Minitest::Test
4
+ def test_removes_2d
5
+ assert_sanitized 'Iron Man 3', 'Iron Man 3 2D'
6
+ end
40
7
 
41
- describe 'Austism screening' do
42
- let(:title) { 'Autism Friendly Screening: Dolphin Tale 2' }
8
+ def test_removes_3d
9
+ assert_sanitized 'Iron Man 3', 'Iron Man 3 3d'
10
+ end
43
11
 
44
- it 'removes prefix' do
45
- _(subject).must_equal('Dolphin Tale 2')
46
- end
47
- end
12
+ def test_removes_language
13
+ assert_sanitized 'Bang Bang!', 'Bang Bang! (Hindi)'
14
+ assert_sanitized 'Deadline', 'Deadline (Mandarin)'
15
+ end
48
16
 
49
- describe 'Bolshoi screening' do
50
- let(:title) { 'Bolshoi Ballet: The Legend of Love' }
17
+ def test_removes_dub_version
18
+ assert_sanitized 'Kung Fu Soccer', 'Kung Fu Soccer (Dubbed)'
19
+ end
51
20
 
52
- it 'removes prefix' do
53
- _(subject).must_equal('Bolshoi Ballet: The Legend of Love')
54
- end
55
- end
21
+ def test_removes_unlimited_screening
22
+ assert_sanitized 'Nightcrawler', 'Nightcrawler - Unlimited Screening'
23
+ end
56
24
 
57
- describe 'English National Opera screening' do
58
- let(:title) { 'ENO: La Traviata ' }
25
+ def test_removes_autism_prefix
26
+ assert_sanitized 'Dolphin Tale 2', 'Autism Friendly Screening: Dolphin Tale 2'
27
+ end
59
28
 
60
- it 'removes prefix' do
61
- _(subject).must_equal('English National Opera: La Traviata')
62
- end
63
- end
29
+ def test_keeps_bolshoi_ballet
30
+ assert_sanitized 'Bolshoi Ballet: The Legend of Love', 'Bolshoi Ballet: The Legend of Love'
31
+ end
64
32
 
65
- describe 'with IMAX' do
66
- let(:title) { '(IMAX) Fury' }
33
+ def test_eno
34
+ assert_sanitized 'English National Opera: La Traviata', 'ENO: La Traviata '
35
+ end
67
36
 
68
- it 'removes prefix' do
69
- _(subject).must_equal('Fury')
70
- end
71
- end
37
+ def test_removes_imax_prefix
38
+ assert_sanitized 'Fury', '(IMAX) Fury'
39
+ end
72
40
 
73
- describe 'Met Opera screening' do
74
- let(:title) { 'MET Opera - Le Nozze Di Figaro' }
41
+ def test_met_opera
42
+ assert_sanitized 'Met Opera: Le Nozze Di Figaro', 'MET Opera - Le Nozze Di Figaro'
43
+ end
75
44
 
76
- it 'removes prefix' do
77
- _(subject).must_equal('Met Opera: Le Nozze Di Figaro')
78
- end
79
- end
45
+ def test_nt_live_encore
46
+ assert_sanitized 'National Theatre: Frankenstein (starring Benedict Cumberbatch)',
47
+ 'NT Live Encore: Frankenstein (starring Benedict Cumberbatch)'
48
+ end
80
49
 
81
- describe 'NT Live screening' do
82
- let(:title) { 'NT Live Encore: Frankenstein (starring Benedict Cumberbatch)' }
50
+ def test_nt_live
51
+ assert_sanitized 'National Theatre: Treasure Island', 'NT Live: Treasure Island'
52
+ end
83
53
 
84
- it 'removes prefix' do
85
- _(subject).must_equal('National Theatre: Frankenstein (starring Benedict Cumberbatch)')
86
- end
87
- end
54
+ def test_nt_live_with_encore_suffix
55
+ assert_sanitized 'National Theatre: A Streetcar Named Desire (Young Vic)',
56
+ 'NT Live: A Streetcar Named Desire (Young Vic) - Encore'
57
+ end
88
58
 
89
- describe 'National Theatre screening' do
90
- let(:title) { 'NT Live: Treasure Island' }
59
+ def test_roh
60
+ assert_sanitized 'Royal Opera House: I Due Foscari', 'ROH - I Due Foscari'
61
+ end
91
62
 
92
- it 'removes prefix' do
93
- _(subject).must_equal('National Theatre: Treasure Island')
94
- end
95
- end
63
+ def test_rbo_season
64
+ assert_sanitized 'Royal Ballet and Opera: Manon', 'RBO Cinema Season 2026-27: Manon'
65
+ end
96
66
 
97
- describe 'National Theatre Encore screening' do
98
- let(:title) { 'NT Live: A Streetcar Named Desire (Young Vic) - Encore' }
67
+ def test_rsc
68
+ assert_sanitized "Royal Shakespeare Company: Love's Labour's Lost",
69
+ "RSC Live: Love's Labour's Lost"
70
+ end
99
71
 
100
- it 'removes prefix' do
101
- _(subject).must_equal('National Theatre: A Streetcar Named Desire (Young Vic)')
102
- end
103
- end
72
+ def test_removes_sciscreen
73
+ assert_sanitized 'Dallas Buyers Club', 'SciScreen: Dallas Buyers Club'
74
+ end
104
75
 
105
- describe 'ROH screening' do
106
- let(:title) { 'ROH - I Due Foscari' }
76
+ def test_removes_special_performance
77
+ assert_sanitized 'Billy Elliot The Musical Live',
78
+ 'Billy Elliot The Musical Live - Special Performance'
79
+ end
107
80
 
108
- it 'removes prefix' do
109
- _(subject).must_equal('Royal Opera House: I Due Foscari')
110
- end
111
- end
112
-
113
- describe 'RSC screening' do
114
- let(:title) { "RSC Live: Love's Labour's Lost" }
81
+ def test_removes_take_2
82
+ assert_sanitized 'Boyhood', 'Take 2 - Boyhood'
83
+ end
115
84
 
116
- it 'removes prefix' do
117
- _(subject).must_equal("Royal Shakespeare Company: Love's Labour's Lost")
118
- end
119
- end
120
-
121
- describe 'SciScreen screening' do
122
- let(:title) { 'SciScreen: Dallas Buyers Club' }
85
+ def test_removes_singalong_and_movies_for_juniors
86
+ assert_sanitized 'Frozen', 'Frozen Sing-Along - Movies For Juniors'
87
+ end
123
88
 
124
- it 'removes prefix' do
125
- _(subject).must_equal('Dallas Buyers Club')
126
- end
127
- end
128
-
129
- describe 'special screening' do
130
- let(:title) { 'Billy Elliot The Musical Live - Special Performance' }
89
+ def test_keeps_sing_along_within_title
90
+ assert_sanitized 'Bebefinn Sing-Along Movie', 'Bebefinn Sing-Along Movie'
91
+ end
131
92
 
132
- it 'removes prefix' do
133
- _(subject).must_equal('Billy Elliot The Musical Live')
134
- end
135
- end
136
-
137
- describe 'Take 2 screening' do
138
- let(:title) { 'Take 2 - Boyhood' }
93
+ def test_removes_festival_prefix
94
+ assert_sanitized 'Scum Of The Earth', 'Cine-Excess 2026: Scum Of The Earth'
95
+ end
139
96
 
140
- it 'removes prefix' do
141
- _(subject).must_equal('Boyhood')
142
- end
143
- end
144
-
145
- describe 'singalong and movies for juniors' do
146
- let(:title) { 'Frozen Sing-Along - Movies For Juniors' }
97
+ private
147
98
 
148
- it 'removes prefix' do
149
- _(subject).must_equal('Frozen')
150
- end
151
- end
99
+ def assert_sanitized(expected, title)
100
+ assert_equal expected, CineworldUk::Internal::TitleSanitizer.new(title).sanitized
152
101
  end
153
102
  end
@@ -1,183 +1,156 @@
1
1
  require_relative '../../test_helper'
2
- require_relative '../../support/fixture_reader'
3
-
4
- describe CineworldUk::Performance do
5
- include Support::FixtureReader
6
-
7
- let(:described_class) { CineworldUk::Performance }
8
- let(:api_response) { Minitest::Mock.new }
9
-
10
- before { WebMock.disable_net_connect! }
11
- after { WebMock.allow_net_connect! }
12
-
13
- describe '.at(cinema_id)' do
14
- subject do
15
- described_class.at(cinema_id, from: Date.today + 1, to: Date.today + 1)
16
- end
17
-
18
- before do
19
- api_response.expect(:cinema_list, cinema_list_json)
20
- 4.times { api_response.expect(:performances,
21
- performances_tomorrow_json(14),
22
- [14, Date.today + 1]) }
23
- end
24
-
25
- describe 'called with integer' do
26
- let(:cinema_id) { 14 }
27
-
28
- it 'returns an array of performances' do
29
- CineworldUk::Internal::ApiResponse.stub :new, api_response do
30
- _(subject).must_be_instance_of(Array)
31
- subject.each do |performance|
32
- _(performance).must_be_instance_of(described_class)
33
- end
34
- end
35
- end
36
-
37
- it 'returns at least a sensible number' do
38
- CineworldUk::Internal::ApiResponse.stub :new, api_response do
39
- _(subject.count).must_be :>, 5
40
- end
41
- end
42
- end
43
-
44
- describe 'called with string' do
45
- let(:cinema_id) { '14' }
46
-
47
- it 'returns an array of performances' do
48
- CineworldUk::Internal::ApiResponse.stub :new, api_response do
49
- _(subject).must_be_instance_of(Array)
50
- subject.each do |performance|
51
- _(performance).must_be_instance_of(described_class)
52
- end
53
- end
54
- end
55
-
56
- it 'returns at least a sensible number' do
57
- CineworldUk::Internal::ApiResponse.stub :new, api_response do
58
- _(subject.count).must_be :>, 5
59
- end
60
- end
61
- end
62
- end
63
-
64
- describe '.new' do
65
- subject { described_class.new(options) }
66
-
67
- describe 'simple' do
68
- let(:options) do
69
- {
70
- film_name: 'Iron Man 3',
71
- cinema_id: 3,
72
- cinema_name: 'Cineworld Brighton',
73
- starting_at: Time.utc(2013, 9, 12, 11, 0)
74
- }
75
- end
76
-
77
- it 'sets cinema name and film name' do
78
- _(subject.film_name).must_equal 'Iron Man 3'
79
- _(subject.cinema_name).must_equal 'Cineworld Brighton'
80
- end
81
-
82
- it 'booking url, dimension & varient are set to defaults' do
83
- _(subject.booking_url).must_be_nil
84
- _(subject.dimension).must_equal '2d'
85
- _(subject.variant).must_equal []
86
- end
87
- end
88
- end
89
-
90
- describe '#dimension' do
91
- let(:options) do
92
- {
93
- film_name: 'Iron Man 3',
94
- dimension: '3d',
95
- cinema_id: 3,
96
- cinema_name: 'Cineworld Brighton',
97
- starting_at: Time.utc(2013, 9, 12, 11, 0)
98
- }
99
- end
100
-
101
- subject { described_class.new(options).dimension }
102
-
103
- it 'returns 2d or 3d' do
104
- _(subject).must_be_instance_of(String)
105
- _(subject).must_equal '3d'
106
- end
107
- end
108
-
109
- describe '#starting_at' do
110
- subject { described_class.new(options).starting_at }
111
-
112
- describe 'with utc time' do
113
- let(:options) do
114
- {
115
- film_name: 'Iron Man 3',
116
- cinema_id: 3,
117
- cinema_name: 'Cineworld Brighton',
118
- starting_at: Time.utc(2013, 9, 12, 11, 0)
119
- }
120
- end
121
-
122
- it 'returns UTC time' do
123
- _(subject).must_be_instance_of Time
124
- _(subject).must_equal Time.utc(2013, 9, 12, 11, 0)
125
- end
126
- end
127
-
128
- describe 'with non-utc time' do
129
- let(:options) do
130
- {
131
- film_name: 'Iron Man 3',
132
- cinema_id: 3,
133
- cinema_name: 'Cineworld Brighton',
134
- starting_at: Time.new(2013, 9, 12, 11, 0)
135
- }
136
- end
137
-
138
- it 'returns UTC time' do
139
- _(subject).must_be_instance_of Time
140
- _(subject).must_equal Time.utc(2013, 9, 12, 10, 0)
141
- _(subject.utc?).must_equal(true)
142
- end
143
- end
144
- end
145
-
146
- describe '#showing_on' do
147
- let(:options) do
148
- {
149
- film_name: 'Iron Man 3',
150
- cinema_id: 3,
151
- cinema_name: 'Cineworld Brighton',
152
- starting_at: Time.utc(2013, 9, 12, 11, 0)
153
- }
154
- end
155
-
156
- subject { described_class.new(options).showing_on }
157
-
158
- it 'returns date of showing' do
159
- _(subject).must_be_instance_of(Date)
160
- _(subject).must_equal Date.new(2013, 9, 12)
161
- end
162
- end
163
-
164
- describe '#variant' do
165
- subject { described_class.new(options).variant }
166
-
167
- let(:options) do
168
- {
169
- film_name: 'Iron Man 3',
170
- cinema_id: 3,
171
- cinema_name: 'Cineworld Brighton',
172
- starting_at: Time.utc(2013, 9, 12, 11, 0),
173
- variant: ['Kids']
174
- }
175
- end
176
-
177
- it 'is an alphabetically ordered array of lower-cased strings' do
178
- _(subject).must_be_instance_of Array
179
- subject.each { |element| _(element).must_be_instance_of String }
180
- _(subject).must_equal %w(kids)
181
- end
2
+
3
+ class CineworldUk::PerformanceTest < Minitest::Test
4
+ include Support::VistaFixtures
5
+
6
+ DATE = Date.new(2026, 10, 24)
7
+
8
+ def setup
9
+ setup_vista
10
+ end
11
+
12
+ def teardown
13
+ teardown_vista
14
+ super
15
+ end
16
+
17
+ def test_at_returns_performances
18
+ performances = performances_on_date
19
+
20
+ assert(performances.all? { |p| p.instance_of?(CineworldUk::Performance) })
21
+ assert_equal 6, performances.count
22
+ end
23
+
24
+ def test_at_accepts_string_id
25
+ stub_showtimes(DATE)
26
+
27
+ assert_equal 6, CineworldUk::Performance.at('014', from: DATE, to: DATE).count
28
+ end
29
+
30
+ def test_at_parses_first_performance
31
+ performance = performances_on_date.first
32
+
33
+ assert_equal 14, performance.cinema_id
34
+ assert_equal 'Brighton', performance.cinema_name
35
+ assert_equal 'The Example Film', performance.film_name
36
+ assert_equal Time.utc(2026, 10, 24, 8, 0), performance.starting_at
37
+ assert_equal '2d', performance.dimension
38
+ assert_equal %w(audio_described), performance.variant
39
+ assert_equal 'https://web.cineworld.co.uk/order/showtimes/014-1001/seats',
40
+ performance.booking_url
41
+ end
42
+
43
+ def test_at_keeps_format_per_session
44
+ performances = performances_on_date
45
+
46
+ assert_equal '3d', performances[1].dimension
47
+ assert_equal %w(imax), performances[1].variant
48
+ assert_equal '2d', performances.last.dimension
49
+ end
50
+
51
+ def test_at_returns_language_and_subtitles
52
+ performance = performances_on_date[2]
53
+
54
+ assert_equal 'Imaginary Picture', performance.film_name
55
+ assert_equal 'Tamil', performance.language
56
+ assert performance.subtitled?
57
+ end
58
+
59
+ def test_at_marks_movies_for_juniors_as_kids
60
+ performance = performances_on_date[3]
61
+
62
+ assert_equal 'Pretend Pups', performance.film_name
63
+ assert_equal %w(kids), performance.variant
64
+ end
65
+
66
+ def test_at_moves_festival_from_title
67
+ performance = performances_on_date[4]
68
+
69
+ assert_equal 'Scum Of The Earth', performance.film_name
70
+ assert_equal Cinebase::Festival.new(name: 'Cine-Excess', year: 2026), performance.festival
71
+ end
72
+
73
+ def test_at_keeps_after_midnight_on_next_utc_day
74
+ assert_equal Time.utc(2026, 10, 24, 23, 15), performances_on_date.last.starting_at
75
+ end
76
+
77
+ def test_at_includes_last_requested_day_without_fetching_sites
78
+ stub_showtimes(DATE, empty_showtimes_json)
79
+ stub_showtimes(DATE + 1)
80
+
81
+ performances = CineworldUk::Performance.at(14, from: DATE, to: DATE + 1)
82
+
83
+ assert_equal 6, performances.count
84
+ assert_not_requested :get, "#{BASE_URL}sites"
85
+ end
86
+
87
+ def test_at_defaults_to_fourteen_days
88
+ (DATE..DATE + 13).each { |date| stub_showtimes(date, empty_showtimes_json) }
89
+
90
+ assert_equal [], CineworldUk::Performance.at(14, from: DATE)
91
+ assert_requested :get, %r{showtimes/by-business-date/}, times: 14
92
+ end
93
+
94
+ def test_at_rejects_range_ending_before_start
95
+ assert_raises(ArgumentError) { CineworldUk::Performance.at(14, from: DATE, to: DATE - 1) }
96
+ end
97
+
98
+ def test_new_sets_names
99
+ performance = CineworldUk::Performance.new(options)
100
+
101
+ assert_equal 'Iron Man 3', performance.film_name
102
+ assert_equal 'Cineworld Brighton', performance.cinema_name
103
+ end
104
+
105
+ def test_new_sets_defaults
106
+ performance = CineworldUk::Performance.new(options)
107
+
108
+ assert_nil performance.booking_url
109
+ assert_equal '2d', performance.dimension
110
+ assert_nil performance.festival
111
+ assert_nil performance.language
112
+ refute performance.subtitled?
113
+ assert_equal [], performance.variant
114
+ end
115
+
116
+ def test_dimension
117
+ assert_equal '3d', CineworldUk::Performance.new(options(dimension: '3d')).dimension
118
+ end
119
+
120
+ def test_starting_at_keeps_utc
121
+ assert_equal Time.utc(2013, 9, 12, 11, 0), CineworldUk::Performance.new(options).starting_at
122
+ end
123
+
124
+ def test_starting_at_converts_local_time_to_utc
125
+ starting_at = CineworldUk::Performance.new(
126
+ options(starting_at: Time.new(2013, 9, 12, 11, 0))
127
+ ).starting_at
128
+
129
+ assert_equal Time.utc(2013, 9, 12, 10, 0), starting_at
130
+ assert starting_at.utc?
131
+ end
132
+
133
+ def test_showing_on
134
+ assert_equal Date.new(2013, 9, 12), CineworldUk::Performance.new(options).showing_on
135
+ end
136
+
137
+ def test_variant_is_sorted_and_lower_case
138
+ assert_equal %w(kids), CineworldUk::Performance.new(options(variant: ['Kids'])).variant
139
+ end
140
+
141
+ private
142
+
143
+ def options(overrides = {})
144
+ {
145
+ film_name: 'Iron Man 3',
146
+ cinema_id: 3,
147
+ cinema_name: 'Cineworld Brighton',
148
+ starting_at: Time.utc(2013, 9, 12, 11, 0)
149
+ }.merge(overrides)
150
+ end
151
+
152
+ def performances_on_date
153
+ stub_showtimes(DATE)
154
+ CineworldUk::Performance.at(14, from: DATE, to: DATE)
182
155
  end
183
156
  end
@@ -1,7 +1,7 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
- describe CineworldUk do
4
- it 'must be defined' do
5
- _(CineworldUk::VERSION).wont_be_nil
3
+ class CineworldUk::VersionTest < Minitest::Test
4
+ def test_version_is_defined
5
+ refute_nil CineworldUk::VERSION
6
6
  end
7
7
  end
@@ -0,0 +1,22 @@
1
+ require_relative 'live_helper'
2
+
3
+ class LiveApiShapeTest < Minitest::Test
4
+ include ApiShapes
5
+
6
+ def test_sites_are_readable
7
+ assert_sites_shape(client.get('sites'))
8
+ end
9
+
10
+ def test_showtimes_are_readable
11
+ date = (Date.today + 1).iso8601
12
+
13
+ assert_showtimes_shape(client.get("showtimes/by-business-date/#{date}", 'siteIds' => '014'))
14
+ end
15
+
16
+ private
17
+
18
+ def client
19
+ Cinebase::Vista::Client.new(base_url: CineworldUk::Internal::ApiResponse::BASE_URL,
20
+ region_code: 'GB', token: CineworldUk.token)
21
+ end
22
+ end