cineworld_uk 3.1.0 → 4.1.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 +5 -5
- data/.agents/setup +51 -0
- data/.github/workflows/test.yml +43 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +21 -0
- data/README.md +136 -16
- data/Rakefile +5 -37
- data/cineworld_uk.gemspec +7 -4
- data/lib/cineworld_uk/cinema.rb +7 -4
- data/lib/cineworld_uk/internal/api_response.rb +99 -56
- data/lib/cineworld_uk/internal/guest_token.rb +73 -0
- data/lib/cineworld_uk/internal/parser/api/cinema_address.rb +24 -24
- data/lib/cineworld_uk/internal/parser/api/film.rb +10 -8
- data/lib/cineworld_uk/internal/parser/api/performance.rb +6 -11
- data/lib/cineworld_uk/performance.rb +42 -23
- data/lib/cineworld_uk/version.rb +2 -2
- data/lib/cineworld_uk.rb +12 -2
- data/tasks/package.rake +84 -0
- data/test/fixtures/api/cinema-list.json +1 -1
- data/test/fixtures/api/dates-14.json +1 -0
- data/test/fixtures/api/performances-tomorrow-14.json +1 -0
- data/test/fixtures/api/vista-showtimes-brighton.json +1 -0
- data/test/lib/cineworld_uk/cinema_test.rb +47 -47
- data/test/lib/cineworld_uk/internal/api_response_test.rb +177 -58
- data/test/lib/cineworld_uk/internal/parser/api/cinema_address_test.rb +14 -14
- data/test/lib/cineworld_uk/internal/parser/api/film_test.rb +43 -55
- data/test/lib/cineworld_uk/internal/parser/api/performance_test.rb +11 -12
- data/test/lib/cineworld_uk/internal/title_sanitizer_test.rb +18 -18
- data/test/lib/cineworld_uk/performance_test.rb +31 -32
- data/test/lib/cineworld_uk/version_test.rb +1 -1
- data/test/live/integration_test.rb +9 -9
- data/test/package_test.rb +49 -0
- data/test/support/fixture_reader.rb +2 -14
- data/test/test_helper.rb +3 -2
- metadata +65 -36
- data/.travis.yml +0 -10
- data/lib/cineworld_uk/internal/parser/api/film_lookup.rb +0 -38
- data/lib/cineworld_uk/internal/parser/api/performances_by_day.rb +0 -54
- data/test/fixtures/api/cinema-detail-10.json +0 -1
- data/test/fixtures/api/cinema-detail-21.json +0 -1
- data/test/fixtures/api/cinema-detail-3.json +0 -1
- data/test/fixtures/api/cinema-detail-96.json +0 -1
- data/test/fixtures/api/dates-3.json +0 -1
- data/test/fixtures/api/film-list-comingsoon.json +0 -1
- data/test/fixtures/api/film-list.json +0 -1
- data/test/fixtures/api/performances-tomorrow-3.json +0 -1
- data/test/lib/cineworld_uk/internal/parser/api/film_lookup_test.rb +0 -31
|
@@ -13,12 +13,12 @@ describe CineworldUk::Internal::Parser::Api::Film do
|
|
|
13
13
|
describe '#id' do
|
|
14
14
|
subject { described_class.new(data).id }
|
|
15
15
|
|
|
16
|
-
it 'is
|
|
17
|
-
subject.must_be_instance_of(
|
|
16
|
+
it 'is a string' do
|
|
17
|
+
_(subject).must_be_instance_of(String)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it 'is the film id from the data' do
|
|
21
|
-
subject.must_equal(data['
|
|
21
|
+
_(subject).must_equal(data['id'])
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -26,42 +26,42 @@ describe CineworldUk::Internal::Parser::Api::Film do
|
|
|
26
26
|
subject { described_class.new(data).dimension }
|
|
27
27
|
|
|
28
28
|
it 'is a string' do
|
|
29
|
-
subject.must_be_instance_of(String)
|
|
29
|
+
_(subject).must_be_instance_of(String)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it 'is 2d or 3d' do
|
|
33
|
-
subject.must_match(/[23]d/)
|
|
33
|
+
_(subject).must_match(/[23]d/)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
describe '
|
|
37
|
-
let(:data) { random_film.merge('
|
|
36
|
+
describe 'attributeIds includes "2d"' do
|
|
37
|
+
let(:data) { random_film.merge('attributeIds' => ['2d']) }
|
|
38
38
|
|
|
39
39
|
it 'is 2d' do
|
|
40
|
-
subject.must_equal('2d')
|
|
40
|
+
_(subject).must_equal('2d')
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
describe '
|
|
45
|
-
let(:data) { random_film.merge('
|
|
44
|
+
describe 'attributeIds includes "3d"' do
|
|
45
|
+
let(:data) { random_film.merge('attributeIds' => ['3d']) }
|
|
46
46
|
|
|
47
47
|
it 'is 3d' do
|
|
48
|
-
subject.must_equal('3d')
|
|
48
|
+
_(subject).must_equal('3d')
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
describe '
|
|
53
|
-
let(:data) { random_film.merge('
|
|
52
|
+
describe 'attributeIds with imax but not 3d' do
|
|
53
|
+
let(:data) { random_film.merge('attributeIds' => ['imax', '2d']) }
|
|
54
54
|
|
|
55
55
|
it 'is 2d' do
|
|
56
|
-
subject.must_equal('2d')
|
|
56
|
+
_(subject).must_equal('2d')
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
describe '
|
|
61
|
-
let(:data) { random_film.merge('
|
|
60
|
+
describe 'attributeIds with imax and 3d' do
|
|
61
|
+
let(:data) { random_film.merge('attributeIds' => ['imax', '3d']) }
|
|
62
62
|
|
|
63
63
|
it 'is 3d' do
|
|
64
|
-
subject.must_equal('3d')
|
|
64
|
+
_(subject).must_equal('3d')
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
end
|
|
@@ -70,25 +70,24 @@ describe CineworldUk::Internal::Parser::Api::Film do
|
|
|
70
70
|
subject { described_class.new(data).name }
|
|
71
71
|
|
|
72
72
|
it 'is a string' do
|
|
73
|
-
subject.must_be_instance_of(String)
|
|
73
|
+
_(subject).must_be_instance_of(String)
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
describe '
|
|
76
|
+
describe 'film name' do
|
|
77
77
|
let(:data) do
|
|
78
|
-
random_film.merge('
|
|
79
|
-
'title' => 'Title')
|
|
78
|
+
random_film.merge('name' => 'Test Film Name')
|
|
80
79
|
end
|
|
81
80
|
|
|
82
|
-
it 'is the
|
|
83
|
-
subject.must_equal('
|
|
81
|
+
it 'is the film name' do
|
|
82
|
+
_(subject).must_equal('Test Film Name')
|
|
84
83
|
end
|
|
85
84
|
end
|
|
86
85
|
|
|
87
|
-
describe '
|
|
88
|
-
let(:data) { random_film.merge('
|
|
86
|
+
describe 'film name is unsanitized' do
|
|
87
|
+
let(:data) { random_film.merge('name' => 'ROH: Something') }
|
|
89
88
|
|
|
90
89
|
it 'is sanitized' do
|
|
91
|
-
subject.must_equal('Royal Opera House: Something')
|
|
90
|
+
_(subject).must_equal('Royal Opera House: Something')
|
|
92
91
|
end
|
|
93
92
|
end
|
|
94
93
|
end
|
|
@@ -97,69 +96,58 @@ describe CineworldUk::Internal::Parser::Api::Film do
|
|
|
97
96
|
subject { described_class.new(data).variant }
|
|
98
97
|
|
|
99
98
|
it 'is a sorted array of strings' do
|
|
100
|
-
subject.must_be_instance_of(Array)
|
|
101
|
-
subject.each { |element| element.must_be_instance_of(String) }
|
|
102
|
-
subject.sort.must_equal(subject)
|
|
99
|
+
_(subject).must_be_instance_of(Array)
|
|
100
|
+
subject.each { |element| _(element).must_be_instance_of(String) }
|
|
101
|
+
_(subject.sort).must_equal(subject)
|
|
103
102
|
end
|
|
104
103
|
|
|
105
|
-
describe '
|
|
104
|
+
describe 'attributeIds includes "junior"' do
|
|
106
105
|
let(:data) do
|
|
107
|
-
random_film.merge('
|
|
106
|
+
random_film.merge('attributeIds' => ['junior'])
|
|
108
107
|
end
|
|
109
108
|
|
|
110
109
|
it 'includes "kids"' do
|
|
111
|
-
subject.must_include('kids')
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
describe 'hash["format"] is "IMAX3D"' do
|
|
116
|
-
let(:data) do
|
|
117
|
-
random_film.merge('title' => 'nothing', 'format' => 'IMAX3D')
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it 'includes "imax"' do
|
|
121
|
-
subject.must_include('imax')
|
|
110
|
+
_(subject).must_include('kids')
|
|
122
111
|
end
|
|
123
112
|
end
|
|
124
113
|
|
|
125
|
-
describe '
|
|
114
|
+
describe 'attributeIds includes "imax"' do
|
|
126
115
|
let(:data) do
|
|
127
|
-
random_film.merge('
|
|
116
|
+
random_film.merge('attributeIds' => ['imax', '3d'])
|
|
128
117
|
end
|
|
129
118
|
|
|
130
119
|
it 'includes "imax"' do
|
|
131
|
-
subject.must_include('imax')
|
|
120
|
+
_(subject).must_include('imax')
|
|
132
121
|
end
|
|
133
122
|
end
|
|
134
123
|
|
|
135
|
-
describe '
|
|
124
|
+
describe 'attributeIds includes "unlimited-screening"' do
|
|
136
125
|
let(:data) do
|
|
137
|
-
random_film.merge('
|
|
126
|
+
random_film.merge('attributeIds' => ['unlimited-screening'])
|
|
138
127
|
end
|
|
139
128
|
|
|
140
129
|
it 'includes "members"' do
|
|
141
|
-
subject.must_include('members')
|
|
130
|
+
_(subject).must_include('members')
|
|
142
131
|
end
|
|
143
132
|
end
|
|
144
133
|
|
|
145
|
-
describe '
|
|
134
|
+
describe 'attributeIds includes "qa"' do
|
|
146
135
|
let(:data) do
|
|
147
|
-
random_film.merge('
|
|
136
|
+
random_film.merge('attributeIds' => ['qa'])
|
|
148
137
|
end
|
|
149
138
|
|
|
150
139
|
it 'includes "q&a"' do
|
|
151
|
-
subject.must_include('q&a')
|
|
140
|
+
_(subject).must_include('q&a')
|
|
152
141
|
end
|
|
153
142
|
end
|
|
154
143
|
|
|
155
144
|
describe 'combination' do
|
|
156
145
|
let(:data) do
|
|
157
|
-
random_film.merge('
|
|
158
|
-
'title' => 'Something Unlimited Screening')
|
|
146
|
+
random_film.merge('attributeIds' => ['imax', 'unlimited-screening'])
|
|
159
147
|
end
|
|
160
148
|
|
|
161
149
|
it 'includes "members"' do
|
|
162
|
-
subject.must_include('imax', 'members')
|
|
150
|
+
_(subject).must_include('imax', 'members')
|
|
163
151
|
end
|
|
164
152
|
end
|
|
165
153
|
end
|
|
@@ -167,6 +155,6 @@ describe CineworldUk::Internal::Parser::Api::Film do
|
|
|
167
155
|
private
|
|
168
156
|
|
|
169
157
|
def random_film
|
|
170
|
-
JSON.parse(
|
|
158
|
+
JSON.parse(performances_tomorrow_json(14))['body']['films'].sample
|
|
171
159
|
end
|
|
172
160
|
end
|
|
@@ -14,16 +14,15 @@ describe CineworldUk::Internal::Parser::Api::Performance do
|
|
|
14
14
|
subject { described_class.new(data).booking_url }
|
|
15
15
|
|
|
16
16
|
it 'should be a url on the cineworld website' do
|
|
17
|
-
subject.must_match(%r{cineworld.co.uk
|
|
17
|
+
_(subject).must_match(%r{cineworld.co.uk})
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
describe '#film_id' do
|
|
22
22
|
subject { described_class.new(data).film_id }
|
|
23
23
|
|
|
24
|
-
it 'should be a
|
|
25
|
-
subject.must_be_instance_of(
|
|
26
|
-
subject.must_be :>, 10_000
|
|
24
|
+
it 'should be a string' do
|
|
25
|
+
_(subject).must_be_instance_of(String)
|
|
27
26
|
end
|
|
28
27
|
end
|
|
29
28
|
|
|
@@ -31,26 +30,26 @@ describe CineworldUk::Internal::Parser::Api::Performance do
|
|
|
31
30
|
subject { described_class.new(data).starting_at }
|
|
32
31
|
|
|
33
32
|
it 'should be a time' do
|
|
34
|
-
subject.must_be_instance_of(Time)
|
|
33
|
+
_(subject).must_be_instance_of(Time)
|
|
35
34
|
end
|
|
36
35
|
end
|
|
37
36
|
|
|
38
37
|
describe '#variant' do
|
|
39
38
|
subject { described_class.new(data).variant }
|
|
40
39
|
|
|
41
|
-
describe 'has "
|
|
42
|
-
let(:data) { random_performance.merge('
|
|
40
|
+
describe 'has "audio-described" in attributeIds' do
|
|
41
|
+
let(:data) { random_performance.merge('attributeIds' => ['audio-described']) }
|
|
43
42
|
|
|
44
43
|
it 'includes "audio_described"' do
|
|
45
|
-
subject.must_include('audio_described')
|
|
44
|
+
_(subject).must_include('audio_described')
|
|
46
45
|
end
|
|
47
46
|
end
|
|
48
47
|
|
|
49
|
-
describe 'has "
|
|
50
|
-
let(:data) { random_performance.merge('
|
|
48
|
+
describe 'has "subbed" in attributeIds' do
|
|
49
|
+
let(:data) { random_performance.merge('attributeIds' => ['subbed']) }
|
|
51
50
|
|
|
52
51
|
it 'includes "subtitled"' do
|
|
53
|
-
subject.must_include('subtitled')
|
|
52
|
+
_(subject).must_include('subtitled')
|
|
54
53
|
end
|
|
55
54
|
end
|
|
56
55
|
end
|
|
@@ -58,6 +57,6 @@ describe CineworldUk::Internal::Parser::Api::Performance do
|
|
|
58
57
|
private
|
|
59
58
|
|
|
60
59
|
def random_performance
|
|
61
|
-
JSON.parse(performances_tomorrow_json(
|
|
60
|
+
JSON.parse(performances_tomorrow_json(14))['body']['events'].sample
|
|
62
61
|
end
|
|
63
62
|
end
|
|
@@ -10,7 +10,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
10
10
|
let(:title) { 'Iron Man 3 2D' }
|
|
11
11
|
|
|
12
12
|
it 'removes dimension' do
|
|
13
|
-
subject.must_equal('Iron Man 3')
|
|
13
|
+
_(subject).must_equal('Iron Man 3')
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
18
18
|
let(:title) { 'Iron Man 3 3d' }
|
|
19
19
|
|
|
20
20
|
it 'removes dimension' do
|
|
21
|
-
subject.must_equal('Iron Man 3')
|
|
21
|
+
_(subject).must_equal('Iron Man 3')
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -26,7 +26,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
26
26
|
let(:title) { 'Bang Bang! (Hindi)' }
|
|
27
27
|
|
|
28
28
|
it 'removes language' do
|
|
29
|
-
subject.must_equal('Bang Bang!')
|
|
29
|
+
_(subject).must_equal('Bang Bang!')
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
@@ -34,7 +34,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
34
34
|
let(:title) { 'Nightcrawler - Unlimited Screening' }
|
|
35
35
|
|
|
36
36
|
it 'removes prefix' do
|
|
37
|
-
subject.must_equal('Nightcrawler')
|
|
37
|
+
_(subject).must_equal('Nightcrawler')
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
42
42
|
let(:title) { 'Autism Friendly Screening: Dolphin Tale 2' }
|
|
43
43
|
|
|
44
44
|
it 'removes prefix' do
|
|
45
|
-
subject.must_equal('Dolphin Tale 2')
|
|
45
|
+
_(subject).must_equal('Dolphin Tale 2')
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -50,7 +50,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
50
50
|
let(:title) { 'Bolshoi Ballet: The Legend of Love' }
|
|
51
51
|
|
|
52
52
|
it 'removes prefix' do
|
|
53
|
-
subject.must_equal('Bolshoi Ballet: The Legend of Love')
|
|
53
|
+
_(subject).must_equal('Bolshoi Ballet: The Legend of Love')
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -58,7 +58,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
58
58
|
let(:title) { 'ENO: La Traviata ' }
|
|
59
59
|
|
|
60
60
|
it 'removes prefix' do
|
|
61
|
-
subject.must_equal('English National Opera: La Traviata')
|
|
61
|
+
_(subject).must_equal('English National Opera: La Traviata')
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
@@ -66,7 +66,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
66
66
|
let(:title) { '(IMAX) Fury' }
|
|
67
67
|
|
|
68
68
|
it 'removes prefix' do
|
|
69
|
-
subject.must_equal('Fury')
|
|
69
|
+
_(subject).must_equal('Fury')
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -74,7 +74,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
74
74
|
let(:title) { 'MET Opera - Le Nozze Di Figaro' }
|
|
75
75
|
|
|
76
76
|
it 'removes prefix' do
|
|
77
|
-
subject.must_equal('Met Opera: Le Nozze Di Figaro')
|
|
77
|
+
_(subject).must_equal('Met Opera: Le Nozze Di Figaro')
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
@@ -82,7 +82,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
82
82
|
let(:title) { 'NT Live Encore: Frankenstein (starring Benedict Cumberbatch)' }
|
|
83
83
|
|
|
84
84
|
it 'removes prefix' do
|
|
85
|
-
subject.must_equal('National Theatre: Frankenstein (starring Benedict Cumberbatch)')
|
|
85
|
+
_(subject).must_equal('National Theatre: Frankenstein (starring Benedict Cumberbatch)')
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
|
|
@@ -90,7 +90,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
90
90
|
let(:title) { 'NT Live: Treasure Island' }
|
|
91
91
|
|
|
92
92
|
it 'removes prefix' do
|
|
93
|
-
subject.must_equal('National Theatre: Treasure Island')
|
|
93
|
+
_(subject).must_equal('National Theatre: Treasure Island')
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
|
|
@@ -98,7 +98,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
98
98
|
let(:title) { 'NT Live: A Streetcar Named Desire (Young Vic) - Encore' }
|
|
99
99
|
|
|
100
100
|
it 'removes prefix' do
|
|
101
|
-
subject.must_equal('National Theatre: A Streetcar Named Desire (Young Vic)')
|
|
101
|
+
_(subject).must_equal('National Theatre: A Streetcar Named Desire (Young Vic)')
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
|
|
@@ -106,7 +106,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
106
106
|
let(:title) { 'ROH - I Due Foscari' }
|
|
107
107
|
|
|
108
108
|
it 'removes prefix' do
|
|
109
|
-
subject.must_equal('Royal Opera House: I Due Foscari')
|
|
109
|
+
_(subject).must_equal('Royal Opera House: I Due Foscari')
|
|
110
110
|
end
|
|
111
111
|
end
|
|
112
112
|
|
|
@@ -114,7 +114,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
114
114
|
let(:title) { "RSC Live: Love's Labour's Lost" }
|
|
115
115
|
|
|
116
116
|
it 'removes prefix' do
|
|
117
|
-
subject.must_equal("Royal Shakespeare Company: Love's Labour's Lost")
|
|
117
|
+
_(subject).must_equal("Royal Shakespeare Company: Love's Labour's Lost")
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
|
|
@@ -122,7 +122,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
122
122
|
let(:title) { 'SciScreen: Dallas Buyers Club' }
|
|
123
123
|
|
|
124
124
|
it 'removes prefix' do
|
|
125
|
-
subject.must_equal('Dallas Buyers Club')
|
|
125
|
+
_(subject).must_equal('Dallas Buyers Club')
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
|
|
@@ -130,7 +130,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
130
130
|
let(:title) { 'Billy Elliot The Musical Live - Special Performance' }
|
|
131
131
|
|
|
132
132
|
it 'removes prefix' do
|
|
133
|
-
subject.must_equal('Billy Elliot The Musical Live')
|
|
133
|
+
_(subject).must_equal('Billy Elliot The Musical Live')
|
|
134
134
|
end
|
|
135
135
|
end
|
|
136
136
|
|
|
@@ -138,7 +138,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
138
138
|
let(:title) { 'Take 2 - Boyhood' }
|
|
139
139
|
|
|
140
140
|
it 'removes prefix' do
|
|
141
|
-
subject.must_equal('Boyhood')
|
|
141
|
+
_(subject).must_equal('Boyhood')
|
|
142
142
|
end
|
|
143
143
|
end
|
|
144
144
|
|
|
@@ -146,7 +146,7 @@ describe CineworldUk::Internal::TitleSanitizer do
|
|
|
146
146
|
let(:title) { 'Frozen Sing-Along - Movies For Juniors' }
|
|
147
147
|
|
|
148
148
|
it 'removes prefix' do
|
|
149
|
-
subject.must_equal('Frozen')
|
|
149
|
+
_(subject).must_equal('Frozen')
|
|
150
150
|
end
|
|
151
151
|
end
|
|
152
152
|
end
|
|
@@ -11,52 +11,51 @@ describe CineworldUk::Performance do
|
|
|
11
11
|
after { WebMock.allow_net_connect! }
|
|
12
12
|
|
|
13
13
|
describe '.at(cinema_id)' do
|
|
14
|
-
subject
|
|
14
|
+
subject do
|
|
15
|
+
described_class.at(cinema_id, from: Date.today + 1, to: Date.today + 1)
|
|
16
|
+
end
|
|
15
17
|
|
|
16
18
|
before do
|
|
17
19
|
api_response.expect(:cinema_list, cinema_list_json)
|
|
18
|
-
api_response.expect(:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
api_response.expect(:performances,
|
|
22
|
-
performances_tomorrow_json(3),
|
|
23
|
-
[3, Date.today + 1])
|
|
20
|
+
4.times { api_response.expect(:performances,
|
|
21
|
+
performances_tomorrow_json(14),
|
|
22
|
+
[14, Date.today + 1]) }
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
describe 'called with integer' do
|
|
27
|
-
let(:cinema_id) {
|
|
26
|
+
let(:cinema_id) { 14 }
|
|
28
27
|
|
|
29
28
|
it 'returns an array of performances' do
|
|
30
29
|
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
|
31
|
-
subject.must_be_instance_of(Array)
|
|
30
|
+
_(subject).must_be_instance_of(Array)
|
|
32
31
|
subject.each do |performance|
|
|
33
|
-
performance.must_be_instance_of(described_class)
|
|
32
|
+
_(performance).must_be_instance_of(described_class)
|
|
34
33
|
end
|
|
35
34
|
end
|
|
36
35
|
end
|
|
37
36
|
|
|
38
37
|
it 'returns at least a sensible number' do
|
|
39
38
|
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
|
40
|
-
subject.count.must_be :>, 5
|
|
39
|
+
_(subject.count).must_be :>, 5
|
|
41
40
|
end
|
|
42
41
|
end
|
|
43
42
|
end
|
|
44
43
|
|
|
45
44
|
describe 'called with string' do
|
|
46
|
-
let(:cinema_id) { '
|
|
45
|
+
let(:cinema_id) { '14' }
|
|
47
46
|
|
|
48
47
|
it 'returns an array of performances' do
|
|
49
48
|
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
|
50
|
-
subject.must_be_instance_of(Array)
|
|
49
|
+
_(subject).must_be_instance_of(Array)
|
|
51
50
|
subject.each do |performance|
|
|
52
|
-
performance.must_be_instance_of(described_class)
|
|
51
|
+
_(performance).must_be_instance_of(described_class)
|
|
53
52
|
end
|
|
54
53
|
end
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
it 'returns at least a sensible number' do
|
|
58
57
|
CineworldUk::Internal::ApiResponse.stub :new, api_response do
|
|
59
|
-
subject.count.must_be :>, 5
|
|
58
|
+
_(subject.count).must_be :>, 5
|
|
60
59
|
end
|
|
61
60
|
end
|
|
62
61
|
end
|
|
@@ -76,14 +75,14 @@ describe CineworldUk::Performance do
|
|
|
76
75
|
end
|
|
77
76
|
|
|
78
77
|
it 'sets cinema name and film name' do
|
|
79
|
-
subject.film_name.must_equal 'Iron Man 3'
|
|
80
|
-
subject.cinema_name.must_equal 'Cineworld Brighton'
|
|
78
|
+
_(subject.film_name).must_equal 'Iron Man 3'
|
|
79
|
+
_(subject.cinema_name).must_equal 'Cineworld Brighton'
|
|
81
80
|
end
|
|
82
81
|
|
|
83
82
|
it 'booking url, dimension & varient are set to defaults' do
|
|
84
|
-
subject.booking_url.
|
|
85
|
-
subject.dimension.must_equal '2d'
|
|
86
|
-
subject.variant.must_equal []
|
|
83
|
+
_(subject.booking_url).must_be_nil
|
|
84
|
+
_(subject.dimension).must_equal '2d'
|
|
85
|
+
_(subject.variant).must_equal []
|
|
87
86
|
end
|
|
88
87
|
end
|
|
89
88
|
end
|
|
@@ -102,8 +101,8 @@ describe CineworldUk::Performance do
|
|
|
102
101
|
subject { described_class.new(options).dimension }
|
|
103
102
|
|
|
104
103
|
it 'returns 2d or 3d' do
|
|
105
|
-
subject.must_be_instance_of(String)
|
|
106
|
-
subject.must_equal '3d'
|
|
104
|
+
_(subject).must_be_instance_of(String)
|
|
105
|
+
_(subject).must_equal '3d'
|
|
107
106
|
end
|
|
108
107
|
end
|
|
109
108
|
|
|
@@ -121,8 +120,8 @@ describe CineworldUk::Performance do
|
|
|
121
120
|
end
|
|
122
121
|
|
|
123
122
|
it 'returns UTC time' do
|
|
124
|
-
subject.must_be_instance_of Time
|
|
125
|
-
subject.must_equal Time.utc(2013, 9, 12, 11, 0)
|
|
123
|
+
_(subject).must_be_instance_of Time
|
|
124
|
+
_(subject).must_equal Time.utc(2013, 9, 12, 11, 0)
|
|
126
125
|
end
|
|
127
126
|
end
|
|
128
127
|
|
|
@@ -137,9 +136,9 @@ describe CineworldUk::Performance do
|
|
|
137
136
|
end
|
|
138
137
|
|
|
139
138
|
it 'returns UTC time' do
|
|
140
|
-
subject.must_be_instance_of Time
|
|
141
|
-
subject.must_equal Time.utc(2013, 9, 12, 10, 0)
|
|
142
|
-
subject.utc
|
|
139
|
+
_(subject).must_be_instance_of Time
|
|
140
|
+
_(subject).must_equal Time.utc(2013, 9, 12, 10, 0)
|
|
141
|
+
_(subject.utc?).must_equal(true)
|
|
143
142
|
end
|
|
144
143
|
end
|
|
145
144
|
end
|
|
@@ -157,8 +156,8 @@ describe CineworldUk::Performance do
|
|
|
157
156
|
subject { described_class.new(options).showing_on }
|
|
158
157
|
|
|
159
158
|
it 'returns date of showing' do
|
|
160
|
-
subject.must_be_instance_of(Date)
|
|
161
|
-
subject.must_equal Date.new(2013, 9, 12)
|
|
159
|
+
_(subject).must_be_instance_of(Date)
|
|
160
|
+
_(subject).must_equal Date.new(2013, 9, 12)
|
|
162
161
|
end
|
|
163
162
|
end
|
|
164
163
|
|
|
@@ -176,9 +175,9 @@ describe CineworldUk::Performance do
|
|
|
176
175
|
end
|
|
177
176
|
|
|
178
177
|
it 'is an alphabetically ordered array of lower-cased strings' do
|
|
179
|
-
subject.must_be_instance_of Array
|
|
180
|
-
subject.each { |element| element.must_be_instance_of String }
|
|
181
|
-
subject.must_equal %w(kids)
|
|
178
|
+
_(subject).must_be_instance_of Array
|
|
179
|
+
subject.each { |element| _(element).must_be_instance_of String }
|
|
180
|
+
_(subject).must_equal %w(kids)
|
|
182
181
|
end
|
|
183
182
|
end
|
|
184
183
|
end
|
|
@@ -6,6 +6,7 @@ Minitest::Reporters.use! [
|
|
|
6
6
|
]
|
|
7
7
|
|
|
8
8
|
require File.expand_path('../../../lib/cineworld_uk.rb', __FILE__)
|
|
9
|
+
CineworldUk.token = ENV.fetch("CINEWORLD_TOKEN")
|
|
9
10
|
|
|
10
11
|
describe CineworldUk::Cinema do
|
|
11
12
|
let(:described_class) { CineworldUk::Cinema }
|
|
@@ -14,19 +15,18 @@ describe CineworldUk::Cinema do
|
|
|
14
15
|
subject { described_class.all }
|
|
15
16
|
|
|
16
17
|
it 'returns an Array of CineworldUK::Cinemas' do
|
|
17
|
-
subject.must_be_instance_of(Array)
|
|
18
|
+
_(subject).must_be_instance_of(Array)
|
|
18
19
|
subject.each do |value|
|
|
19
|
-
value.must_be_instance_of(CineworldUk::Cinema)
|
|
20
|
+
_(value).must_be_instance_of(CineworldUk::Cinema)
|
|
20
21
|
end
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
it 'returns the correctly sized array' do
|
|
24
|
-
subject.size.must_be :>, 18
|
|
25
|
+
_(subject.size).must_be :>, 18
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
it 'returns the right cinemas' do
|
|
28
|
-
subject.
|
|
29
|
-
subject.last.name.must_equal 'Yeovil'
|
|
29
|
+
_(subject.detect { |cinema| cinema.id == 14 }.name).must_equal "Brighton"
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -35,17 +35,17 @@ describe CineworldUk::Performance do
|
|
|
35
35
|
let(:described_class) { CineworldUk::Performance }
|
|
36
36
|
|
|
37
37
|
describe '.at(cinema_id)' do
|
|
38
|
-
subject { described_class.at(
|
|
38
|
+
subject { described_class.at(14, from: Date.today + 1, to: Date.today + 1) }
|
|
39
39
|
|
|
40
40
|
it 'returns an array of screenings' do
|
|
41
|
-
subject.must_be_instance_of(Array)
|
|
41
|
+
_(subject).must_be_instance_of(Array)
|
|
42
42
|
subject.each do |performance|
|
|
43
|
-
performance.must_be_instance_of(CineworldUk::Performance)
|
|
43
|
+
_(performance).must_be_instance_of(CineworldUk::Performance)
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it 'returns correct number of screenings' do
|
|
48
|
-
subject.count.must_be :>, 10
|
|
48
|
+
_(subject.count).must_be :>, 10
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Run separately after building: CINEWORLD_PACKAGE=pkg/...gem bundle exec ruby test/package_test.rb
|
|
2
|
+
require "minitest/autorun"
|
|
3
|
+
require "rubygems/installer"
|
|
4
|
+
require "tmpdir"
|
|
5
|
+
require "fileutils"
|
|
6
|
+
require "open3"
|
|
7
|
+
require "base64"
|
|
8
|
+
require "json"
|
|
9
|
+
|
|
10
|
+
describe "Platform package" do
|
|
11
|
+
before do
|
|
12
|
+
@directory = Dir.mktmpdir("cineworld-package-test")
|
|
13
|
+
@spec = Gem::Installer.at(
|
|
14
|
+
ENV.fetch("CINEWORLD_PACKAGE"), install_dir: @directory, ignore_dependencies: true
|
|
15
|
+
).install
|
|
16
|
+
@vendor = File.join(@spec.full_gem_path, "vendor", "curl-impersonate")
|
|
17
|
+
@binary = File.join(@vendor, "bin", "curl-impersonate")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
after do
|
|
21
|
+
FileUtils.remove_entry(@directory)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "installs a runnable executable with upstream notices and provenance" do
|
|
25
|
+
assert File.executable?(@binary)
|
|
26
|
+
output, status = Open3.capture2(@binary, "--version")
|
|
27
|
+
assert status.success?
|
|
28
|
+
assert_includes output, "curl"
|
|
29
|
+
assert File.file?(File.join(@vendor, "licenses", "LICENSE_CURL"))
|
|
30
|
+
assert_includes File.read(File.join(@vendor, "SOURCE")), "2.2.3"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "acquires a token using the gem-local executable without any curl on PATH" do
|
|
34
|
+
payload = Base64.urlsafe_encode64(JSON.generate("exp" => Time.now.to_i + 3600), padding: false)
|
|
35
|
+
token = "header.#{payload}.signature"
|
|
36
|
+
data = { "props" => { "pageProps" => { "environment" => { "gasToken" => token } } } }
|
|
37
|
+
page = "<script id='__NEXT_DATA__'>#{JSON.generate(data)}</script>\n200"
|
|
38
|
+
# Substitute only the network response, not the installed package's path resolution.
|
|
39
|
+
File.write(@binary, "#!#{RbConfig.ruby}\nSTDOUT.write(#{page.dump})\n")
|
|
40
|
+
output, error, status = Open3.capture3(
|
|
41
|
+
{ "PATH" => @directory, "RUBYOPT" => nil, "BUNDLER_SETUP" => nil,
|
|
42
|
+
"GEM_PATH" => Gem.path.join(File::PATH_SEPARATOR) }, RbConfig.ruby,
|
|
43
|
+
"-I#{File.join(@spec.full_gem_path, 'lib')}", "-rcineworld_uk",
|
|
44
|
+
"-e", "print CineworldUk.acquire_token!"
|
|
45
|
+
)
|
|
46
|
+
assert status.success?, error
|
|
47
|
+
_(output).must_equal token
|
|
48
|
+
end
|
|
49
|
+
end
|