saasbook

movie_spec.5.rb

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