Skip to content

Commit

Permalink
tersified movie_spec by collapsing context blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
armandofox committed Oct 3, 2011
1 parent 4dd3e75 commit 62f9751
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions spec/models/movie_spec.rb
Expand Up @@ -2,25 +2,19 @@

describe Movie do
describe 'searching Tmdb by keyword' do
context 'with valid API key' do
it 'should call Tmdb with title keywords' do
TmdbMovie.should_receive(:find).with(hash_including :title => 'Inception')
Movie.find_in_tmdb('Inception')
end
it 'should call Tmdb with title keywords given valid API key' do
TmdbMovie.should_receive(:find).with(hash_including :title => 'Inception')
Movie.find_in_tmdb('Inception')
end
context 'with no API key' do
it 'should raise an InvalidKeyError' do
Movie.stub(:api_key).and_return('')
lambda { Movie.find_in_tmdb('Inception') }.
should raise_error(Movie::InvalidKeyError)
end
it 'should raise an InvalidKeyError with no API key' do
Movie.stub(:api_key).and_return('')
lambda { Movie.find_in_tmdb('Inception') }.
should raise_error(Movie::InvalidKeyError)
end
context 'with invalid API key' do
it 'should raise an InvalidKeyError' do
TmdbMovie.stub(:find).and_raise(RuntimeError.new('API returned code 404'))
lambda { Movie.find_in_tmdb('Inception') }.
should raise_error(Movie::InvalidKeyError)
end
it 'should raise an InvalidKeyError with invalid API key' do
TmdbMovie.stub(:find).and_raise(RuntimeError.new('API returned code 404'))
lambda { Movie.find_in_tmdb('Inception') }.
should raise_error(Movie::InvalidKeyError)
end
end
end

0 comments on commit 62f9751

Please sign in to comment.