simple_youtube 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/simple_youtube/activeyoutube.rb +4 -3
- data/spec/fakeweb_helper.rb +6 -2
- data/spec/spec_helper.rb +7 -0
- data/spec/youtube_read_spec.rb +7 -3
- data/spec/youtube_update_spec.rb +1 -1
- metadata +8 -6
@@ -3,16 +3,17 @@ require 'active_resource'
|
|
3
3
|
require File.dirname(__FILE__) + "/entry_interface_shim"
|
4
4
|
|
5
5
|
class ActiveYoutube < ActiveResource::Base
|
6
|
-
|
6
|
+
|
7
7
|
include EntryInterfaceShim
|
8
8
|
|
9
9
|
self.site = "http://gdata.youtube.com/feeds/api"
|
10
|
+
self.format = :xml
|
10
11
|
|
11
12
|
def self.find(args)
|
12
13
|
scope, type, query = args[:scope], args[:type], args[:params]
|
13
14
|
headers['Accept'] = "application/atom+xml"
|
14
15
|
path = "#{prefix()}#{collection_name}#{'/' if scope}#{scope}#{'/' if type}#{type}#{query_string(query)}"
|
15
|
-
instantiate_record(connection.get(path, headers))
|
16
|
+
instantiate_record(format.decode(connection.get(path, headers).body))
|
16
17
|
end
|
17
|
-
|
18
|
+
|
18
19
|
end
|
data/spec/fakeweb_helper.rb
CHANGED
@@ -2,7 +2,7 @@ require 'fakeweb'
|
|
2
2
|
|
3
3
|
module FakewebHelper
|
4
4
|
# Make sure nothing gets out (IMPORTANT)
|
5
|
-
FakeWeb.allow_net_connect = false
|
5
|
+
FakeWeb.allow_net_connect = false
|
6
6
|
|
7
7
|
# Turns a fixture file name into a full path
|
8
8
|
def fixture_file(filename)
|
@@ -13,6 +13,10 @@ module FakewebHelper
|
|
13
13
|
# Convenience methods for stubbing URLs to fixtures
|
14
14
|
def stub_get(url, filename)
|
15
15
|
FakeWeb.register_uri(:get, url, :response => fixture_file(filename))
|
16
|
-
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def stub_http_error(http_type, url, error_code, error_message)
|
19
|
+
FakeWeb.register_uri(http_type, url, :status => [error_code, error_message])
|
20
|
+
end
|
17
21
|
|
18
22
|
end
|
data/spec/spec_helper.rb
ADDED
data/spec/youtube_read_spec.rb
CHANGED
@@ -1,16 +1,20 @@
|
|
1
|
-
require
|
2
|
-
require File.dirname(__FILE__) + "/fakeweb_helper"
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe 'YoutubeFindSpec' do
|
5
4
|
|
6
5
|
include FakewebHelper
|
7
6
|
|
8
|
-
it "finds video search for uid" do
|
7
|
+
it "finds video search for uid", :wip do
|
9
8
|
stub_get('http://gdata.youtube.com/feeds/api/videos/wOzOc0xxJu8?v=2', 'video_uid.xml')
|
10
9
|
video_uid = Youtube::Video.find(:scope => 'wOzOc0xxJu8', :params => {:v => '2'})
|
11
10
|
video_uid.entry.size.should == 1
|
12
11
|
video_uid.entry[0].title.should == "Michael Watford - So Into You (Dub Mix)"
|
13
12
|
end
|
13
|
+
|
14
|
+
it "fails to connect to Youtube", :fail do
|
15
|
+
stub_http_error(:get, 'http://gdata.youtube.com/feeds/api/videos/wOzOc0xxJu8?v=2', '500', 'Server Error')
|
16
|
+
lambda {Youtube::Video.find(:scope => 'wOzOc0xxJu8', :params => {:v => '2'})}.should raise_error(ActiveResource::ServerError, "Failed. Response code = 500. Response message = Server Error.")
|
17
|
+
end
|
14
18
|
|
15
19
|
it "finds video search for top 5 ruby on rails videos" do
|
16
20
|
stub_get('http://gdata.youtube.com/feeds/api/videos?q=ruby+on+rails&max-results=5&v=2', 'video_search.xml')
|
data/spec/youtube_update_spec.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: simple_youtube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.0
|
5
|
+
version: 2.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James Shipton
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-09-30 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ~>
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 3.0
|
24
|
+
version: 3.1.0
|
25
25
|
type: :runtime
|
26
26
|
version_requirements: *id001
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - ~>
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.4.
|
35
|
+
version: 0.4.5
|
36
36
|
type: :runtime
|
37
37
|
version_requirements: *id002
|
38
38
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.
|
46
|
+
version: 1.3.0
|
47
47
|
type: :development
|
48
48
|
version_requirements: *id003
|
49
49
|
- !ruby/object:Gem::Dependency
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
requirements:
|
55
55
|
- - ~>
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: "2.
|
57
|
+
version: "2.6"
|
58
58
|
type: :development
|
59
59
|
version_requirements: *id004
|
60
60
|
description: ActiveResource extension to Gdata Youtube API, anonymous Reads, Updates using your API key and OAuth, no Create or Delete access.
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- spec/fixture/video_search.xml
|
92
92
|
- spec/fixture/video_uid.xml
|
93
93
|
- spec/fixture/video_update.xml
|
94
|
+
- spec/spec_helper.rb
|
94
95
|
- spec/youtube_read_spec.rb
|
95
96
|
- spec/youtube_update_spec.rb
|
96
97
|
has_rdoc: true
|
@@ -142,5 +143,6 @@ test_files:
|
|
142
143
|
- spec/fixture/video_search.xml
|
143
144
|
- spec/fixture/video_uid.xml
|
144
145
|
- spec/fixture/video_update.xml
|
146
|
+
- spec/spec_helper.rb
|
145
147
|
- spec/youtube_read_spec.rb
|
146
148
|
- spec/youtube_update_spec.rb
|