Sha256: 94d1850f46f797575dd94b2e9bdd34080f281df738e3b3fa8720ae6c1fd0db76

Contents?: true

Size: 995 Bytes

Versions: 6

Compression:

Stored size: 995 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)
    plist = CFPropertyList::List.new(data: content).value
    CFPropertyList.native_types(plist).fetch('data', {})
  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

6 entries across 6 versions & 1 rubygems

Version Path
odeon_uk-3.0.6 test/support/api_fixtures_helper.rb
odeon_uk-3.0.5 test/support/api_fixtures_helper.rb
odeon_uk-3.0.4 test/support/api_fixtures_helper.rb
odeon_uk-3.0.3 test/support/api_fixtures_helper.rb
odeon_uk-3.0.2 test/support/api_fixtures_helper.rb
odeon_uk-3.0.1 test/support/api_fixtures_helper.rb