-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit reflects state after getting the failing movie specs around exception handling
- Loading branch information
1 parent
1d8b4f6
commit 462fe90
Showing
4 changed files
with
30 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
class Movie < ActiveRecord::Base | ||
|
||
@@ratings_with_ages = { | ||
'G' => 0, | ||
'PG' => 0, | ||
'PG-13' => 13, | ||
'R' => 17, | ||
'NC-17' => 17 | ||
} | ||
@@ratings = @@ratings_with_ages.keys | ||
cattr_reader :ratings | ||
class InvalidKeyError < StandardError ; end | ||
|
||
validates_presence_of :title | ||
validates_length_of :description, :minimum => 10 | ||
validates_uniqueness_of :title, :message => "already exists in the database" | ||
validates_inclusion_of :rating, :in => Movie.ratings, :message => "is not a valid rating" | ||
|
||
def self.find_in_tmdb(string) | ||
TmdbMovie.find(:title => string) | ||
end | ||
|
||
# rest of file elided for brevity | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
require 'spec_helper' | ||
|
||
describe Movie do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
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 | ||
end | ||
context 'with invalid API key' do | ||
it 'should raise an error with a 404 in the message' do | ||
lambda { Movie.find_in_tmdb('Inception') }. | ||
should raise_error(Movie::InvalidKeyError) | ||
end | ||
end | ||
end | ||
end |