cineworld_uk 1.0.5 → 2.0.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +64 -0
  4. data/README.md +2 -1
  5. data/cineworld_uk.gemspec +3 -3
  6. data/lib/cineworld_uk/cinema.rb +60 -69
  7. data/lib/cineworld_uk/film.rb +25 -7
  8. data/lib/cineworld_uk/internal/film_with_screenings_parser.rb +29 -71
  9. data/lib/cineworld_uk/internal/name_parser.rb +20 -18
  10. data/lib/cineworld_uk/internal/screening_parser.rb +132 -0
  11. data/lib/cineworld_uk/internal/titleize.rb +19 -19
  12. data/lib/cineworld_uk/internal/website.rb +33 -0
  13. data/lib/cineworld_uk/internal/whatson_parser.rb +44 -0
  14. data/lib/cineworld_uk/screening.rb +65 -20
  15. data/lib/cineworld_uk/version.rb +2 -2
  16. data/lib/cineworld_uk.rb +4 -0
  17. data/test/fixture_updater.rb +64 -0
  18. data/test/fixtures/cinemas.html +134 -41
  19. data/test/fixtures/{cinemas/bury-st-edmunds.html → information/brighton.html} +488 -437
  20. data/test/fixtures/{cinemas → information}/bristol.html +463 -410
  21. data/test/fixtures/whatson/brighton/film_first.html +775 -0
  22. data/test/fixtures/whatson/brighton/film_last.html +52 -0
  23. data/test/fixtures/whatson/brighton/film_second.html +645 -0
  24. data/test/fixtures/whatson/brighton.html +3564 -2690
  25. data/test/fixtures/whatson/glasgow-imax-at-gsc/film_first.html +140 -0
  26. data/test/fixtures/whatson/the-o2-greenwich/film_first.html +1242 -0
  27. data/test/lib/cineworld_uk/cinema_test.rb +104 -301
  28. data/test/lib/cineworld_uk/film_test.rb +49 -2
  29. data/test/lib/cineworld_uk/internal/film_with_screenings_parser_test.rb +83 -81
  30. data/test/lib/cineworld_uk/internal/titleize_test.rb +12 -5
  31. data/test/lib/cineworld_uk/internal/website_test.rb +57 -0
  32. data/test/lib/cineworld_uk/internal/whatson_parser_test.rb +58 -0
  33. data/test/lib/cineworld_uk/screening_test.rb +155 -23
  34. data/test/lib/cineworld_uk/version_test.rb +1 -1
  35. data/test/test_helper.rb +3 -1
  36. metadata +30 -33
  37. data/test/fixtures/cinemas/brighton.html +0 -8
  38. data/test/fixtures/cinemas/chelsea.html +0 -1030
  39. data/test/fixtures/cinemas/glasgow-imax-at-gsc.html +0 -916
  40. data/test/fixtures/cinemas/the-o2-grenwich.html +0 -1191
  41. data/test/fixtures/whatson/brighton/gravity.html +0 -2129
  42. data/test/fixtures/whatson/glasgow-imax-at-gsc/the-hunger-games-catching-fire.html +0 -498
  43. data/test/fixtures/whatson/glasgow-imax-at-gsc-cinema.html +0 -3160
  44. data/test/fixtures/whatson/the-o2-greenwich/gravity.html +0 -784
  45. data/test/fixtures/whatson/the-o2-greenwich/the-hobbit-desolation-of-smaug.html +0 -764
  46. data/test/fixtures/whatson/the-o2-greenwich.html +0 -6854
  47. data/test/fixtures/whatson/wandsworth.html +0 -13729
@@ -1,127 +1,129 @@
1
1
  require_relative '../../../test_helper'
2
2
 
3
3
  describe CineworldUk::Internal::FilmWithScreeningsParser do
4
+ let(:described_class) { CineworldUk::Internal::FilmWithScreeningsParser }
4
5
 
5
- describe '#film_name' do
6
- subject { CineworldUk::Internal::FilmWithScreeningsParser.new(film_html).film_name }
6
+ describe '#cinema_id' do
7
+ subject { described_class.new(film_html).cinema_id }
7
8
 
8
- describe 'passed valid film html with simple name' do
9
- let(:film_html) { read_film_html('brighton/gravity') }
9
+ describe 'passed film html from top of page' do
10
+ let(:film_html) { read_film_html('brighton/film_first') }
10
11
 
11
- it 'returns the film name' do
12
- subject.must_equal('Gravity')
12
+ it 'returns the id' do
13
+ subject.must_equal(3)
13
14
  end
14
15
  end
15
- end
16
-
17
- describe '#showings' do
18
- subject { CineworldUk::Internal::FilmWithScreeningsParser.new(film_html).showings }
19
16
 
20
- describe 'passed valid film html in headline position' do
21
- let(:film_html) { read_film_html('brighton/gravity') }
17
+ describe 'passed second html from page' do
18
+ let(:film_html) { read_film_html('brighton/film_second') }
22
19
 
23
- it 'returns a hash keyed by type of performance' do
24
- subject.must_be_instance_of Hash
25
- subject.keys.each { |key| key.must_be_instance_of String }
20
+ it 'returns the id' do
21
+ subject.must_equal(3)
26
22
  end
23
+ end
27
24
 
28
- it 'returns an array of Times for each type of performance' do
29
- subject.each do |key, value|
30
- value.must_be_instance_of Array
31
- value.each do |array|
32
- array.must_be_instance_of Array
33
- array[0].must_be_instance_of Time
34
- array[1].must_be_instance_of String
35
- end
36
- end
37
- end
25
+ describe 'passed last html from end of page' do
26
+ let(:film_html) { read_film_html('brighton/film_last') }
38
27
 
39
- it 'returns the correct number of Times' do
40
- subject.keys.must_equal ['2D', '3D']
41
- subject['2D'].count.must_equal 49
42
- subject['3D'].count.must_equal 89
28
+ it 'returns the id' do
29
+ subject.must_equal(3)
43
30
  end
31
+ end
32
+ end
44
33
 
45
- it 'returns Times in UTC' do
46
- subject['2D'].first[0].must_equal Time.utc(2013, 11, 13, 12, 0, 0)
47
- subject['2D'].last[0].must_equal Time.utc(2013, 11, 21, 20, 30, 0)
48
-
49
- subject['3D'].first[0].must_equal Time.utc(2013, 11, 13, 12, 50, 0)
50
- subject['3D'].last[0].must_equal Time.utc(2013, 11, 21, 17, 45, 0)
51
- end
34
+ describe '#film_name' do
35
+ subject { described_class.new(film_html).film_name }
52
36
 
53
- it 'returns booking urls' do
54
- subject['2D'].first[1].must_equal 'http://www.cineworld.co.uk/booking?cinema=3&filmEdi=39755&date=20131113&time=12:00'
55
- subject['2D'].last[1].must_equal 'http://www.cineworld.co.uk/booking?cinema=3&filmEdi=43483&date=20131121&time=20:30'
37
+ describe 'passed film html from top of page' do
38
+ let(:film_html) { read_film_html('brighton/film_first') }
56
39
 
57
- subject['3D'].first[1].must_equal 'http://www.cineworld.co.uk/booking?cinema=3&filmEdi=39755&date=20131113&time=12:50'
58
- subject['3D'].last[1].must_equal 'http://www.cineworld.co.uk/booking?cinema=3&filmEdi=43483&date=20131121&time=17:45'
40
+ it 'returns the film name' do
41
+ subject.must_be_instance_of(String)
42
+ subject.must_equal('Dawn of the Planet of the Apes')
59
43
  end
60
44
  end
61
45
 
62
- describe 'passed valid film html in headline position with crazy screens' do
63
- let(:film_html) { read_film_html('the-o2-greenwich/gravity') }
46
+ describe 'passed film html from page' do
47
+ let(:film_html) { read_film_html('brighton/film_second') }
64
48
 
65
- it 'returns the correct number of Times' do
66
- subject.keys.sort.must_equal ['2D', '3D', '3D D-BOX']
67
- subject['2D'].count.must_equal 5
68
- subject['3D'].count.must_equal 24
69
- subject['3D D-BOX'].count.must_equal 19
49
+ it 'returns the film name' do
50
+ subject.must_be_instance_of(String)
51
+ subject.must_equal('How To Train Your Dragon 2')
70
52
  end
53
+ end
71
54
 
72
- it 'returns Times in UTC' do
73
- subject['2D'].first[0].must_equal Time.utc(2013, 11, 18, 15, 30, 0)
74
- subject['2D'].last[0].must_equal Time.utc(2013, 11, 21, 18, 35, 0)
75
-
76
- subject['3D'].first[0].must_equal Time.utc(2013, 11, 16, 22, 15, 0)
77
- subject['3D'].last[0].must_equal Time.utc(2013, 11, 21, 21, 0, 0)
55
+ describe 'passed film html from end of page' do
56
+ let(:film_html) { read_film_html('brighton/film_last') }
78
57
 
79
- subject['3D D-BOX'].first[0].must_equal Time.utc(2013, 11, 17, 11, 30, 0)
80
- subject['3D D-BOX'].last[0].must_equal Time.utc(2013, 11, 20, 19, 0, 0)
58
+ it 'returns the film name' do
59
+ subject.must_be_instance_of(String)
60
+ subject.must_equal('The Royal Ballet - Manon')
81
61
  end
82
62
  end
63
+ end
83
64
 
84
- describe 'passed valid film html in headline position with 2d imax' do
85
- let(:film_html) { read_film_html('glasgow-imax-at-gsc/the-hunger-games-catching-fire') }
65
+ describe '#to_a' do
66
+ subject { described_class.new(film_html).to_a }
86
67
 
87
- it 'returns the correct number of Times' do
88
- subject.keys.sort.must_equal ['2D IMAX']
89
- subject['2D IMAX'].count.must_equal 27
68
+ describe 'passed film html from top of page' do
69
+ let(:film_html) { read_film_html('brighton/film_first') }
70
+ let(:permitted_types) { %w(baby hfr kids) }
71
+
72
+ it 'returns a non-zero array of hashes' do
73
+ subject.must_be_instance_of(Array)
74
+ subject.size.must_be :>=, 1
75
+ subject.each do |hash|
76
+ hash.must_be_instance_of(Hash)
77
+ end
90
78
  end
91
79
 
92
- it 'returns Times in UTC' do
93
- subject['2D IMAX'].first[0].must_equal Time.utc(2013, 11, 20, 00, 30, 0)
94
- subject['2D IMAX'].last[0].must_equal Time.utc(2013, 11, 28, 20, 40, 0)
80
+ it 'contains properly completed hashes' do
81
+ subject.each do |hash|
82
+ hash[:booking_url].must_include('http://www.cineworld.co.uk')
83
+ hash[:dimension].must_match(/\A[23]d\z/)
84
+ hash[:time].must_be_instance_of(Time)
85
+ hash[:variant].must_be_instance_of(Array)
86
+ hash[:variant].each do |type|
87
+ type.must_be_instance_of(String)
88
+ permitted_types.must_include(type)
89
+ end
90
+ end
95
91
  end
96
92
  end
97
93
 
98
- describe 'passed valid film html with H(obbity)FR' do
99
- let(:film_html) { read_film_html('the-o2-greenwich/the-hobbit-desolation-of-smaug') }
94
+ describe 'passed film html from top of dbox cinema page' do
95
+ let(:film_html) { read_film_html('the-o2-greenwich/film_first') }
96
+ let(:permitted_types) { %w(baby dbox hfr kids) }
100
97
 
101
- it 'returns the correct number of Times' do
102
- subject.keys.sort.must_equal ['2D', '3D D-BOX', '3D HFR']
103
- subject['2D'].count.must_equal 26
104
- subject['3D HFR'].count.must_equal 1
105
- subject['3D D-BOX'].count.must_equal 23
98
+ it 'returns a hash with allowed variants' do
99
+ subject.each do |hash|
100
+ hash[:variant].each do |type|
101
+ type.must_be_instance_of(String)
102
+ permitted_types.must_include(type)
103
+ end
104
+ end
106
105
  end
106
+ end
107
107
 
108
- it 'returns Times in UTC' do
109
- subject['2D'].first[0].must_equal Time.utc(2014, 1, 2, 16, 20, 0)
110
- subject['2D'].last[0].must_equal Time.utc(2014, 1, 9, 19, 20, 0)
111
-
112
- subject['3D HFR'].first[0].must_equal Time.utc(2014, 1, 2, 19, 20, 0)
113
- subject['3D HFR'].last[0].must_equal Time.utc(2014, 1, 2, 19, 20, 0)
108
+ describe 'passed film html from top of imax cinema page' do
109
+ let(:film_html) { read_film_html('glasgow-imax-at-gsc/film_first') }
110
+ let(:permitted_types) { %w(baby dbox hfr imax kids) }
114
111
 
115
- subject['3D D-BOX'].first[0].must_equal Time.utc(2014, 1, 2, 17, 0, 0)
116
- subject['3D D-BOX'].last[0].must_equal Time.utc(2014, 1, 9, 20, 20, 0)
112
+ it 'returns a hash with allowed variants' do
113
+ subject.each do |hash|
114
+ hash[:variant].each do |type|
115
+ type.must_be_instance_of(String)
116
+ permitted_types.must_include(type)
117
+ end
118
+ end
117
119
  end
118
120
  end
119
-
120
121
  end
121
122
 
122
123
  private
123
124
 
124
125
  def read_film_html(filename)
125
- File.read(File.expand_path("../../../../fixtures/whatson/#{filename}.html", __FILE__))
126
+ path = '../../../../fixtures/whatson/'
127
+ File.read(File.expand_path(path + "#{filename}.html", __FILE__))
126
128
  end
127
129
  end
@@ -6,8 +6,14 @@ describe CineworldUk::Internal::Titleize do
6
6
  subject { CineworldUk::Internal::Titleize.titleize(string) }
7
7
 
8
8
  [
9
- ['star wars: episode iv - a new hope', 'Star Wars: Episode IV - A New Hope'],
10
- ['star wars: episode v - the empire strikes back', 'Star Wars: Episode V - The Empire Strikes Back'],
9
+ [
10
+ 'star wars: episode iv - a new hope',
11
+ 'Star Wars: Episode IV - A New Hope'
12
+ ],
13
+ [
14
+ 'star wars: episode v - the empire strikes back',
15
+ 'Star Wars: Episode V - The Empire Strikes Back'
16
+ ],
11
17
  ['2 fast 2 furious', '2 Fast 2 Furious'],
12
18
  ['saw iv', 'Saw IV'],
13
19
  ['fast & Furious 6', 'Fast & Furious 6'],
@@ -20,7 +26,6 @@ describe CineworldUk::Internal::Titleize do
20
26
  subject.must_equal test_case[1]
21
27
  end
22
28
  end
23
-
24
29
  end
25
30
  end
26
31
 
@@ -28,7 +33,10 @@ describe CineworldUk::Internal::Titleize do
28
33
  subject { CineworldUk::Internal::Titleize.phrases(string) }
29
34
 
30
35
  [
31
- ['star wars: episode iv - a new hope',['star wars:','episode iv -','a new hope']],
36
+ [
37
+ 'star wars: episode iv - a new hope',
38
+ ['star wars:', 'episode iv -', 'a new hope']
39
+ ]
32
40
  ].each do |test_case|
33
41
 
34
42
  describe test_case[0] do
@@ -38,6 +46,5 @@ describe CineworldUk::Internal::Titleize do
38
46
  end
39
47
  end
40
48
  end
41
-
42
49
  end
43
50
  end
@@ -0,0 +1,57 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ describe CineworldUk::Internal::Website do
4
+ describe '#cinemas' do
5
+ subject { CineworldUk::Internal::Website.new.cinemas }
6
+
7
+ before { stub_get('cinemas', cinemas_html) }
8
+
9
+ it 'returns a string' do
10
+ subject.class.must_equal String
11
+ end
12
+ end
13
+
14
+ describe '#cinema_information(id)' do
15
+ subject { CineworldUk::Internal::Website.new.cinema_information(3) }
16
+
17
+ before { stub_get('cinemas/3/information', information_html) }
18
+
19
+ it 'returns a string' do
20
+ subject.class.must_equal String
21
+ end
22
+ end
23
+
24
+ describe '#whatson(id)' do
25
+ subject { CineworldUk::Internal::Website.new.whatson(3) }
26
+
27
+ before { stub_get('whatson?cinema=3', whatson_html) }
28
+
29
+ it 'returns a string' do
30
+ subject.class.must_equal String
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def read_file(filepath)
37
+ File.read(File.expand_path(filepath, __FILE__))
38
+ end
39
+
40
+ def cinemas_html
41
+ read_file('../../../../fixtures/cinemas.html')
42
+ end
43
+
44
+ def information_html
45
+ read_file('../../../../fixtures/information/brighton.html')
46
+ end
47
+
48
+ def stub_get(site_path, response_body)
49
+ url = "http://www.cineworld.co.uk/#{site_path}"
50
+ response = { status: 200, body: response_body, headers: {} }
51
+ stub_request(:get, url).to_return(response)
52
+ end
53
+
54
+ def whatson_html
55
+ read_file('../../../../fixtures/whatson/brighton.html')
56
+ end
57
+ end
@@ -0,0 +1,58 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ describe CineworldUk::Internal::WhatsonParser do
4
+ let(:described_class) { CineworldUk::Internal::WhatsonParser }
5
+
6
+ let(:website) { Minitest::Mock.new }
7
+
8
+ before do
9
+ WebMock.disable_net_connect!
10
+ end
11
+
12
+ describe '#films_with_screenings' do
13
+ subject { described_class.new(3).films_with_screenings }
14
+
15
+ before do
16
+ website.expect(:whatson, brighton_whatson_html, [3])
17
+ end
18
+
19
+ it 'returns an non-zero array of film screenings html fragments' do
20
+ CineworldUk::Internal::Website.stub :new, website do
21
+ subject.must_be_instance_of(Array)
22
+ subject.size.must_be :>, 0
23
+
24
+ subject.each do |film_html|
25
+ film_html.must_be_instance_of(String)
26
+ film_html.size.must_be :>, 0
27
+ end
28
+ end
29
+ end
30
+
31
+ it 'returns an array with correct content' do
32
+ CineworldUk::Internal::Website.stub :new, website do
33
+ # include primary film
34
+ subject.first.must_include('class="span4"') # big poster
35
+ subject.first.must_include('class="span5"') # film info block
36
+ subject.first.must_include('<h3 class="h1">') # title
37
+ subject.first.must_include('class="date row"') # showing rows
38
+
39
+ subject[1..-1].each do |html|
40
+ html.must_include('class="span2"') # poster
41
+ html.must_include('class="span7"') # film info block
42
+ html.must_include('<h3 class="h1">') # title
43
+ html.must_include('class="date row"') # showing rows
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def read_file(filepath)
52
+ File.read(File.expand_path(filepath, __FILE__))
53
+ end
54
+
55
+ def brighton_whatson_html
56
+ read_file('../../../../fixtures/whatson/brighton.html')
57
+ end
58
+ end
@@ -1,40 +1,172 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
3
  describe CineworldUk::Screening do
4
- describe '#new film_name, cinema_name, date, time, variant' do
5
- it 'stores film_name, cinema_name & when (in UTC)' do
6
- screening = CineworldUk::Screening.new 'Iron Man 3', "Duke's At Komedia", Time.parse('2013-09-12 11:00')
7
- screening.film_name.must_equal 'Iron Man 3'
8
- screening.cinema_name.must_equal "Duke's At Komedia"
9
- screening.when.must_equal Time.utc(2013, 9, 12, 10, 0)
10
- screening.booking_url.must_equal nil
11
- screening.variant.must_equal nil
4
+ let(:website) { Minitest::Mock.new }
5
+
6
+ before do
7
+ WebMock.disable_net_connect!
8
+ end
9
+
10
+ describe '.at(cinema_id)' do
11
+ subject { CineworldUk::Screening.at(3) }
12
+
13
+ before do
14
+ website.expect(:whatson, whatson_html('brighton'), [3])
15
+ website.expect(:cinemas, cinemas_html)
16
+ end
17
+
18
+ it 'returns an array of screenings' do
19
+ CineworldUk::Internal::Website.stub :new, website do
20
+ subject.must_be_instance_of(Array)
21
+ subject.each do |screening|
22
+ screening.must_be_instance_of(CineworldUk::Screening)
23
+ end
24
+ end
25
+ end
26
+
27
+ it 'returns correct number of screenings' do
28
+ CineworldUk::Internal::Website.stub :new, website do
29
+ subject.count.must_equal 333
30
+ end
31
+ end
32
+ end
33
+
34
+ describe '.new' do
35
+ subject { CineworldUk::Screening.new(options) }
36
+
37
+ describe 'simple' do
38
+ let(:options) do
39
+ {
40
+ film_name: 'Iron Man 3',
41
+ cinema_id: 3,
42
+ cinema_name: 'Cineworld Brighton',
43
+ time: Time.utc(2013, 9, 12, 11, 0)
44
+ }
45
+ end
46
+
47
+ it 'sets cinema name and film name' do
48
+ subject.film_name.must_equal 'Iron Man 3'
49
+ subject.cinema_name.must_equal 'Cineworld Brighton'
50
+ end
51
+
52
+ it 'booking url, dimension & varient are set to defaults' do
53
+ subject.booking_url.must_equal nil
54
+ subject.dimension.must_equal '2d'
55
+ subject.variant.must_equal []
56
+ end
57
+ end
58
+ end
59
+
60
+ describe '#dimension' do
61
+ let(:options) do
62
+ {
63
+ film_name: 'Iron Man 3',
64
+ dimension: '3d',
65
+ cinema_id: 3,
66
+ cinema_name: 'Cineworld Brighton',
67
+ time: Time.utc(2013, 9, 12, 11, 0)
68
+ }
69
+ end
70
+
71
+ subject { CineworldUk::Screening.new(options).dimension }
72
+
73
+ it 'returns 2d or 3d' do
74
+ subject.must_be_instance_of(String)
75
+ subject.must_equal '3d'
76
+ end
77
+ end
78
+
79
+ describe '#showing_at' do
80
+ subject { CineworldUk::Screening.new(options).showing_at }
81
+
82
+ describe 'with utc time' do
83
+ let(:options) do
84
+ {
85
+ film_name: 'Iron Man 3',
86
+ cinema_id: 3,
87
+ cinema_name: 'Cineworld Brighton',
88
+ time: Time.utc(2013, 9, 12, 11, 0)
89
+ }
90
+ end
91
+
92
+ it 'returns UTC time' do
93
+ subject.must_be_instance_of Time
94
+ subject.must_equal Time.utc(2013, 9, 12, 11, 0)
95
+ end
12
96
  end
13
97
 
14
- it 'stores variant if passed' do
15
- screening = CineworldUk::Screening.new 'Iron Man 3', "Duke's At Komedia", Time.utc(2013, 9, 12, 11, 0), 'http://link.com', '2d'
16
- screening.film_name.must_equal 'Iron Man 3'
17
- screening.cinema_name.must_equal "Duke's At Komedia"
18
- screening.when.must_equal Time.utc(2013, 9, 12, 11, 0)
19
- screening.booking_url.must_equal 'http://link.com'
20
- screening.variant.must_equal '2d'
98
+ describe 'with non-utc time' do
99
+ let(:options) do
100
+ {
101
+ film_name: 'Iron Man 3',
102
+ cinema_id: 3,
103
+ cinema_name: 'Cineworld Brighton',
104
+ time: Time.parse('2013-09-12 11:00')
105
+ }
106
+ end
107
+
108
+ it 'returns UTC time' do
109
+ subject.must_be_instance_of Time
110
+ subject.must_equal Time.utc(2013, 9, 12, 10, 0)
111
+ end
21
112
  end
22
113
  end
23
114
 
24
- describe '#date' do
25
- subject { CineworldUk::Screening.new('Iron Man 3', "Duke's At Komedia", Time.utc(2013, 9, 12, 11, 0)).date }
26
- it 'should return date of showing' do
115
+ describe '#showing_on' do
116
+ let(:options) do
117
+ {
118
+ film_name: 'Iron Man 3',
119
+ cinema_id: 3,
120
+ cinema_name: 'Cineworld Brighton',
121
+ time: Time.utc(2013, 9, 12, 11, 0)
122
+ }
123
+ end
124
+
125
+ subject { CineworldUk::Screening.new(options).showing_on }
126
+
127
+ it 'returns date of showing' do
27
128
  subject.must_be_instance_of(Date)
28
129
  subject.must_equal Date.new(2013, 9, 12)
29
130
  end
30
131
  end
31
132
 
32
- describe '#varient (DEPRECATED)' do
33
- subject { screening.varient }
34
- let(:screening) { CineworldUk::Screening.new 'Iron Man 3', "Duke's At Komedia", Time.utc(2013, 9, 12, 11, 0), 'http://link.com', '2d' }
133
+ describe '#variant' do
134
+ subject { CineworldUk::Screening.new(options).variant }
135
+
136
+ let(:options) do
137
+ {
138
+ film_name: 'Iron Man 3',
139
+ cinema_id: 3,
140
+ cinema_name: 'Cineworld Brighton',
141
+ time: Time.utc(2013, 9, 12, 11, 0),
142
+ variant: 'Kids'
143
+ }
144
+ end
35
145
 
36
- it 'should return variant' do
37
- subject.must_equal '2d'
146
+ it 'is an alphabetically ordered array of lower-cased strings' do
147
+ subject.must_be_instance_of Array
148
+ subject.each do |tag|
149
+ tag.must_be_instance_of String
150
+ end
151
+ subject.must_equal %w(kids)
38
152
  end
39
153
  end
154
+
155
+ private
156
+
157
+ def cinemas_html
158
+ read_file('../../../fixtures/cinemas.html')
159
+ end
160
+
161
+ def information_html(filename)
162
+ read_file("../../../fixtures/information/#{filename}.html")
163
+ end
164
+
165
+ def read_file(filepath)
166
+ File.read(File.expand_path(filepath, __FILE__))
167
+ end
168
+
169
+ def whatson_html(filename)
170
+ read_file("../../../fixtures/whatson/#{filename}.html")
171
+ end
40
172
  end
@@ -2,7 +2,7 @@ require_relative '../../test_helper'
2
2
 
3
3
  describe CineworldUk do
4
4
 
5
- it "must be defined" do
5
+ it 'must be defined' do
6
6
  CineworldUk::VERSION.wont_be_nil
7
7
  end
8
8
 
data/test/test_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'minitest/autorun'
2
- require 'minitest/pride'
2
+ require 'minitest/reporters'
3
+ reporter_options = { color: true, slow_count: 5 }
4
+ Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(reporter_options)]
3
5
 
4
6
  require 'webmock/minitest'
5
7