Sha256: e1f566ba7cc8262097ba27630a43cbee008a45f8d44c2d3b186af41146404f9d

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

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

describe OdeonUk::Internal::ShowtimesPage do
  let(:described_class) { OdeonUk::Internal::ShowtimesPage }

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

  before { WebMock.disable_net_connect! }

  describe '#to_a' do
    subject { described_class.new(71).to_a }

    before do
      website.expect(:showtimes, brighton_showtimes_html, [71])
    end

    it 'returns an non-zero array of film screenings html fragments' do
      OdeonUk::Internal::Website.stub :new, website do
        subject.must_be_instance_of(Array)
        subject.size.must_be :>, 0

        subject.each do |film_html|
          film_html.must_be_instance_of(String)
          film_html.size.must_be :>, 0
        end
      end
    end

    it 'returns an array with correct content' do
      OdeonUk::Internal::Website.stub :new, website do
        subject.each do |html|
          html.must_include('class="film-detail') # screenings group
          html.must_include('class="presentation-info') # title
          html.must_include('class="WEEK') # a performance
          html.must_include('data-start="') # start time
          html.must_include('data-end="') # end time
        end
      end
    end
  end

  private

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

  def brighton_showtimes_html
    read_file('../../../../fixtures/showtimes/brighton.html')
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
odeon_uk-2.0.4 test/lib/odeon_uk/internal/showtimes_page_test.rb
odeon_uk-2.0.3 test/lib/odeon_uk/internal/showtimes_page_test.rb
odeon_uk-2.0.2 test/lib/odeon_uk/internal/showtimes_page_test.rb
odeon_uk-2.0.1 test/lib/odeon_uk/internal/showtimes_page_test.rb
odeon_uk-2.0.0 test/lib/odeon_uk/internal/showtimes_page_test.rb