Sha256: 9354c6839b4ab4b48c22862b51addd70168e5abd527cc5e454e179e89f2e5451

Contents?: true

Size: 959 Bytes

Versions: 1

Compression:

Stored size: 959 Bytes

Contents

module ApiFixturesHelper
  private

  def all_cinemas_plist
    read_fixture('api/all_cinemas')
  end

  def app_init_plist
    read_fixture('api/app_init')
  end

  def film_times_plist(cinema_id, film_id)
    read_fixture("api/film_times/#{cinema_id}-#{film_id}")
  end

  def film_times_plists(cinema_id)
    listing = Dir.entries(File.expand_path('../../fixtures/api/film_times', __FILE__))
    listing.reject { |filename| !filename.match(/\A#{cinema_id}-/) }
  end

  def parse(content)
    CFPropertyList.native_types(CFPropertyList::List.new(data: content).value)
  end

  def read_fixture(filepath)
    File.read(File.expand_path("../../fixtures/#{filepath}.plist", __FILE__))
  end

  def stub_post(site_path, request_body, response_body)
    url      = "https://api.odeon.co.uk/2.1/api/#{site_path}"
    response = { status: 200, body: response_body, headers: {} }
    stub_request(:post, url).with(body: request_body).to_return(response)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
odeon_uk-3.0.0 test/support/api_fixtures_helper.rb