odeon_uk 1.1.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +8 -1
  4. data/README.md +1 -0
  5. data/Rakefile +13 -9
  6. data/lib/odeon_uk/cinema.rb +14 -42
  7. data/lib/odeon_uk/film.rb +23 -5
  8. data/lib/odeon_uk/internal/film_with_screenings_parser.rb +133 -46
  9. data/lib/odeon_uk/internal/showtimes_page.rb +36 -0
  10. data/lib/odeon_uk/internal/title_sanitizer.rb +49 -0
  11. data/lib/odeon_uk/internal/website.rb +36 -0
  12. data/lib/odeon_uk/screening.rb +56 -22
  13. data/lib/odeon_uk/version.rb +2 -2
  14. data/lib/odeon_uk.rb +4 -2
  15. data/odeon_uk.gemspec +0 -1
  16. data/test/fixture_updater.rb +72 -0
  17. data/test/fixtures/{odeon-bfi-imax.html → cinema/bfi_imax.html} +988 -1130
  18. data/test/fixtures/{odeon-brighton.html → cinema/brighton.html} +1035 -761
  19. data/test/fixtures/{odeon-london-leicester-square.html → cinema/leicester_square.html} +470 -766
  20. data/test/fixtures/showtimes/brighton/film_first.html +92 -0
  21. data/test/fixtures/showtimes/brighton/film_last.html +100 -0
  22. data/test/fixtures/showtimes/brighton.html +2071 -0
  23. data/test/fixtures/showtimes/liverpool_one/film_first_dbox.html +188 -0
  24. data/test/fixtures/showtimes/manchester/film_first_imax.html +182 -0
  25. data/test/fixtures/{odeon-sitemap.html → sitemap.html} +572 -444
  26. data/test/lib/odeon_uk/cinema_test.rb +129 -231
  27. data/test/lib/odeon_uk/film_test.rb +50 -3
  28. data/test/lib/odeon_uk/internal/film_with_screenings_parser_test.rb +79 -123
  29. data/test/lib/odeon_uk/internal/showtimes_page_test.rb +51 -0
  30. data/test/lib/odeon_uk/internal/title_sanitizer_test.rb +105 -0
  31. data/test/lib/odeon_uk/internal/website_test.rb +59 -0
  32. data/test/lib/odeon_uk/screening_test.rb +66 -32
  33. metadata +32 -53
  34. data/test/fixtures/brighton-showtimes/about-time.html +0 -175
  35. data/test/fixtures/brighton-showtimes/autism-friendly-planes.html +0 -75
  36. data/test/fixtures/brighton-showtimes/bolshoi-spartacus-live.html +0 -67
  37. data/test/fixtures/brighton-showtimes/cinemagic-echo-planet.html +0 -67
  38. data/test/fixtures/brighton-showtimes/globe-on-screen-twelfth-night.html +0 -67
  39. data/test/fixtures/brighton-showtimes/met-opera-eugene-onegin.html +0 -67
  40. data/test/fixtures/brighton-showtimes/national-theatre-live-frankenstein.html +0 -78
  41. data/test/fixtures/brighton-showtimes/nt-live-war-horse.html +0 -67
  42. data/test/fixtures/brighton-showtimes/royal-opera-house-turandot.html +0 -66
  43. data/test/fixtures/brighton-showtimes/rsc-richard-ii.html +0 -67
  44. data/test/fixtures/brighton-showtimes/star-trek-into-darkness-2d.html +0 -83
  45. data/test/fixtures/brighton-showtimes/ukjff-from-cable-street-to-brick-lane.html +0 -67
  46. data/test/fixtures/manchester-showtimes/thor-the-dark-world.html +0 -300
  47. data/test/fixtures/odeon-brighton-showtimes.html +0 -1238
@@ -1,171 +1,127 @@
1
1
  require_relative '../../../test_helper'
2
2
 
3
3
  describe OdeonUk::Internal::FilmWithScreeningsParser do
4
+ let(:described_class) { OdeonUk::Internal::FilmWithScreeningsParser }
4
5
 
5
6
  describe '#film_name' do
6
- subject { OdeonUk::Internal::FilmWithScreeningsParser.new(film_html).film_name }
7
+ subject { described_class.new(film_html).film_name }
7
8
 
8
- describe 'passed valid film html with simple name' do
9
- let(:film_html) { read_film_html('about-time') }
9
+ describe 'passed first film html' do
10
+ let(:film_html) { read_film_html('brighton/film_first') }
10
11
 
11
- it 'returns the film name' do
12
- subject.must_equal('About Time')
12
+ it 'returns film name' do
13
+ subject.must_equal 'A Most Wanted Man'
13
14
  end
14
15
  end
15
16
 
16
- describe 'passed valid film html with 2d name' do
17
- let(:film_html) { read_film_html('star-trek-into-darkness-2d') }
17
+ describe 'passed last film html' do
18
+ let(:film_html) { read_film_html('brighton/film_last') }
18
19
 
19
- it 'returns the film name' do
20
- subject.must_equal('Star Trek Into Darkness')
20
+ it 'returns film name' do
21
+ subject.must_equal 'The Riot Club'
21
22
  end
22
23
  end
24
+ end
23
25
 
24
- describe 'passed valid film html with autism text' do
25
- let(:film_html) { read_film_html('autism-friendly-planes') }
26
-
27
- it 'returns the film name' do
28
- subject.must_equal('Planes')
29
- end
30
- end
31
-
32
- describe 'passed valid film html with ROH live screening' do
33
- let(:film_html) { read_film_html('royal-opera-house-turandot') }
34
-
35
- it 'returns the film name' do
36
- subject.must_equal('Royal Opera House: Turandot 2013')
37
- end
38
- end
39
-
40
- describe 'passed valid film html with Met Opera screening' do
41
- let(:film_html) { read_film_html('met-opera-eugene-onegin') }
42
-
43
- it 'returns the film name' do
44
- subject.must_equal('Met Opera: Eugene Onegin 2013')
45
- end
46
- end
47
-
48
- describe 'passed valid film html with Met Opera screening' do
49
- let(:film_html) { read_film_html('cinemagic-echo-planet') }
50
-
51
- it 'returns the film name' do
52
- subject.must_equal('Echo Planet')
53
- end
54
- end
55
-
56
- describe 'passed valid film html with UK Jewish Film Festival' do
57
- let(:film_html) { read_film_html('ukjff-from-cable-street-to-brick-lane') }
58
-
59
- it 'returns the film name' do
60
- subject.must_equal('From Cable Street To Brick Lane')
61
- end
62
- end
26
+ describe '#to_a' do
27
+ subject { described_class.new(film_html).to_a }
63
28
 
64
- describe 'passed valid film html with NT Encore' do
65
- let(:film_html) { read_film_html('national-theatre-live-frankenstein') }
29
+ describe 'passed first film html' do
30
+ let(:film_html) { read_film_html('brighton/film_first') }
66
31
 
67
- it 'returns the film name' do
68
- subject.must_equal('National Theatre: Frankenstein')
32
+ it 'returns an array of hashes of screening attributes' do
33
+ subject.must_be_instance_of Array
34
+ subject.each do |hash|
35
+ hash[:booking_url].must_match 'https://www.odeon.co.uk/'
36
+ hash[:dimension].must_match(/[23]d/)
37
+ hash[:film_name].must_be_instance_of String
38
+ hash[:time].must_be_instance_of Time
39
+ hash[:time].zone.must_equal 'UTC'
40
+ end
69
41
  end
70
- end
71
42
 
72
- describe 'passed valid film html with NT Encore' do
73
- let(:film_html) { read_film_html('nt-live-war-horse') }
74
-
75
- it 'returns the film name' do
76
- subject.must_equal('National Theatre: War Horse')
43
+ it 'returns the same film title' do
44
+ first_title = subject[0][:film_name]
45
+ subject.each do |hash|
46
+ hash[:film_name].must_equal first_title
47
+ end
77
48
  end
78
- end
79
-
80
- describe 'passed valid film html with Bolshoi Ballet' do
81
- let(:film_html) { read_film_html('bolshoi-spartacus-live') }
82
49
 
83
- it 'returns the film name' do
84
- subject.must_equal('Bolshoi: Spartacus')
50
+ it 'returns the correct number of screenings' do
51
+ subject.count.must_equal 10
85
52
  end
86
53
  end
87
54
 
88
- describe 'passed valid film html with Globe' do
89
- let(:film_html) { read_film_html('globe-on-screen-twelfth-night') }
90
-
91
- it 'returns the film name' do
92
- subject.must_equal('Globe: Twelfth Night')
55
+ describe 'passed last film html' do
56
+ let(:film_html) { read_film_html('brighton/film_last') }
57
+
58
+ it 'returns an array of hashes of screening attributes' do
59
+ subject.must_be_instance_of Array
60
+ subject.each do |hash|
61
+ hash[:booking_url].must_match 'https://www.odeon.co.uk/'
62
+ hash[:dimension].must_match(/[23]d/)
63
+ hash[:film_name].must_be_instance_of String
64
+ hash[:time].must_be_instance_of Time
65
+ hash[:time].zone.must_equal 'UTC'
66
+ end
93
67
  end
94
- end
95
68
 
96
- describe 'passed valid film html with RSC' do
97
- let(:film_html) { read_film_html('rsc-richard-ii') }
98
-
99
- it 'returns the film name' do
100
- subject.must_equal('Royal Shakespeare Company: Richard II')
69
+ it 'returns at least 1' do
70
+ subject.count.must_be :>=, 1
101
71
  end
102
72
  end
103
- end
104
73
 
105
- describe '#showings' do
106
- subject { OdeonUk::Internal::FilmWithScreeningsParser.new(film_html).showings }
107
-
108
- describe 'passed valid film html' do
109
- let(:film_html) { read_film_html('about-time') }
110
-
111
- it 'returns an hash of variants => array of times' do
112
- subject.must_be_instance_of Hash
113
- subject.each do |key, value|
114
- key.must_equal '2D'
115
- value.must_be_instance_of Array
116
- value.each do |element|
117
- element[0].must_be_instance_of Time
118
- element[0].zone.must_equal 'UTC'
119
- element[1].must_be_instance_of String
120
- element[1].must_match 'http://www.odeon.co.uk/'
121
- end
74
+ describe 'passed imax film html' do
75
+ let(:film_html) { read_film_html('manchester/film_first_imax') }
76
+
77
+ it 'returns an array of hashes of screening attributes' do
78
+ subject.must_be_instance_of Array
79
+ subject.each do |hash|
80
+ hash[:booking_url].must_match 'https://www.odeon.co.uk/'
81
+ hash[:dimension].must_match(/[23]d/)
82
+ hash[:film_name].must_be_instance_of String
83
+ hash[:time].must_be_instance_of Time
84
+ hash[:time].zone.must_equal 'UTC'
122
85
  end
123
86
  end
124
87
 
125
- it 'returns the correct number of screenings' do
126
- subject['2D'].count.must_equal 21
88
+ it 'contains imax in the variant' do
89
+ variants = subject.map { |hash| hash[:variant] }
90
+ variants.must_include('imax')
127
91
  end
128
92
 
129
- it 'returns UTC times for showings' do
130
- # about times are from British Summer Time UTC+1
131
- # the actual show time is 20:30 from the fixture
132
- subject['2D'].last[0].must_equal Time.utc(2013, 9, 19, 19, 30, 0)
93
+ it 'returns at least 1' do
94
+ subject.count.must_be :>=, 1
133
95
  end
134
96
  end
135
97
 
136
- describe 'passed valid film html for multi variants' do
137
- let(:film_html) { read_film_html('thor-the-dark-world', 'manchester') }
138
-
139
- it 'returns an hash of variants => array of times' do
140
- subject.must_be_instance_of Hash
141
- subject.keys.must_equal ['2D', 'IMAX 3D', '3D']
142
- subject.values.each do |value|
143
- value.must_be_instance_of Array
144
- value.each do |element|
145
- element[0].must_be_instance_of Time
146
- element[0].zone.must_equal 'UTC'
147
- element[1].must_be_instance_of String
148
- element[1].must_match 'http://www.odeon.co.uk/'
149
- end
98
+ describe 'passed d-box film html' do
99
+ let(:film_html) { read_film_html('liverpool_one/film_first_dbox') }
100
+
101
+ it 'returns an array of hashes of screening attributes' do
102
+ subject.must_be_instance_of Array
103
+ subject.each do |hash|
104
+ hash[:booking_url].must_match 'https://www.odeon.co.uk/'
105
+ hash[:dimension].must_match(/[23]d/)
106
+ hash[:film_name].must_be_instance_of String
107
+ hash[:time].must_be_instance_of Time
108
+ hash[:time].zone.must_equal 'UTC'
150
109
  end
151
110
  end
152
111
 
153
- it 'returns the correct number of screenings' do
154
- subject['2D'].count.must_equal 1
155
- subject['3D'].count.must_equal 1
156
- subject['IMAX 3D'].count.must_equal 37
112
+ it 'contains d-box in the variant' do
113
+ variants = subject.map { |hash| hash[:variant] }
114
+ variants.must_include('d-box')
157
115
  end
158
116
 
159
- it 'returns UTC times for showings' do
160
- # about times are from GMT
161
- # the actual show time is 00:01 from the fixture
162
- subject['2D'].last[0].must_equal Time.utc(2013, 10, 30, 0, 1, 0)
117
+ it 'returns at least 1' do
118
+ subject.count.must_be :>=, 1
163
119
  end
164
120
  end
165
121
  end
166
122
 
167
- def read_film_html(filename, cinema='brighton')
168
- path = "../../../../fixtures/#{cinema}-showtimes"
123
+ def read_film_html(filename)
124
+ path = '../../../../fixtures/showtimes'
169
125
  File.read(File.expand_path("#{path}/#{filename}.html", __FILE__))
170
126
  end
171
127
  end
@@ -0,0 +1,51 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ describe OdeonUk::Internal::ShowtimesPage do
4
+ let(:described_class) { OdeonUk::Internal::ShowtimesPage }
5
+
6
+ let(:website) { Minitest::Mock.new }
7
+
8
+ before { WebMock.disable_net_connect! }
9
+
10
+ describe '#to_a' do
11
+ subject { described_class.new(71).to_a }
12
+
13
+ before do
14
+ website.expect(:showtimes, brighton_showtimes_html, [71])
15
+ end
16
+
17
+ it 'returns an non-zero array of film screenings html fragments' do
18
+ OdeonUk::Internal::Website.stub :new, website do
19
+ subject.must_be_instance_of(Array)
20
+ subject.size.must_be :>, 0
21
+
22
+ subject.each do |film_html|
23
+ film_html.must_be_instance_of(String)
24
+ film_html.size.must_be :>, 0
25
+ end
26
+ end
27
+ end
28
+
29
+ it 'returns an array with correct content' do
30
+ OdeonUk::Internal::Website.stub :new, website do
31
+ subject.each do |html|
32
+ html.must_include('class="film-detail') # screenings group
33
+ html.must_include('class="presentation-info') # title
34
+ html.must_include('class="WEEK') # a performance
35
+ html.must_include('data-start="') # start time
36
+ html.must_include('data-end="') # end time
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def read_file(filepath)
45
+ File.read(File.expand_path(filepath, __FILE__))
46
+ end
47
+
48
+ def brighton_showtimes_html
49
+ read_file('../../../../fixtures/showtimes/brighton.html')
50
+ end
51
+ end
@@ -0,0 +1,105 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ describe OdeonUk::Internal::TitleSanitizer do
4
+ let(:described_class) { OdeonUk::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 'Austism screening' do
26
+ let(:title) { 'Autism Friendly Screening - Planes' }
27
+
28
+ it 'removes prefix' do
29
+ subject.must_equal('Planes')
30
+ end
31
+ end
32
+
33
+ describe 'Bolshoi screeening' do
34
+ let(:title) { 'Bolshoi - Spartacus (Live)' }
35
+
36
+ it 'removes prefix' do
37
+ subject.must_equal('Bolshoi: Spartacus')
38
+ end
39
+ end
40
+
41
+ describe 'Cinemagic screeening' do
42
+ let(:title) { 'Cinemagic 2013 - Echo Planet' }
43
+
44
+ it 'removes prefix' do
45
+ subject.must_equal('Echo Planet')
46
+ end
47
+ end
48
+
49
+ describe 'Globe on Screen screeening' do
50
+ let(:title) { 'Globe On Screen: Twelfth Night' }
51
+
52
+ it 'removes prefix' do
53
+ subject.must_equal('Globe: Twelfth Night')
54
+ end
55
+ end
56
+
57
+ describe 'Met Opera screeening' do
58
+ let(:title) { 'Met Opera - Eugene Onegin 2013' }
59
+
60
+ it 'removes prefix' do
61
+ subject.must_equal('Met Opera: Eugene Onegin 2013')
62
+ end
63
+ end
64
+
65
+ describe 'NT Live screeening' do
66
+ let(:title) { 'NT Live - War Horse' }
67
+
68
+ it 'removes prefix' do
69
+ subject.must_equal('National Theatre: War Horse')
70
+ end
71
+ end
72
+
73
+ describe 'National Theatre screeening' do
74
+ let(:title) { 'National Theatre Live - Frankenstein (Encore Screening)' }
75
+
76
+ it 'removes prefix' do
77
+ subject.must_equal('National Theatre: Frankenstein')
78
+ end
79
+ end
80
+
81
+ describe 'ROH screeening' do
82
+ let(:title) { 'Autism Friendly Screening - Planes' }
83
+
84
+ it 'removes prefix' do
85
+ subject.must_equal('Planes')
86
+ end
87
+ end
88
+
89
+ describe 'RSC screeening' do
90
+ let(:title) { 'Richard II - RSC Live 2013' }
91
+
92
+ it 'removes prefix' do
93
+ subject.must_equal('Royal Shakespeare Company: Richard II')
94
+ end
95
+ end
96
+
97
+ describe 'UK Jewish FF screeening' do
98
+ let(:title) { 'UKJFF - From Cable Street To Brick Lane' }
99
+
100
+ it 'removes prefix' do
101
+ subject.must_equal('From Cable Street To Brick Lane')
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,59 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ describe OdeonUk::Internal::Website do
4
+ let(:described_class) { OdeonUk::Internal::Website }
5
+
6
+ describe '#cinema(id)' do
7
+ subject { described_class.new.cinema(71) }
8
+
9
+ before { stub_get('cinemas/odeon/71/', brighton_cinema_html) }
10
+
11
+ it 'returns a string' do
12
+ subject.class.must_equal String
13
+ end
14
+ end
15
+
16
+ describe '#sitemap' do
17
+ subject { described_class.new.sitemap }
18
+
19
+ before { stub_get('sitemap/', sitemap_html) }
20
+
21
+ it 'returns a string' do
22
+ subject.class.must_equal String
23
+ end
24
+ end
25
+
26
+ describe '#showtimes(id)' do
27
+ subject { described_class.new.showtimes(71) }
28
+
29
+ before { stub_get('showtimes/week/71/?siteId=71', brighton_showtimes_html) }
30
+
31
+ it 'returns a string' do
32
+ subject.class.must_equal String
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def brighton_cinema_html
39
+ read_file('../../../../fixtures/cinema/brighton.html')
40
+ end
41
+
42
+ def brighton_showtimes_html
43
+ read_file('../../../../fixtures/showtimes/brighton.html')
44
+ end
45
+
46
+ def read_file(filepath)
47
+ File.read(File.expand_path(filepath, __FILE__))
48
+ end
49
+
50
+ def sitemap_html
51
+ read_file('../../../../fixtures/sitemap.html')
52
+ end
53
+
54
+ def stub_get(site_path, response_body)
55
+ url = "http://www.odeon.co.uk/#{site_path}"
56
+ response = { status: 200, body: response_body, headers: {} }
57
+ stub_request(:get, url).to_return(response)
58
+ end
59
+ end
@@ -1,53 +1,87 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
3
  describe OdeonUk::Screening do
4
+ let(:described_class) { OdeonUk::Screening }
5
+
6
+ let(:website) { Minitest::Mock.new }
4
7
 
5
8
  before { WebMock.disable_net_connect! }
6
9
 
7
- describe '#new film_name, cinema_name, date, time, variant' do
8
- it 'stores film_name, cinema_name & when (in UTC)' do
9
- screening = OdeonUk::Screening.new 'Iron Man 3', 'Brighton', Time.parse('2013-09-12 12:00') # non-UTC time
10
- screening.film_name.must_equal 'Iron Man 3'
11
- screening.cinema_name.must_equal 'Brighton'
12
- screening.when.must_equal Time.utc(2013, 9, 12, 11, 0)
13
- screening.booking_url.must_equal nil
14
- screening.variant.must_equal nil
10
+ describe '.at(cinema_id)' do
11
+ subject { described_class.at(71) }
12
+
13
+ before do
14
+ website.expect(:showtimes, brighton_showtimes_html, [71])
15
+ website.expect(:sitemap, sitemap_html)
15
16
  end
16
17
 
17
- it 'stores variant if passed' do
18
- screening = OdeonUk::Screening.new 'Iron Man 3', 'Brighton', Time.utc(2013, 9, 12, 11, 0), nil, '3d'
19
- screening.film_name.must_equal 'Iron Man 3'
20
- screening.cinema_name.must_equal 'Brighton'
21
- screening.when.must_equal Time.utc(2013, 9, 12, 11, 0)
22
- screening.booking_url.must_equal nil
23
- screening.variant.must_equal '3d'
18
+ it 'returns an array of screenings' do
19
+ OdeonUk::Internal::Website.stub :new, website do
20
+ subject.must_be_instance_of(Array)
21
+ subject.each do |screening|
22
+ screening.must_be_instance_of(described_class)
23
+ end
24
+ end
24
25
  end
25
26
 
26
- it 'stores booking_url if passed' do
27
- screening = OdeonUk::Screening.new 'Iron Man 3', 'Brighton', Time.utc(2013, 9, 12, 11, 0), 'http://booking_url'
28
- screening.film_name.must_equal 'Iron Man 3'
29
- screening.cinema_name.must_equal 'Brighton'
30
- screening.when.must_equal Time.utc(2013, 9, 12, 11, 0)
31
- screening.when.must_equal Time.utc(2013, 9, 12, 11, 0)
32
- screening.booking_url.must_equal 'http://booking_url'
33
- screening.variant.must_equal nil
27
+ it 'returns correct number of screenings' do
28
+ OdeonUk::Internal::Website.stub :new, website do
29
+ subject.count.must_equal 214
30
+ end
34
31
  end
35
32
  end
36
33
 
37
- describe '#date' do
38
- subject { OdeonUk::Screening.new('Iron Man 3', 'Brighton', Time.utc(2013, 9, 12, 11, 0), '3d').date }
39
- it 'should return date of showing' do
34
+ describe '#showing_on' do
35
+ subject { described_class.new(options).showing_on }
36
+
37
+ let(:options) do
38
+ {
39
+ film_name: 'Guardians of the Galaxy',
40
+ cinema_id: 71,
41
+ cinema_name: 'Odeon Brighton',
42
+ time: Time.utc(2014, 9, 12, 11, 0),
43
+ }
44
+ end
45
+
46
+ it 'should return date of screening' do
40
47
  subject.must_be_instance_of(Date)
41
- subject.must_equal Date.new(2013, 9, 12)
48
+ subject.must_equal Date.new(2014, 9, 12)
42
49
  end
43
50
  end
44
51
 
45
- describe '#varient (DEPRECATED)' do
46
- subject { screening.varient }
47
- let(:screening) { OdeonUk::Screening.new('Iron Man 3', 'Brighton', Time.utc(2013, 9, 12, 11, 0), nil, '3d') }
52
+ describe '#variant' do
53
+ subject { described_class.new(options).variant }
54
+
55
+ let(:options) do
56
+ {
57
+ film_name: 'Guardians of the Galaxy',
58
+ cinema_id: 71,
59
+ cinema_name: 'Odeon Brighton',
60
+ time: Time.utc(2014, 9, 12, 11, 0),
61
+ variant: ['Kids', 'BABY']
62
+ }
63
+ end
48
64
 
49
- it 'should return variant' do
50
- subject.must_equal '3d'
65
+ it 'is an alphabetically ordered array of lower-cased strings' do
66
+ subject.must_be_instance_of Array
67
+ subject.each do |tag|
68
+ tag.must_be_instance_of String
69
+ end
70
+ subject.must_equal %w(baby kids)
51
71
  end
52
72
  end
73
+
74
+ private
75
+
76
+ def brighton_showtimes_html
77
+ read_file('../../../fixtures/showtimes/brighton.html')
78
+ end
79
+
80
+ def read_file(filepath)
81
+ File.read(File.expand_path(filepath, __FILE__))
82
+ end
83
+
84
+ def sitemap_html
85
+ read_file('../../../fixtures/sitemap.html')
86
+ end
53
87
  end