Sha256: 06841a7466a7254f79b3bdf477c1ffebe7df9d4452a5a8fd042e3b45097189d5

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

require_relative '../../../../test_helper'

describe PicturehouseUk::Internal::Parser::Screenings do
  let(:described_class) { PicturehouseUk::Internal::Parser::Screenings }

  let(:website) { Minitest::Mock.new }

  before do
    WebMock.disable_net_connect!
  end

  %w(Duke_Of_Yorks Dukes_At_Komedia Phoenix_Picturehouse).each do |cinema|
    describe '#to_a' do
      subject { described_class.new(cinema).to_a }

      before { website.expect(:cinema, html(cinema), [cinema]) }

      it 'returns an non-zero array of hashes' do
        PicturehouseUk::Internal::Website.stub :new, website do
          subject.must_be_instance_of(Array)
          subject.size.must_be :>, 0

          subject.each do |element|
            element.must_be_instance_of(Hash)
            element.keys.must_equal([:film_name, :dimension, :variant, :booking_url, :time])
            element[:film_name].must_be_kind_of(String)
            element[:dimension].must_match(/\A[23]d\z/)
            # element[:booking_url].must_match(/\Ahttps?\:\/\//)
            element[:time].must_be_kind_of(Time)
          end
        end
      end
    end
  end

  private

  def read_file(filepath)
    File.read(File.expand_path(filepath, __FILE__))
  end

  def html(cinema)
    read_file("../../../../../fixtures/cinema/#{cinema}.html")
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
picturehouse_uk-3.0.10 test/lib/picturehouse_uk/internal/parser/screenings_test.rb
picturehouse_uk-3.0.9 test/lib/picturehouse_uk/internal/parser/screenings_test.rb
picturehouse_uk-3.0.8 test/lib/picturehouse_uk/internal/parser/screenings_test.rb
picturehouse_uk-3.0.7 test/lib/picturehouse_uk/internal/parser/screenings_test.rb