Sha256: 086d3ee31ad007993c55362b45491f2c8f3e12da13661c65b0612e93f5a93011

Contents?: true

Size: 1.67 KB

Versions: 4

Compression:

Stored size: 1.67 KB

Contents

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

describe CineworldUk::Internal::WhatsonParser do
  let(:described_class) { CineworldUk::Internal::WhatsonParser }

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

  before do
    WebMock.disable_net_connect!
  end

  describe '#films_with_screenings' do
    subject { described_class.new(3).films_with_screenings }

    before do
      website.expect(:whatson, brighton_whatson_html, [3])
    end

    it 'returns an non-zero array of film screenings html fragments' do
      CineworldUk::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
      CineworldUk::Internal::Website.stub :new, website do
        # include primary film
        subject.first.must_include('class="span4"') # big poster
        subject.first.must_include('class="span5"') # film info block
        subject.first.must_include('<h3 class="h1">') # title
        subject.first.must_include('class="date row"') # showing rows

        subject[1..-1].each do |html|
          html.must_include('class="span2"') # poster
          html.must_include('class="span7"') # film info block
          html.must_include('<h3 class="h1">') # title
          html.must_include('class="date row"') # showing rows
        end
      end
    end
  end

  private

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

  def brighton_whatson_html
    read_file('../../../../fixtures/whatson/brighton.html')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cineworld_uk-2.0.3 test/lib/cineworld_uk/internal/whatson_parser_test.rb
cineworld_uk-2.0.2 test/lib/cineworld_uk/internal/whatson_parser_test.rb
cineworld_uk-2.0.1 test/lib/cineworld_uk/internal/whatson_parser_test.rb
cineworld_uk-2.0.0 test/lib/cineworld_uk/internal/whatson_parser_test.rb