Sha256: bd377d006dbda2251ba8056dc891addda78ced494092b2089e4b6432b58c6c1e

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

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

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

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

    before { stub_get('cinema/Duke_Of_Yorks/', duke_of_yorks_html) }

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

  describe '#contact_us(id)' do
    subject { described_class.new.contact_us('Duke_Of_Yorks') }

    before do
      stub_get(
        'cinema/Duke_Of_Yorks/Hires_Info/Contact_Us/',
        duke_of_yorks_contact_us_html
      )
    end

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

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

    before { stub_get('', home_html) }

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

  private

  def duke_of_yorks_html
    read_file('../../../../fixtures/cinema/Duke_Of_Yorks.html')
  end

  def duke_of_yorks_contact_us_html
    read_file('../../../../fixtures/contact_us/Duke_Of_Yorks.html')
  end

  def home_html
    read_file('../../../../fixtures/home.html')
  end

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

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