Advertisement
saasbook

Untitled

Feb 16th, 2012
2,494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.86 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' 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement