Sha256: f1795431bc89bd4f6f50d2d3216f4507f4621277de4d9db7c52b627c7ee65d9e

Contents?: true

Size: 1.42 KB

Versions: 5

Compression:

Stored size: 1.42 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 '#info(id)' do
    subject { described_class.new.info('Duke_Of_Yorks') }

    before do
      stub_get(
        'cinema/info/Duke_Of_Yorks',
        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/info/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.com/#{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
picturehouse_uk-3.0.4 test/lib/picturehouse_uk/internal/website_test.rb
picturehouse_uk-3.0.3 test/lib/picturehouse_uk/internal/website_test.rb
picturehouse_uk-3.0.2 test/lib/picturehouse_uk/internal/website_test.rb
picturehouse_uk-3.0.1 test/lib/picturehouse_uk/internal/website_test.rb
picturehouse_uk-3.0.0 test/lib/picturehouse_uk/internal/website_test.rb