saasbook

movie_spec_with_context.rb

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