Sha256: 528968a2b21d8699622880d7c1d19fb33893154e68871026d6edd02cd3c86760

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

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

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

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

    before { stub_get('cinemas/odeon/71/', brighton_cinema_html) }

    it 'returns a string' do
      subject.class.must_equal String
    end
  end

  describe '#sitemap' do
    subject { described_class.new.sitemap }

    before { stub_get('sitemap/', sitemap_html) }

    it 'returns a string' do
      subject.class.must_equal String
    end
  end

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

    before { stub_get('showtimes/week/71/?siteId=71', brighton_showtimes_html) }

    it 'returns a string' do
      subject.class.must_equal String
    end
  end

  private

  def brighton_cinema_html
    read_file('../../../../fixtures/cinema/brighton.html')
  end

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

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

  def sitemap_html
    read_file('../../../../fixtures/sitemap.html')
  end

  def stub_get(site_path, response_body)
    url      = "http://www.odeon.co.uk/#{site_path}"
    response = { status: 200, body: response_body, headers: {} }
    stub_request(:get, url).to_return(response)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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