ruby-tmdb 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +19 -19
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/ruby-tmdb.gemspec +7 -4
- data/test/setup/setup_api_key.rb +2 -2
- data/test/setup/test_unit_extensions.rb +20 -20
- data/test/test_helper.rb +19 -19
- data/test/unit/test_direct_require.rb +24 -24
- data/test/unit/tmdb_test.rb +157 -157
- metadata +23 -6
data/MIT-LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2010 Aaron Gough (http://thingsaaronmade.com/)
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
1
|
+
Copyright (c) 2010 Aaron Gough (http://thingsaaronmade.com/)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -17,6 +17,7 @@ begin
|
|
17
17
|
gemspec.rdoc_options << '--line-numbers' << '--inline-source'
|
18
18
|
gemspec.extra_rdoc_files = ['README.rdoc', 'MIT-LICENSE']
|
19
19
|
gemspec.add_dependency( "deepopenstruct", ">= 0.1.2")
|
20
|
+
gemspec.add_dependency( "json")
|
20
21
|
gemspec.add_development_dependency "webmock"
|
21
22
|
end
|
22
23
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/ruby-tmdb.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruby-tmdb}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Aaron Gough"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-06}
|
13
13
|
s.description = %q{An ActiveRecord-style API wrapper for TheMovieDB.org}
|
14
14
|
s.email = %q{aaron@aarongough.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
|
|
49
49
|
s.homepage = %q{https://github.com/aarongough/ruby-tmdb}
|
50
50
|
s.rdoc_options = ["--charset=UTF-8", "--line-numbers", "--inline-source"]
|
51
51
|
s.require_paths = ["lib"]
|
52
|
-
s.rubygems_version = %q{1.3.
|
52
|
+
s.rubygems_version = %q{1.3.7}
|
53
53
|
s.summary = %q{An ActiveRecord-style API wrapper for TheMovieDB.org}
|
54
54
|
s.test_files = [
|
55
55
|
"test/setup/setup_api_key.rb",
|
@@ -66,15 +66,18 @@ Gem::Specification.new do |s|
|
|
66
66
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
67
67
|
s.specification_version = 3
|
68
68
|
|
69
|
-
if Gem::Version.new(Gem::
|
69
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
70
70
|
s.add_runtime_dependency(%q<deepopenstruct>, [">= 0.1.2"])
|
71
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
71
72
|
s.add_development_dependency(%q<webmock>, [">= 0"])
|
72
73
|
else
|
73
74
|
s.add_dependency(%q<deepopenstruct>, [">= 0.1.2"])
|
75
|
+
s.add_dependency(%q<json>, [">= 0"])
|
74
76
|
s.add_dependency(%q<webmock>, [">= 0"])
|
75
77
|
end
|
76
78
|
else
|
77
79
|
s.add_dependency(%q<deepopenstruct>, [">= 0.1.2"])
|
80
|
+
s.add_dependency(%q<json>, [">= 0"])
|
78
81
|
s.add_dependency(%q<webmock>, [">= 0"])
|
79
82
|
end
|
80
83
|
end
|
data/test/setup/setup_api_key.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
File.open(File.join(File.dirname(__FILE__), 'tmdb_api_key.txt')) do |file|
|
2
|
-
Tmdb.api_key = file.read
|
1
|
+
File.open(File.join(File.dirname(__FILE__), 'tmdb_api_key.txt')) do |file|
|
2
|
+
Tmdb.api_key = file.read
|
3
3
|
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
module Test::Unit
|
2
|
-
# Used to fix a minor minitest/unit incompatibility in flexmock
|
3
|
-
AssertionFailedError = Class.new(StandardError)
|
4
|
-
|
5
|
-
class TestCase
|
6
|
-
|
7
|
-
def self.test(name, &block)
|
8
|
-
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
9
|
-
defined = instance_method(test_name) rescue false
|
10
|
-
raise "#{test_name} is already defined in #{self}" if defined
|
11
|
-
if block_given?
|
12
|
-
define_method(test_name, &block)
|
13
|
-
else
|
14
|
-
define_method(test_name) do
|
15
|
-
flunk "No implementation provided for #{name}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
1
|
+
module Test::Unit
|
2
|
+
# Used to fix a minor minitest/unit incompatibility in flexmock
|
3
|
+
AssertionFailedError = Class.new(StandardError)
|
4
|
+
|
5
|
+
class TestCase
|
6
|
+
|
7
|
+
def self.test(name, &block)
|
8
|
+
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
9
|
+
defined = instance_method(test_name) rescue false
|
10
|
+
raise "#{test_name} is already defined in #{self}" if defined
|
11
|
+
if block_given?
|
12
|
+
define_method(test_name, &block)
|
13
|
+
else
|
14
|
+
define_method(test_name) do
|
15
|
+
flunk "No implementation provided for #{name}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
21
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
TEST_LIVE_API = false
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'test/unit'
|
5
|
-
|
6
|
-
unless(TEST_LIVE_API)
|
7
|
-
require 'webmock/test_unit'
|
8
|
-
include WebMock
|
9
|
-
end
|
10
|
-
|
11
|
-
require_files = []
|
12
|
-
require_files << File.join(File.dirname(__FILE__), '..', 'lib', 'ruby-tmdb.rb')
|
13
|
-
require_files.concat Dir[File.join(File.dirname(__FILE__), 'setup', '*.rb')]
|
14
|
-
|
15
|
-
require_files.each do |file|
|
16
|
-
require File.expand_path(file)
|
17
|
-
end
|
18
|
-
|
19
|
-
#load(File.join('unit', 'test_direct_require.rb'), true)
|
1
|
+
TEST_LIVE_API = false
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
unless(TEST_LIVE_API)
|
7
|
+
require 'webmock/test_unit'
|
8
|
+
include WebMock
|
9
|
+
end
|
10
|
+
|
11
|
+
require_files = []
|
12
|
+
require_files << File.join(File.dirname(__FILE__), '..', 'lib', 'ruby-tmdb.rb')
|
13
|
+
require_files.concat Dir[File.join(File.dirname(__FILE__), 'setup', '*.rb')]
|
14
|
+
|
15
|
+
require_files.each do |file|
|
16
|
+
require File.expand_path(file)
|
17
|
+
end
|
18
|
+
|
19
|
+
#load(File.join('unit', 'test_direct_require.rb'), true)
|
20
20
|
system('ruby ' + File.expand_path(File.join(File.dirname(__FILE__), 'unit', 'test_direct_require.rb')))
|
@@ -1,25 +1,25 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
|
3
|
-
require_files = []
|
4
|
-
require_files << File.join(File.dirname(__FILE__), "..", "..", "lib", "ruby-tmdb.rb")
|
5
|
-
require_files.concat Dir[File.join(File.dirname(__FILE__), '..', 'setup', '*.rb')]
|
6
|
-
|
7
|
-
require_files.each do |file|
|
8
|
-
require File.expand_path(file)
|
9
|
-
end
|
10
|
-
|
11
|
-
class DirectRequireTest < Test::Unit::TestCase
|
12
|
-
|
13
|
-
test "TmdbMovie should not raise exception when directly required without using rubygems" do
|
14
|
-
assert_nothing_raised do
|
15
|
-
TmdbMovie.find(:id => 187)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
test "TmdbCast should not raise exception when directly required without using rubygems" do
|
20
|
-
assert_nothing_raised do
|
21
|
-
TmdbCast.find(:id => 287)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
1
|
+
require "test/unit"
|
2
|
+
|
3
|
+
require_files = []
|
4
|
+
require_files << File.join(File.dirname(__FILE__), "..", "..", "lib", "ruby-tmdb.rb")
|
5
|
+
require_files.concat Dir[File.join(File.dirname(__FILE__), '..', 'setup', '*.rb')]
|
6
|
+
|
7
|
+
require_files.each do |file|
|
8
|
+
require File.expand_path(file)
|
9
|
+
end
|
10
|
+
|
11
|
+
class DirectRequireTest < Test::Unit::TestCase
|
12
|
+
|
13
|
+
test "TmdbMovie should not raise exception when directly required without using rubygems" do
|
14
|
+
assert_nothing_raised do
|
15
|
+
TmdbMovie.find(:id => 187)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
test "TmdbCast should not raise exception when directly required without using rubygems" do
|
20
|
+
assert_nothing_raised do
|
21
|
+
TmdbCast.find(:id => 287)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
25
|
end
|
data/test/unit/tmdb_test.rb
CHANGED
@@ -1,158 +1,158 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
|
2
|
-
|
3
|
-
class TmdbTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
register_api_url_stubs
|
7
|
-
end
|
8
|
-
|
9
|
-
test "allows setting of api_key" do
|
10
|
-
old_api_key = Tmdb.api_key
|
11
|
-
api_key = "test1234567890"
|
12
|
-
Tmdb.api_key = api_key
|
13
|
-
assert_equal Tmdb.api_key, api_key
|
14
|
-
Tmdb.api_key = old_api_key
|
15
|
-
end
|
16
|
-
|
17
|
-
test "should return base API url" do
|
18
|
-
assert_equal "http://api.themoviedb.org/2.1/", Tmdb.base_api_url
|
19
|
-
end
|
20
|
-
|
21
|
-
test "get url returns a response object" do
|
22
|
-
test_response = Tmdb.get_url("http://example.com/")
|
23
|
-
assert_equal 200, test_response.code.to_i
|
24
|
-
end
|
25
|
-
|
26
|
-
test "getting nonexistent URL returns response object" do
|
27
|
-
test_response = Tmdb.get_url('http://thisisaurlthatdoesntexist.co.nz')
|
28
|
-
assert_equal 404, test_response.code.to_i
|
29
|
-
end
|
30
|
-
|
31
|
-
test "api_call should raise exception if api_key is not set" do
|
32
|
-
old_api_key = Tmdb.api_key
|
33
|
-
Tmdb.api_key = ""
|
34
|
-
assert_raises ArgumentError do
|
35
|
-
Tmdb.api_call('Movie.search', 'Transformers')
|
36
|
-
end
|
37
|
-
Tmdb.api_key = old_api_key
|
38
|
-
end
|
39
|
-
|
40
|
-
test "should perform Movie.search API call and return array of results" do
|
41
|
-
movies = Tmdb.api_call('Movie.search', 'Transformers')
|
42
|
-
assert_kind_of Array, movies
|
43
|
-
assert movies.length > 1
|
44
|
-
movies.each do |movie|
|
45
|
-
assert_kind_of Hash, movie
|
46
|
-
["url", "id", "name"].each do |item|
|
47
|
-
assert movie[item]
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
test "should perform Movie.getInfo API call and return array of results" do
|
53
|
-
movies = Tmdb.api_call('Movie.getInfo', 187)
|
54
|
-
assert_kind_of Array, movies
|
55
|
-
assert movies.length == 1
|
56
|
-
movies.each do |movie|
|
57
|
-
assert_kind_of Hash, movie
|
58
|
-
["url", "id", "name"].each do |item|
|
59
|
-
assert movie[item]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
test "should perform Movie.imdbLookup API call and return array of results" do
|
65
|
-
movies = Tmdb.api_call('Movie.imdbLookup', "tt0401792")
|
66
|
-
assert_kind_of Array, movies
|
67
|
-
assert movies.length == 1
|
68
|
-
movies.each do |movie|
|
69
|
-
assert_kind_of Hash, movie
|
70
|
-
["url", "id", "name"].each do |item|
|
71
|
-
assert movie[item]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
test "should perform Person.getInfo API call and return array of results" do
|
77
|
-
people = Tmdb.api_call('Person.getInfo', 287)
|
78
|
-
assert_kind_of Array, people
|
79
|
-
assert people.length == 1
|
80
|
-
people.each do |person|
|
81
|
-
assert_kind_of Hash, person
|
82
|
-
["url", "id", "name"].each do |item|
|
83
|
-
assert person[item]
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
test "should perform Person.search API call and return array of results" do
|
89
|
-
people = Tmdb.api_call('Person.search', "vince")
|
90
|
-
assert_kind_of Array, people
|
91
|
-
assert people.length > 1
|
92
|
-
people.each do |person|
|
93
|
-
assert_kind_of Hash, person
|
94
|
-
["url", "id", "name"].each do |item|
|
95
|
-
assert person[item]
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
test "failed API call should return nil" do
|
101
|
-
movies = Tmdb.api_call('Movie.blarg', 'Transformers')
|
102
|
-
assert_kind_of NilClass, movies
|
103
|
-
assert_nil movies
|
104
|
-
end
|
105
|
-
|
106
|
-
test "API call that finds no results should return nil" do
|
107
|
-
movies = Tmdb.api_call('Search.empty', 'Transformers')
|
108
|
-
assert_kind_of NilClass, movies
|
109
|
-
assert_nil movies
|
110
|
-
end
|
111
|
-
|
112
|
-
test "API call cache should not be changed when data altered in the receiving method" do
|
113
|
-
person = Tmdb.api_call('Person.getInfo', 287)[0]
|
114
|
-
assert_not_nil person[person.keys[0]]
|
115
|
-
person[person.keys[0]] = nil
|
116
|
-
person = Tmdb.api_call('Person.getInfo', 287)[0]
|
117
|
-
assert_not_nil person[person.keys[0]]
|
118
|
-
end
|
119
|
-
|
120
|
-
test "data_to_object should create object from nested data structures" do
|
121
|
-
test_data = {
|
122
|
-
:test1 => [
|
123
|
-
1,2,3,4
|
124
|
-
],
|
125
|
-
:test2 => 1
|
126
|
-
}
|
127
|
-
test_object = Tmdb.data_to_object(test_data)
|
128
|
-
assert_nothing_raised do
|
129
|
-
assert_equal [1,2,3,4], test_object.test1
|
130
|
-
assert_equal 1, test_object.test2
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
test "data_to_object should include raw_data method that returns original data" do
|
135
|
-
test_data = {
|
136
|
-
:test1 => [1,2,3]
|
137
|
-
}
|
138
|
-
test_object = Tmdb.data_to_object(test_data)
|
139
|
-
assert_equal test_object.raw_data, test_data
|
140
|
-
end
|
141
|
-
|
142
|
-
test "data_to_object should convert arrays containing images to nicer format" do
|
143
|
-
test_data = {
|
144
|
-
"backdrops" => [
|
145
|
-
{
|
146
|
-
"image" => {
|
147
|
-
:test => 1
|
148
|
-
}
|
149
|
-
}
|
150
|
-
]
|
151
|
-
}
|
152
|
-
test_object = Tmdb.data_to_object(test_data)
|
153
|
-
assert_nothing_raised do
|
154
|
-
assert_equal 1, test_object.backdrops[0].test
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
|
2
|
+
|
3
|
+
class TmdbTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
register_api_url_stubs
|
7
|
+
end
|
8
|
+
|
9
|
+
test "allows setting of api_key" do
|
10
|
+
old_api_key = Tmdb.api_key
|
11
|
+
api_key = "test1234567890"
|
12
|
+
Tmdb.api_key = api_key
|
13
|
+
assert_equal Tmdb.api_key, api_key
|
14
|
+
Tmdb.api_key = old_api_key
|
15
|
+
end
|
16
|
+
|
17
|
+
test "should return base API url" do
|
18
|
+
assert_equal "http://api.themoviedb.org/2.1/", Tmdb.base_api_url
|
19
|
+
end
|
20
|
+
|
21
|
+
test "get url returns a response object" do
|
22
|
+
test_response = Tmdb.get_url("http://example.com/")
|
23
|
+
assert_equal 200, test_response.code.to_i
|
24
|
+
end
|
25
|
+
|
26
|
+
test "getting nonexistent URL returns response object" do
|
27
|
+
test_response = Tmdb.get_url('http://thisisaurlthatdoesntexist.co.nz')
|
28
|
+
assert_equal 404, test_response.code.to_i
|
29
|
+
end
|
30
|
+
|
31
|
+
test "api_call should raise exception if api_key is not set" do
|
32
|
+
old_api_key = Tmdb.api_key
|
33
|
+
Tmdb.api_key = ""
|
34
|
+
assert_raises ArgumentError do
|
35
|
+
Tmdb.api_call('Movie.search', 'Transformers')
|
36
|
+
end
|
37
|
+
Tmdb.api_key = old_api_key
|
38
|
+
end
|
39
|
+
|
40
|
+
test "should perform Movie.search API call and return array of results" do
|
41
|
+
movies = Tmdb.api_call('Movie.search', 'Transformers')
|
42
|
+
assert_kind_of Array, movies
|
43
|
+
assert movies.length > 1
|
44
|
+
movies.each do |movie|
|
45
|
+
assert_kind_of Hash, movie
|
46
|
+
["url", "id", "name"].each do |item|
|
47
|
+
assert movie[item]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
test "should perform Movie.getInfo API call and return array of results" do
|
53
|
+
movies = Tmdb.api_call('Movie.getInfo', 187)
|
54
|
+
assert_kind_of Array, movies
|
55
|
+
assert movies.length == 1
|
56
|
+
movies.each do |movie|
|
57
|
+
assert_kind_of Hash, movie
|
58
|
+
["url", "id", "name"].each do |item|
|
59
|
+
assert movie[item]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
test "should perform Movie.imdbLookup API call and return array of results" do
|
65
|
+
movies = Tmdb.api_call('Movie.imdbLookup', "tt0401792")
|
66
|
+
assert_kind_of Array, movies
|
67
|
+
assert movies.length == 1
|
68
|
+
movies.each do |movie|
|
69
|
+
assert_kind_of Hash, movie
|
70
|
+
["url", "id", "name"].each do |item|
|
71
|
+
assert movie[item]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
test "should perform Person.getInfo API call and return array of results" do
|
77
|
+
people = Tmdb.api_call('Person.getInfo', 287)
|
78
|
+
assert_kind_of Array, people
|
79
|
+
assert people.length == 1
|
80
|
+
people.each do |person|
|
81
|
+
assert_kind_of Hash, person
|
82
|
+
["url", "id", "name"].each do |item|
|
83
|
+
assert person[item]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
test "should perform Person.search API call and return array of results" do
|
89
|
+
people = Tmdb.api_call('Person.search', "vince")
|
90
|
+
assert_kind_of Array, people
|
91
|
+
assert people.length > 1
|
92
|
+
people.each do |person|
|
93
|
+
assert_kind_of Hash, person
|
94
|
+
["url", "id", "name"].each do |item|
|
95
|
+
assert person[item]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
test "failed API call should return nil" do
|
101
|
+
movies = Tmdb.api_call('Movie.blarg', 'Transformers')
|
102
|
+
assert_kind_of NilClass, movies
|
103
|
+
assert_nil movies
|
104
|
+
end
|
105
|
+
|
106
|
+
test "API call that finds no results should return nil" do
|
107
|
+
movies = Tmdb.api_call('Search.empty', 'Transformers')
|
108
|
+
assert_kind_of NilClass, movies
|
109
|
+
assert_nil movies
|
110
|
+
end
|
111
|
+
|
112
|
+
test "API call cache should not be changed when data altered in the receiving method" do
|
113
|
+
person = Tmdb.api_call('Person.getInfo', 287)[0]
|
114
|
+
assert_not_nil person[person.keys[0]]
|
115
|
+
person[person.keys[0]] = nil
|
116
|
+
person = Tmdb.api_call('Person.getInfo', 287)[0]
|
117
|
+
assert_not_nil person[person.keys[0]]
|
118
|
+
end
|
119
|
+
|
120
|
+
test "data_to_object should create object from nested data structures" do
|
121
|
+
test_data = {
|
122
|
+
:test1 => [
|
123
|
+
1,2,3,4
|
124
|
+
],
|
125
|
+
:test2 => 1
|
126
|
+
}
|
127
|
+
test_object = Tmdb.data_to_object(test_data)
|
128
|
+
assert_nothing_raised do
|
129
|
+
assert_equal [1,2,3,4], test_object.test1
|
130
|
+
assert_equal 1, test_object.test2
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
test "data_to_object should include raw_data method that returns original data" do
|
135
|
+
test_data = {
|
136
|
+
:test1 => [1,2,3]
|
137
|
+
}
|
138
|
+
test_object = Tmdb.data_to_object(test_data)
|
139
|
+
assert_equal test_object.raw_data, test_data
|
140
|
+
end
|
141
|
+
|
142
|
+
test "data_to_object should convert arrays containing images to nicer format" do
|
143
|
+
test_data = {
|
144
|
+
"backdrops" => [
|
145
|
+
{
|
146
|
+
"image" => {
|
147
|
+
:test => 1
|
148
|
+
}
|
149
|
+
}
|
150
|
+
]
|
151
|
+
}
|
152
|
+
test_object = Tmdb.data_to_object(test_data)
|
153
|
+
assert_nothing_raised do
|
154
|
+
assert_equal 1, test_object.backdrops[0].test
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
158
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Aaron Gough
|
@@ -14,13 +14,14 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-06 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: deepopenstruct
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
@@ -32,17 +33,31 @@ dependencies:
|
|
32
33
|
type: :runtime
|
33
34
|
version_requirements: *id001
|
34
35
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
36
|
+
name: json
|
36
37
|
prerelease: false
|
37
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
38
40
|
requirements:
|
39
41
|
- - ">="
|
40
42
|
- !ruby/object:Gem::Version
|
41
43
|
segments:
|
42
44
|
- 0
|
43
45
|
version: "0"
|
44
|
-
type: :
|
46
|
+
type: :runtime
|
45
47
|
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: webmock
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
type: :development
|
60
|
+
version_requirements: *id003
|
46
61
|
description: An ActiveRecord-style API wrapper for TheMovieDB.org
|
47
62
|
email: aaron@aarongough.com
|
48
63
|
executables: []
|
@@ -93,6 +108,7 @@ rdoc_options:
|
|
93
108
|
require_paths:
|
94
109
|
- lib
|
95
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
96
112
|
requirements:
|
97
113
|
- - ">="
|
98
114
|
- !ruby/object:Gem::Version
|
@@ -100,6 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
116
|
- 0
|
101
117
|
version: "0"
|
102
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
103
120
|
requirements:
|
104
121
|
- - ">="
|
105
122
|
- !ruby/object:Gem::Version
|
@@ -109,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
126
|
requirements: []
|
110
127
|
|
111
128
|
rubyforge_project:
|
112
|
-
rubygems_version: 1.3.
|
129
|
+
rubygems_version: 1.3.7
|
113
130
|
signing_key:
|
114
131
|
specification_version: 3
|
115
132
|
summary: An ActiveRecord-style API wrapper for TheMovieDB.org
|