picturehouse_uk 2.0.5 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -6
- data/README.md +9 -1
- data/lib/picturehouse_uk.rb +2 -3
- data/lib/picturehouse_uk/cinema.rb +24 -12
- data/lib/picturehouse_uk/film.rb +3 -5
- data/lib/picturehouse_uk/internal/parser/address.rb +37 -0
- data/lib/picturehouse_uk/internal/parser/screenings.rb +117 -0
- data/lib/picturehouse_uk/internal/title_sanitizer.rb +2 -0
- data/lib/picturehouse_uk/internal/website.rb +4 -10
- data/lib/picturehouse_uk/screening.rb +5 -15
- data/lib/picturehouse_uk/version.rb +2 -2
- data/test/fixture_updater.rb +16 -13
- data/test/fixtures/cinema/Duke_Of_Yorks.html +2048 -4341
- data/test/fixtures/cinema/Dukes_At_Komedia.html +3780 -0
- data/test/fixtures/cinema/Phoenix_Picturehouse.html +3465 -0
- data/test/fixtures/home.html +487 -1932
- data/test/fixtures/info/Duke_Of_Yorks.html +450 -0
- data/test/fixtures/info/Dukes_At_Komedia.html +439 -0
- data/test/fixtures/info/Phoenix_Picturehouse.html +458 -0
- data/test/lib/picturehouse_uk/cinema_test.rb +53 -16
- data/test/lib/picturehouse_uk/internal/parser/screenings_test.rb +45 -0
- data/test/lib/picturehouse_uk/internal/title_sanitizer_test.rb +16 -0
- data/test/lib/picturehouse_uk/internal/website_test.rb +6 -6
- data/test/lib/picturehouse_uk/screening_test.rb +9 -1
- metadata +16 -25
- data/lib/picturehouse_uk/internal/address_parser.rb +0 -72
- data/lib/picturehouse_uk/internal/cinema_page.rb +0 -35
- data/lib/picturehouse_uk/internal/film_with_screenings_parser.rb +0 -116
- data/test/fixtures/address-fragments/duke-of-yorks.html +0 -39
- data/test/fixtures/address-fragments/hackney-picturehouse.html +0 -12
- data/test/fixtures/cinema/Duke_Of_Yorks/film_last.html +0 -45
- data/test/fixtures/cinema/Duke_Of_Yorks/film_second.html +0 -37
- data/test/fixtures/cinema/York_Picturehouse/basement.html +0 -19
- data/test/fixtures/contact_us/Duke_Of_Yorks.html +0 -1505
- data/test/fixtures/contact_us/Dukes_At_Komedia.html +0 -1503
- data/test/lib/picturehouse_uk/internal/address_parser_test.rb +0 -55
- data/test/lib/picturehouse_uk/internal/cinema_page_test.rb +0 -51
- data/test/lib/picturehouse_uk/internal/film_with_screenings_parser_test.rb +0 -95
@@ -1,55 +0,0 @@
|
|
1
|
-
require_relative '../../../test_helper'
|
2
|
-
|
3
|
-
describe PicturehouseUk::Internal::AddressParser do
|
4
|
-
let(:described_class) { PicturehouseUk::Internal::AddressParser }
|
5
|
-
|
6
|
-
describe '#address' do
|
7
|
-
subject { described_class.new(html).address }
|
8
|
-
|
9
|
-
describe 'standard address' do # brighton
|
10
|
-
let(:html) { address_html('duke-of-yorks') }
|
11
|
-
|
12
|
-
it 'returns a hash' do
|
13
|
-
subject.class.must_equal Hash
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'contains the correct keys' do
|
17
|
-
subject.must_equal(
|
18
|
-
street_address: 'Preston Circus',
|
19
|
-
extended_address: nil,
|
20
|
-
locality: 'Brighton',
|
21
|
-
postal_code: 'BN1 4NA',
|
22
|
-
country: 'United Kingdom'
|
23
|
-
)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'freak address: hackney' do
|
28
|
-
let(:html) { address_html('hackney-picturehouse') }
|
29
|
-
|
30
|
-
it 'returns a hash' do
|
31
|
-
subject.class.must_equal Hash
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'contains the correct keys' do
|
35
|
-
subject.must_equal(
|
36
|
-
street_address: '270 Mare Street',
|
37
|
-
extended_address: nil,
|
38
|
-
locality: 'London',
|
39
|
-
postal_code: 'E8 1HE',
|
40
|
-
country: 'United Kingdom'
|
41
|
-
)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def read_file(filepath)
|
49
|
-
File.read(File.expand_path(filepath, __FILE__))
|
50
|
-
end
|
51
|
-
|
52
|
-
def address_html(cinema)
|
53
|
-
read_file("../../../../fixtures/address-fragments/#{cinema}.html")
|
54
|
-
end
|
55
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require_relative '../../../test_helper'
|
2
|
-
|
3
|
-
describe PicturehouseUk::Internal::CinemaPage do
|
4
|
-
let(:described_class) { PicturehouseUk::Internal::CinemaPage }
|
5
|
-
|
6
|
-
let(:website) { Minitest::Mock.new }
|
7
|
-
|
8
|
-
before do
|
9
|
-
WebMock.disable_net_connect!
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#film_html' do
|
13
|
-
subject { described_class.new('Duke_Of_Yorks').film_html }
|
14
|
-
|
15
|
-
before do
|
16
|
-
website.expect(:cinema, dukes_html, ['Duke_Of_Yorks'])
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'returns an non-zero array of film screenings html fragments' do
|
20
|
-
PicturehouseUk::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
|
-
PicturehouseUk::Internal::Website.stub :new, website do
|
33
|
-
subject[1..-1].each do |html|
|
34
|
-
html.must_include('class="imageborder"') # poster
|
35
|
-
html.must_include('class="movielink"') # title
|
36
|
-
html.must_include('epoch="') # screening
|
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 dukes_html
|
49
|
-
read_file('../../../../fixtures/cinema/Duke_Of_Yorks.html')
|
50
|
-
end
|
51
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
require_relative '../../../test_helper'
|
2
|
-
|
3
|
-
describe PicturehouseUk::Internal::FilmWithScreeningsParser do
|
4
|
-
let(:described_class) { PicturehouseUk::Internal::FilmWithScreeningsParser }
|
5
|
-
|
6
|
-
describe '#film_name' do
|
7
|
-
subject { described_class.new(film_html).film_name }
|
8
|
-
|
9
|
-
describe 'passed film html from page' do
|
10
|
-
let(:film_html) { read_film_html('Duke_Of_Yorks/film_second') }
|
11
|
-
|
12
|
-
it 'returns the film name' do
|
13
|
-
subject.must_be_instance_of(String)
|
14
|
-
subject.must_equal('Gone Girl')
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'passed film html from end of page' do
|
19
|
-
let(:film_html) { read_film_html('Duke_Of_Yorks/film_last') }
|
20
|
-
|
21
|
-
it 'returns the film name' do
|
22
|
-
subject.must_be_instance_of(String)
|
23
|
-
subject.must_equal('The Judge')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'passed basement from Cityscreen Picturehouse York' do
|
28
|
-
let(:film_html) { read_film_html('York_Picturehouse/basement') }
|
29
|
-
|
30
|
-
it 'returns nil' do
|
31
|
-
subject.must_equal(nil)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#to_a' do
|
37
|
-
subject { described_class.new(film_html).to_a }
|
38
|
-
|
39
|
-
describe 'passed film html from top of page' do
|
40
|
-
let(:film_html) { read_film_html('Duke_Of_Yorks/film_second') }
|
41
|
-
let(:permitted_types) { %w(baby hfr kids silver) }
|
42
|
-
|
43
|
-
it 'returns a non-zero array of hashes' do
|
44
|
-
subject.must_be_instance_of(Array)
|
45
|
-
subject.size.must_be :>=, 1
|
46
|
-
subject.each do |hash|
|
47
|
-
hash.must_be_instance_of(Hash)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'contains properly completed hashes' do
|
52
|
-
subject.each do |hash|
|
53
|
-
hash[:booking_url].must_include('http://www.picturehouses.co.uk')
|
54
|
-
hash[:dimension].must_match(/\A[23]d\z/)
|
55
|
-
hash[:time].must_be_instance_of(Time)
|
56
|
-
hash[:variant].must_be_instance_of(Array)
|
57
|
-
hash[:variant].each do |type|
|
58
|
-
type.must_be_instance_of(String)
|
59
|
-
permitted_types.must_include(type)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe 'passed film html from bottom of cinema page' do
|
66
|
-
let(:film_html) { read_film_html('Duke_Of_Yorks/film_last') }
|
67
|
-
let(:permitted_types) { %w(baby dbox hfr kids silver) }
|
68
|
-
|
69
|
-
it 'returns a hash with allowed variants' do
|
70
|
-
subject.each do |hash|
|
71
|
-
hash[:variant].each do |type|
|
72
|
-
type.must_be_instance_of(String)
|
73
|
-
permitted_types.must_include(type)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe 'passed basement from Cityscreen Picturehouse York' do
|
80
|
-
let(:film_html) { read_film_html('York_Picturehouse/basement') }
|
81
|
-
|
82
|
-
it 'returns an empty array' do
|
83
|
-
subject.must_be_instance_of(Array)
|
84
|
-
subject.must_be :empty?
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
|
91
|
-
def read_film_html(filename)
|
92
|
-
path = '../../../../fixtures/cinema/'
|
93
|
-
File.read(File.expand_path(path + "#{filename}.html", __FILE__))
|
94
|
-
end
|
95
|
-
end
|