test/unit/tmdb_test.rb in ruby-tmdb3-0.3.0 vs test/unit/tmdb_test.rb in ruby-tmdb3-0.3.1

- old
+ new

@@ -29,11 +29,11 @@ Tmdb.default_language = new_language assert_equal new_language, Tmdb.default_language end test "should return base API url" do - assert_equal "http://api.themoviedb.org/3/", Tmdb.base_api_url + assert_equal "http://api.themoviedb.org/3", Tmdb.base_api_url end test "get url returns a response object" do test_response = Tmdb.get_url("http://example.com/") assert_equal 200, test_response.code.to_i @@ -46,21 +46,21 @@ test "API call without explicit language setting should use default language" do method = "search/movie" data = "hello" Tmdb.default_language = "es" - url = Tmdb.base_api_url + method + '?api_key=' + Tmdb.api_key + '&language=' + Tmdb.default_language + '&query=' + CGI::escape(data.to_s) + url = Tmdb.base_api_url + '/' + method + '?api_key=' + Tmdb.api_key + '&language=' + Tmdb.default_language + '&query=' + CGI::escape(data.to_s) mock_response = stub(:code => "200", :body => '{"page":1,"results":[],"total_pages":0,"total_results":0}') Tmdb.expects(:get_url).with(url).returns(mock_response) Tmdb.api_call(method, {query: data}) end test "API call with explicit language setting should override default language" do method = "movie" data = "hello" language = "blah" - url = Tmdb.base_api_url + method + "?api_key=" + Tmdb.api_key + "&language=" + language + '&query=' + CGI::escape(data.to_s) + url = Tmdb.base_api_url + '/' + method + "?api_key=" + Tmdb.api_key + "&language=" + language + '&query=' + CGI::escape(data.to_s) mock_response = stub(:code => "200", :body => '{"page":1,"results":[],"total_pages":0,"total_results":0}') Tmdb.expects(:get_url).with(url).returns(mock_response) Tmdb.api_call(method, {query: data}, language) end @@ -90,10 +90,18 @@ assert_kind_of Hash, result %w(original_title id).each do |item| assert_not_nil result[item] end end + + test "should perform movie API call with an action and return a single result" do + result = Tmdb.api_call("movie/images", {id: "187"}) + assert_kind_of Hash, result + %w(posters id).each do |item| + assert_not_nil result[item] + end + end test "should perform Movie.imdbLookup API call and return a single result" do result = Tmdb.api_call("movie", {id: "tt0401792"}) assert_kind_of Hash, result %w(original_title id).each do |item| @@ -163,18 +171,16 @@ test "data_to_object should convert arrays containing images to nicer format" do test_data = { "backdrops" => [ { - "image" => { - :test => 1 - } + :test => 1 } ] } test_object = Tmdb.data_to_object(test_data) assert_nothing_raised do assert_equal 1, test_object.backdrops[0].test end end -end \ No newline at end of file +end