sproutvideo-rb 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "httpclient"
3
+ gem "rest-client"
4
4
  gem "multi_json"
5
5
 
6
6
  group :development do
@@ -3,18 +3,20 @@ GEM
3
3
  specs:
4
4
  diff-lcs (1.1.3)
5
5
  git (1.2.5)
6
- httpclient (2.2.4)
7
6
  jeweler (1.8.3)
8
7
  bundler (~> 1.0)
9
8
  git (>= 1.2.5)
10
9
  rake
11
10
  rdoc
12
11
  json (1.6.5)
12
+ mime-types (1.19)
13
13
  multi_json (1.0.4)
14
14
  rake (0.9.2.2)
15
15
  rcov (1.0.0)
16
16
  rdoc (3.12)
17
17
  json (~> 1.4)
18
+ rest-client (1.6.1)
19
+ mime-types (>= 1.16)
18
20
  rspec (2.8.0)
19
21
  rspec-core (~> 2.8.0)
20
22
  rspec-expectations (~> 2.8.0)
@@ -29,9 +31,9 @@ PLATFORMS
29
31
 
30
32
  DEPENDENCIES
31
33
  bundler (~> 1.0.0)
32
- httpclient
33
34
  jeweler (~> 1.8.3)
34
35
  multi_json
35
36
  rcov
36
37
  rdoc (~> 3.12)
38
+ rest-client
37
39
  rspec (~> 2.8.0)
@@ -1,5 +1,5 @@
1
1
  require 'multi_json'
2
- require 'httpclient'
2
+ require 'rest_client'
3
3
 
4
4
  require 'sproutvideo/version.rb'
5
5
  require 'sproutvideo/sproutvideo.rb'
@@ -9,10 +9,14 @@ module Sproutvideo
9
9
 
10
10
  def self.post(path, options={})
11
11
  body = MultiJson.encode(options.dup)
12
- resp = HTTPClient.new.post(
13
- "#{base_url}#{path}",
14
- body,
15
- {'SproutVideo-Api-Key' => api_key})
12
+ begin
13
+ resp = RestClient.post(
14
+ "#{base_url}#{path}",
15
+ body,
16
+ {'SproutVideo-Api-Key' => api_key})
17
+ rescue => e
18
+ resp = e.response
19
+ end
16
20
  Response.new(resp)
17
21
  end
18
22
 
@@ -20,40 +24,51 @@ module Sproutvideo
20
24
  resp = nil
21
25
  File.open(file_path) do |file|
22
26
  body = {:source_video => file}.merge(options.dup)
23
- client = HTTPClient.new
24
- client.send_timeout = 18000
25
- resp = client.post(
26
- "#{base_url}#{path}",
27
- body,
28
- {'SproutVideo-Api-Key' => api_key})
27
+ begin
28
+ resp = RestClient.post(
29
+ "#{base_url}#{path}",
30
+ body,
31
+ {'SproutVideo-Api-Key' => api_key, :timeout => 18000})
32
+ rescue => e
33
+ resp = e.response
34
+ end
29
35
  end
30
36
 
31
37
  Response.new(resp)
32
38
  end
33
39
 
34
40
  def self.get(path, options={})
35
- options = options.dup
36
- resp = HTTPClient.new.get(
37
- "#{base_url}#{path}",
38
- options,
39
- {'SproutVideo-Api-Key' => api_key})
41
+ begin
42
+ resp = RestClient.get(
43
+ "#{base_url}#{path}",
44
+ {'SproutVideo-Api-Key' => api_key, :params => options.dup})
45
+ rescue => e
46
+ resp = e.response
47
+ end
40
48
  Response.new(resp)
41
49
  end
42
50
 
43
51
  def self.put(path, options={})
44
52
  body = MultiJson.encode(options.dup)
45
- resp = HTTPClient.new.put(
46
- "#{base_url}#{path}",
47
- body,
48
- {'SproutVideo-Api-Key' => api_key})
53
+ begin
54
+ resp = RestClient.put(
55
+ "#{base_url}#{path}",
56
+ body,
57
+ {'SproutVideo-Api-Key' => api_key})
58
+ rescue => e
59
+ resp = e.response
60
+ end
49
61
  Response.new(resp)
50
62
  end
51
63
 
52
64
  def self.delete(path, options={})
53
- resp = HTTPClient.new.delete(
54
- "#{base_url}#{path}",
55
- {},
56
- {'SproutVideo-Api-Key' => api_key})
65
+ begin
66
+ resp = RestClient.delete(
67
+ "#{base_url}#{path}",
68
+ {'SproutVideo-Api-Key' => api_key})
69
+ rescue => e
70
+ resp = e.response
71
+ end
57
72
  Response.new(resp)
58
73
  end
59
74
  end
@@ -3,8 +3,8 @@ module Sproutvideo
3
3
  attr_accessor :status, :body, :raw_body
4
4
 
5
5
  def initialize(msg)
6
- self.status = msg.status
7
- self.raw_body = msg.body
6
+ self.status = msg.code
7
+ self.raw_body = msg.to_s
8
8
  self.body = MultiJson.decode(self.raw_body, :symbolize_keys => true)
9
9
  end
10
10
 
@@ -1,3 +1,3 @@
1
1
  module Sproutvideo
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -4,9 +4,7 @@ describe Sproutvideo::AccessGrant do
4
4
  @api_key = 'abc123'
5
5
  Sproutvideo.api_key = @api_key
6
6
  Sproutvideo.base_url = 'https://api.sproutvideo.com/v1'
7
- @http_mock = mock()
8
- HTTPClient.stub!(:new).and_return(@http_mock)
9
- @msg = mock(:body => "{}", :status => 200)
7
+ @msg = mock(:to_s => "{}", :code => 200)
10
8
  end
11
9
 
12
10
  describe "#create" do
@@ -16,7 +14,7 @@ describe Sproutvideo::AccessGrant do
16
14
 
17
15
  it "should POST the correct url and return a response" do
18
16
  data = {:email => 'test@example.com', :password => 'password'}
19
- @http_mock.should_receive(:post).with(
17
+ RestClient.should_receive(:post).with(
20
18
  @url,
21
19
  MultiJson.encode(data),
22
20
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
@@ -31,26 +29,23 @@ describe Sproutvideo::AccessGrant do
31
29
 
32
30
  it "should GET the correct url and return a response" do
33
31
 
34
- @http_mock.should_receive(:get).with(
32
+ RestClient.should_receive(:get).with(
35
33
  @url,
36
- {:page => 1, :per_page => 25},
37
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
34
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25}}).and_return(@msg)
38
35
  Sproutvideo::AccessGrant.list.class.should == Sproutvideo::Response
39
36
  end
40
37
 
41
38
  it "should merge params" do
42
- @http_mock.should_receive(:get).with(
39
+ RestClient.should_receive(:get).with(
43
40
  @url,
44
- {:page => 1, :per_page => 25, :foo => 'bar'},
45
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
41
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25, :foo => 'bar'}}).and_return(@msg)
46
42
  Sproutvideo::AccessGrant.list(:foo => 'bar')
47
43
  end
48
44
 
49
45
  it "should use pagination params" do
50
- @http_mock.should_receive(:get).with(
46
+ RestClient.should_receive(:get).with(
51
47
  @url,
52
- {:page => 2, :per_page => 5},
53
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
48
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 2, :per_page => 5}}).and_return(@msg)
54
49
  Sproutvideo::AccessGrant.list(:page => 2, :per_page => 5)
55
50
  end
56
51
  end
@@ -62,10 +57,9 @@ describe Sproutvideo::AccessGrant do
62
57
  end
63
58
 
64
59
  it "should get the correct url and return a response" do
65
- @http_mock.should_receive(:get).with(
60
+ RestClient.should_receive(:get).with(
66
61
  @url,
67
- {},
68
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
62
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
69
63
  Sproutvideo::AccessGrant.details(@access_grant_id).class.should == Sproutvideo::Response
70
64
  end
71
65
  end
@@ -79,7 +73,7 @@ describe Sproutvideo::AccessGrant do
79
73
  it "should PUT the correct url and return a response" do
80
74
  data = {:password => 'new password'}
81
75
 
82
- @http_mock.should_receive(:put).with(
76
+ RestClient.should_receive(:put).with(
83
77
  @url,
84
78
  MultiJson.encode(data),
85
79
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
@@ -95,9 +89,8 @@ describe Sproutvideo::AccessGrant do
95
89
  end
96
90
 
97
91
  it "should DELETE the correct url and return a response" do
98
- @http_mock.should_receive(:delete).with(
92
+ RestClient.should_receive(:delete).with(
99
93
  @url,
100
- {},
101
94
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
102
95
  Sproutvideo::AccessGrant.destroy(@access_grant_id).class.should == Sproutvideo::Response
103
96
  end
@@ -4,9 +4,7 @@ describe Sproutvideo::Login do
4
4
  @api_key = 'abc123'
5
5
  Sproutvideo.api_key = @api_key
6
6
  Sproutvideo.base_url = 'https://api.sproutvideo.com/v1'
7
- @http_mock = mock()
8
- HTTPClient.stub!(:new).and_return(@http_mock)
9
- @msg = mock(:body => "{}", :status => 200)
7
+ @msg = mock(:to_s => "{}", :code => 200)
10
8
  end
11
9
 
12
10
  describe "#create" do
@@ -16,7 +14,7 @@ describe Sproutvideo::Login do
16
14
 
17
15
  it "should POST the correct url and return a response" do
18
16
  data = {:email => 'test@example.com', :password => 'password'}
19
- @http_mock.should_receive(:post).with(
17
+ RestClient.should_receive(:post).with(
20
18
  @url,
21
19
  MultiJson.encode(data),
22
20
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
@@ -31,26 +29,23 @@ describe Sproutvideo::Login do
31
29
 
32
30
  it "should GET the correct url and return a response" do
33
31
 
34
- @http_mock.should_receive(:get).with(
32
+ RestClient.should_receive(:get).with(
35
33
  @url,
36
- {:page => 1, :per_page => 25},
37
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
34
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25}}).and_return(@msg)
38
35
  Sproutvideo::Login.list.class.should == Sproutvideo::Response
39
36
  end
40
37
 
41
38
  it "should merge params" do
42
- @http_mock.should_receive(:get).with(
39
+ RestClient.should_receive(:get).with(
43
40
  @url,
44
- {:page => 1, :per_page => 25, :foo => 'bar'},
45
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
41
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25, :foo => 'bar'}}).and_return(@msg)
46
42
  Sproutvideo::Login.list(:foo => 'bar')
47
43
  end
48
44
 
49
45
  it "should use pagination params" do
50
- @http_mock.should_receive(:get).with(
46
+ RestClient.should_receive(:get).with(
51
47
  @url,
52
- {:page => 2, :per_page => 5},
53
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
48
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 2, :per_page => 5}}).and_return(@msg)
54
49
  Sproutvideo::Login.list(:page => 2, :per_page => 5)
55
50
  end
56
51
  end
@@ -62,10 +57,9 @@ describe Sproutvideo::Login do
62
57
  end
63
58
 
64
59
  it "should get the correct url and return a response" do
65
- @http_mock.should_receive(:get).with(
60
+ RestClient.should_receive(:get).with(
66
61
  @url,
67
- {},
68
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
62
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
69
63
  Sproutvideo::Login.details(@login_id).class.should == Sproutvideo::Response
70
64
  end
71
65
  end
@@ -79,7 +73,7 @@ describe Sproutvideo::Login do
79
73
  it "should PUT the correct url and return a response" do
80
74
  data = {:password => 'new password'}
81
75
 
82
- @http_mock.should_receive(:put).with(
76
+ RestClient.should_receive(:put).with(
83
77
  @url,
84
78
  MultiJson.encode(data),
85
79
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
@@ -95,9 +89,8 @@ describe Sproutvideo::Login do
95
89
  end
96
90
 
97
91
  it "should DELETE the correct url and return a response" do
98
- @http_mock.should_receive(:delete).with(
92
+ RestClient.should_receive(:delete).with(
99
93
  @url,
100
- {},
101
94
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
102
95
  Sproutvideo::Login.destroy(@login_id).class.should == Sproutvideo::Response
103
96
  end
@@ -4,9 +4,7 @@ describe Sproutvideo::Playlist do
4
4
  @api_key = 'abc123'
5
5
  Sproutvideo.api_key = @api_key
6
6
  Sproutvideo.base_url = 'https://api.sproutvideo.com/v1'
7
- @http_mock = mock()
8
- HTTPClient.stub!(:new).and_return(@http_mock)
9
- @msg = mock(:body => "{}", :status => 200)
7
+ @msg = mock(:to_s => "{}", :code => 200)
10
8
  end
11
9
 
12
10
  describe "#create" do
@@ -16,7 +14,7 @@ describe Sproutvideo::Playlist do
16
14
 
17
15
  it "should POST the correct url and return a response" do
18
16
  data = {:name => 'new playlist'}
19
- @http_mock.should_receive(:post).with(
17
+ RestClient.should_receive(:post).with(
20
18
  @url,
21
19
  MultiJson.encode(data),
22
20
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
@@ -31,26 +29,23 @@ describe Sproutvideo::Playlist do
31
29
 
32
30
  it "should GET the correct url and return a response" do
33
31
 
34
- @http_mock.should_receive(:get).with(
32
+ RestClient.should_receive(:get).with(
35
33
  @url,
36
- {:page => 1, :per_page => 25},
37
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
34
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25}}).and_return(@msg)
38
35
  Sproutvideo::Playlist.list.class.should == Sproutvideo::Response
39
36
  end
40
37
 
41
38
  it "should merge params" do
42
- @http_mock.should_receive(:get).with(
39
+ RestClient.should_receive(:get).with(
43
40
  @url,
44
- {:page => 1, :per_page => 25, :foo => 'bar'},
45
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
41
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25, :foo => 'bar'}}).and_return(@msg)
46
42
  Sproutvideo::Playlist.list(:foo => 'bar')
47
43
  end
48
44
 
49
45
  it "should use pagination params" do
50
- @http_mock.should_receive(:get).with(
46
+ RestClient.should_receive(:get).with(
51
47
  @url,
52
- {:page => 2, :per_page => 5},
53
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
48
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 2, :per_page => 5}}).and_return(@msg)
54
49
  Sproutvideo::Playlist.list(:page => 2, :per_page => 5)
55
50
  end
56
51
  end
@@ -62,10 +57,9 @@ describe Sproutvideo::Playlist do
62
57
  end
63
58
 
64
59
  it "should get the correct url and return a response" do
65
- @http_mock.should_receive(:get).with(
60
+ RestClient.should_receive(:get).with(
66
61
  @url,
67
- {},
68
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
62
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
69
63
  Sproutvideo::Playlist.details(@playlist_id).class.should == Sproutvideo::Response
70
64
  end
71
65
  end
@@ -79,7 +73,7 @@ describe Sproutvideo::Playlist do
79
73
  it "should PUT the correct url and return a response" do
80
74
  data = {:name => 'new name'}
81
75
 
82
- @http_mock.should_receive(:put).with(
76
+ RestClient.should_receive(:put).with(
83
77
  @url,
84
78
  MultiJson.encode(data),
85
79
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
@@ -95,9 +89,8 @@ describe Sproutvideo::Playlist do
95
89
  end
96
90
 
97
91
  it "should DELETE the correct url and return a response" do
98
- @http_mock.should_receive(:delete).with(
92
+ RestClient.should_receive(:delete).with(
99
93
  @url,
100
- {},
101
94
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
102
95
  Sproutvideo::Playlist.destroy(@playlist_id).class.should == Sproutvideo::Response
103
96
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
2
2
  describe Sproutvideo::Response do
3
3
  describe "#success?" do
4
4
  it "should return true when status is between 200 and 299" do
5
- msg = mock(:status => 200, :body => "{}")
5
+ msg = mock(:code => 200, :to_s => "{}")
6
6
  Sproutvideo::Response.new(msg).success?.should == true
7
7
  msg.stub!(:status).and_return(299)
8
8
  Sproutvideo::Response.new(msg).success?.should == true
@@ -11,21 +11,21 @@ describe Sproutvideo::Response do
11
11
  end
12
12
 
13
13
  it "should return false when status is less than 200 or greater than 299" do
14
- msg = mock(:status => 300, :body => "{}")
14
+ msg = mock(:code => 300, :to_s => "{}")
15
15
  Sproutvideo::Response.new(msg).success?.should == false
16
- msg.stub!(:status => 199)
16
+ msg.stub!(:code => 199)
17
17
  Sproutvideo::Response.new(msg).success?.should == false
18
18
  end
19
19
  end
20
20
 
21
21
  describe "#errors" do
22
22
  it "should return an empty array when the result has no errors" do
23
- msg = mock(:status => 200, :body => "{}")
23
+ msg = mock(:code => 200, :to_s => "{}")
24
24
  Sproutvideo::Response.new(msg).errors.should == []
25
25
  end
26
26
 
27
27
  it "should return a compacted array of errors if the body has errors" do
28
- msg = mock(:status => 200, :body => '{"error":"Unauthorized"}')
28
+ msg = mock(:code => 200, :to_s => '{"error":"Unauthorized"}')
29
29
  Sproutvideo::Response.new(msg).errors.should == ['Unauthorized']
30
30
  end
31
31
  end
@@ -33,7 +33,7 @@ describe Sproutvideo::Response do
33
33
  describe "#body" do
34
34
  it "should decode the body" do
35
35
  body = {:foo => 'bar'}
36
- msg = mock(:status => 200, :body => MultiJson.encode(body))
36
+ msg = mock(:code => 200, :to_s => MultiJson.encode(body))
37
37
  Sproutvideo::Response.new(msg).body.should == body
38
38
  end
39
39
  end
@@ -4,9 +4,7 @@ describe Sproutvideo::Tag do
4
4
  @api_key = 'abc123'
5
5
  Sproutvideo.api_key = @api_key
6
6
  Sproutvideo.base_url = 'https://api.sproutvideo.com/v1'
7
- @http_mock = mock()
8
- HTTPClient.stub!(:new).and_return(@http_mock)
9
- @msg = mock(:body => "{}", :status => 200)
7
+ @msg = mock(:to_s => "{}", :code => 200)
10
8
  end
11
9
 
12
10
  describe "#create" do
@@ -16,7 +14,7 @@ describe Sproutvideo::Tag do
16
14
 
17
15
  it "should POST the correct url and return a response" do
18
16
  data = {:name => 'new tag'}
19
- @http_mock.should_receive(:post).with(
17
+ RestClient.should_receive(:post).with(
20
18
  @url,
21
19
  MultiJson.encode(data),
22
20
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
@@ -31,26 +29,23 @@ describe Sproutvideo::Tag do
31
29
 
32
30
  it "should GET the correct url and return a response" do
33
31
 
34
- @http_mock.should_receive(:get).with(
32
+ RestClient.should_receive(:get).with(
35
33
  @url,
36
- {:page => 1, :per_page => 25},
37
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
34
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25}}).and_return(@msg)
38
35
  Sproutvideo::Tag.list.class.should == Sproutvideo::Response
39
36
  end
40
37
 
41
38
  it "should merge params" do
42
- @http_mock.should_receive(:get).with(
39
+ RestClient.should_receive(:get).with(
43
40
  @url,
44
- {:page => 1, :per_page => 25, :foo => 'bar'},
45
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
41
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25, :foo => 'bar'}}).and_return(@msg)
46
42
  Sproutvideo::Tag.list(:foo => 'bar')
47
43
  end
48
44
 
49
45
  it "should use pagination params" do
50
- @http_mock.should_receive(:get).with(
46
+ RestClient.should_receive(:get).with(
51
47
  @url,
52
- {:page => 2, :per_page => 5},
53
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
48
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 2, :per_page => 5}}).and_return(@msg)
54
49
  Sproutvideo::Tag.list(:page => 2, :per_page => 5)
55
50
  end
56
51
  end
@@ -62,10 +57,9 @@ describe Sproutvideo::Tag do
62
57
  end
63
58
 
64
59
  it "should get the correct url and return a response" do
65
- @http_mock.should_receive(:get).with(
60
+ RestClient.should_receive(:get).with(
66
61
  @url,
67
- {},
68
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
62
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
69
63
  Sproutvideo::Tag.details(@tag_id).class.should == Sproutvideo::Response
70
64
  end
71
65
  end
@@ -79,7 +73,7 @@ describe Sproutvideo::Tag do
79
73
  it "should PUT the correct url and return a response" do
80
74
  data = {:name => 'new name'}
81
75
 
82
- @http_mock.should_receive(:put).with(
76
+ RestClient.should_receive(:put).with(
83
77
  @url,
84
78
  MultiJson.encode(data),
85
79
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
@@ -95,9 +89,8 @@ describe Sproutvideo::Tag do
95
89
  end
96
90
 
97
91
  it "should DELETE the correct url and return a response" do
98
- @http_mock.should_receive(:delete).with(
92
+ RestClient.should_receive(:delete).with(
99
93
  @url,
100
- {},
101
94
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
102
95
  Sproutvideo::Tag.destroy(@tag_id).class.should == Sproutvideo::Response
103
96
  end
@@ -4,9 +4,7 @@ describe Sproutvideo::Video do
4
4
  @api_key = 'abc123'
5
5
  Sproutvideo.api_key = @api_key
6
6
  Sproutvideo.base_url = 'https://api.sproutvideo.com/v1'
7
- @http_mock = mock(:send_timeout= => 18000)
8
- HTTPClient.stub!(:new).and_return(@http_mock)
9
- @msg = mock(:body => "{}", :status => 200)
7
+ @msg = mock(:to_s => "{}", :code => 200)
10
8
  end
11
9
 
12
10
  describe "#create" do
@@ -20,10 +18,10 @@ describe Sproutvideo::Video do
20
18
 
21
19
  File.stub!(:open).with('upload_test').and_yield(file)
22
20
 
23
- @http_mock.should_receive(:post).with(
21
+ RestClient.should_receive(:post).with(
24
22
  "#{Sproutvideo.base_url}/videos",
25
23
  {:source_video => file, :title => 'test title'},
26
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
24
+ {'SproutVideo-Api-Key' => @api_key, :timeout => 18000}).and_return(@msg)
27
25
 
28
26
 
29
27
  Sproutvideo::Video.create('upload_test', {:title => 'test title'}).class.should == Sproutvideo::Response
@@ -39,34 +37,30 @@ describe Sproutvideo::Video do
39
37
 
40
38
  it "should GET the correct url and return a response" do
41
39
 
42
- @http_mock.should_receive(:get).with(
40
+ RestClient.should_receive(:get).with(
43
41
  @url,
44
- {:page => 1, :per_page => 25},
45
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
42
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25}}).and_return(@msg)
46
43
  Sproutvideo::Video.list.class.should == Sproutvideo::Response
47
44
  end
48
45
 
49
46
  it "should merge params" do
50
- @http_mock.should_receive(:get).with(
47
+ RestClient.should_receive(:get).with(
51
48
  @url,
52
- {:page => 1, :per_page => 25, :foo => 'bar'},
53
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
49
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25, :foo => 'bar'}}).and_return(@msg)
54
50
  Sproutvideo::Video.list(:foo => 'bar')
55
51
  end
56
52
 
57
53
  it "should use pagination params" do
58
- @http_mock.should_receive(:get).with(
54
+ RestClient.should_receive(:get).with(
59
55
  @url,
60
- {:page => 2, :per_page => 5},
61
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
56
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 2, :per_page => 5}}).and_return(@msg)
62
57
  Sproutvideo::Video.list(:page => 2, :per_page => 5)
63
58
  end
64
59
 
65
60
  it "should request videos for a tag if tag_id is passed in" do
66
- @http_mock.should_receive(:get).with(
61
+ RestClient.should_receive(:get).with(
67
62
  @url,
68
- {:page => 1, :per_page => 25, :tag_id => 'asdf'},
69
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
63
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25, :tag_id => 'asdf'}}).and_return(@msg)
70
64
  Sproutvideo::Video.list(:tag_id => 'asdf')
71
65
  end
72
66
  end
@@ -78,10 +72,9 @@ describe Sproutvideo::Video do
78
72
  end
79
73
 
80
74
  it "should get the correct url and return a response" do
81
- @http_mock.should_receive(:get).with(
75
+ RestClient.should_receive(:get).with(
82
76
  @url,
83
- {},
84
- {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
77
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
85
78
  Sproutvideo::Video.details(@video_id).class.should == Sproutvideo::Response
86
79
  end
87
80
  end
@@ -95,7 +88,7 @@ describe Sproutvideo::Video do
95
88
  it "should PUT the correct url and return a response" do
96
89
  data = {:title => 'new title'}
97
90
 
98
- @http_mock.should_receive(:put).with(
91
+ RestClient.should_receive(:put).with(
99
92
  @url,
100
93
  MultiJson.encode(data),
101
94
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
@@ -111,9 +104,8 @@ describe Sproutvideo::Video do
111
104
  end
112
105
 
113
106
  it "should DELETE the correct url and return a response" do
114
- @http_mock.should_receive(:delete).with(
107
+ RestClient.should_receive(:delete).with(
115
108
  @url,
116
- {},
117
109
  {'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
118
110
  Sproutvideo::Video.destroy(@video_id).class.should == Sproutvideo::Response
119
111
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sproutvideo-rb}
8
- s.version = "1.1.0"
8
+ s.version = "1.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["SproutVideo"]
12
- s.date = %q{2012-08-04}
12
+ s.date = %q{2012-12-12}
13
13
  s.description = %q{SproutVideo API Client}
14
14
  s.email = %q{support@sproutvideo.com}
15
15
  s.extra_rdoc_files = [
@@ -55,7 +55,7 @@ Gem::Specification.new do |s|
55
55
  s.specification_version = 3
56
56
 
57
57
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
- s.add_runtime_dependency(%q<httpclient>, [">= 0"])
58
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
59
59
  s.add_runtime_dependency(%q<multi_json>, [">= 0"])
60
60
  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
61
61
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
@@ -63,7 +63,7 @@ Gem::Specification.new do |s|
63
63
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
64
64
  s.add_development_dependency(%q<rcov>, [">= 0"])
65
65
  else
66
- s.add_dependency(%q<httpclient>, [">= 0"])
66
+ s.add_dependency(%q<rest-client>, [">= 0"])
67
67
  s.add_dependency(%q<multi_json>, [">= 0"])
68
68
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
69
69
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
@@ -72,7 +72,7 @@ Gem::Specification.new do |s|
72
72
  s.add_dependency(%q<rcov>, [">= 0"])
73
73
  end
74
74
  else
75
- s.add_dependency(%q<httpclient>, [">= 0"])
75
+ s.add_dependency(%q<rest-client>, [">= 0"])
76
76
  s.add_dependency(%q<multi_json>, [">= 0"])
77
77
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
78
78
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 0
9
- version: 1.1.0
8
+ - 1
9
+ version: 1.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - SproutVideo
@@ -14,11 +14,11 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-08-04 00:00:00 -04:00
17
+ date: 2012-12-12 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: httpclient
21
+ name: rest-client
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  requirements: