Sha256: d34b9c98064e030c71d9d3a49e389ce5d2b1207b60c34d4df0ecafd232f13b3d

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe Fandango do

  describe '.movies_near' do

    it 'returns hash of theaters and movies playing at each' do
      VCR.use_cassette 'movies_near_me_73142' do
        array = Fandango.movies_near(73142)
        fixture_yaml = fixture_file_content('movies_near_me_73142.yaml')
        array.to_yaml.must_equal fixture_yaml
      end
    end

    it 'raises error if postal code blank' do
      proc { Fandango.movies_near('') }.must_raise(ArgumentError)
    end

    it 'raises error if status code is not 200' do
      response = MiniTest::Mock.new
      response.expect(:status, ['500', 'not ok'])
      Fandango.stub(:request, response) do
        proc { Fandango.movies_near('does not matter') }.must_raise(Fandango::BadResponse)
      end
    end

  end

  specify '.request makes http request and returns response' do
    VCR.use_cassette 'movies_near_me_73142' do
      source = Fandango.request(73142).read
      fixture_source = fixture_file_content('movies_near_me_73142.rss').chomp
      source.must_equal fixture_source
    end
  end

  specify '.clean_postal_code removes spaces from postal code' do
    Fandango.send(:clean_postal_code, 'ABC 123').must_equal 'ABC123'
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fandango-1.0.0 spec/fandango.spec.rb