Guest User

Untitled

a guest
Oct 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.88 KB | None | 0 0
  1. require 'spec_helper'
  2.  
  3. describe Movie do
  4.   describe 'searching Tmdb by keyword' do
  5.     context 'with valid key' do
  6.       it 'should call Tmdb with title keywords given valid API key' do
  7.         TmdbMovie.should_receive(:find).
  8.           with(hash_including :title => 'Inception')
  9.         Movie.find_in_tmdb('Inception')
  10.       end
  11.     end
  12.     context 'with invalid key' do
  13.       it 'should raise InvalidKeyError if key not given' do
  14.         Movie.stub(:api_key).and_return('')
  15.         lambda { Movie.find_in_tmdb('Inception') }.
  16.           should raise_error(Movie::InvalidKeyError)
  17.       end
  18.       it 'should raise InvalidKeyError if key is bad' do
  19.         TmdbMovie.stub(:find).
  20.           and_raise(RuntimeError.new('API returned code 404'))
  21.         lambda { Movie.find_in_tmdb('Inception') }.
  22.           should raise_error(Movie::InvalidKeyError)
  23.       end
  24.     end
  25.   end
  26. end
Add Comment
Please, Sign In to add comment