panda 1.3.0 → 1.4.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/.gitignore +21 -0
- data/{spec/spec.opts → .rspec} +0 -0
- data/CHANGELOG.md +52 -0
- data/Gemfile +2 -14
- data/README.md +38 -32
- data/Rakefile +9 -27
- data/lib/panda.rb +9 -3
- data/lib/panda/adapters/adapter.rb +4 -0
- data/lib/panda/adapters/faraday.rb +70 -0
- data/lib/panda/adapters/restclient.rb +67 -0
- data/lib/panda/api_authentication.rb +2 -0
- data/lib/panda/base.rb +23 -21
- data/lib/panda/config.rb +58 -0
- data/lib/panda/connection.rb +33 -122
- data/lib/panda/errors.rb +17 -0
- data/lib/panda/modules/builders.rb +18 -10
- data/lib/panda/modules/destroyers.rb +25 -0
- data/lib/panda/modules/finders.rb +10 -4
- data/lib/panda/modules/router.rb +16 -10
- data/lib/panda/modules/updatable.rb +3 -2
- data/lib/panda/modules/video_state.rb +16 -0
- data/lib/panda/modules/viewable.rb +19 -0
- data/lib/panda/panda.rb +41 -20
- data/lib/panda/proxies/proxy.rb +3 -1
- data/lib/panda/proxies/scope.rb +34 -28
- data/lib/panda/resources/cloud.rb +13 -11
- data/lib/panda/resources/encoding.rb +4 -19
- data/lib/panda/resources/resource.rb +2 -12
- data/lib/panda/resources/video.rb +4 -1
- data/lib/panda/version.rb +3 -0
- data/panda.gemspec +22 -105
- data/spec/cloud_spec.rb +44 -35
- data/spec/encoding_spec.rb +28 -9
- data/spec/heroku_spec.rb +15 -5
- data/spec/panda_spec.rb +41 -68
- data/spec/profile_spec.rb +6 -6
- data/spec/spec_helper.rb +3 -4
- data/spec/video_spec.rb +68 -19
- metadata +44 -98
- data/VERSION +0 -1
- data/lib/panda/error.rb +0 -29
- data/lib/panda/modules/short_status.rb +0 -13
data/spec/cloud_spec.rb
CHANGED
@@ -4,12 +4,12 @@ describe Panda::Cloud do
|
|
4
4
|
|
5
5
|
describe "region" do
|
6
6
|
it "should tell the region" do
|
7
|
-
Panda.configure do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
Panda.configure do
|
8
|
+
access_key "my_access_key"
|
9
|
+
secret_key "my_secret_key"
|
10
|
+
api_host "api.pandastream.com"
|
11
|
+
cloud_id 'my_cloud_id'
|
12
|
+
api_port 85
|
13
13
|
end
|
14
14
|
|
15
15
|
Panda.cloud.region.should == "us"
|
@@ -17,12 +17,12 @@ describe Panda::Cloud do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should tell the region" do
|
20
|
-
Panda.configure do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
Panda.configure do
|
21
|
+
access_key "my_access_key"
|
22
|
+
secret_key "my_secret_key"
|
23
|
+
api_host "api.eu.pandastream.com"
|
24
|
+
cloud_id 'my_cloud_id'
|
25
|
+
api_port 85
|
26
26
|
end
|
27
27
|
|
28
28
|
Panda.cloud.region.should == "eu"
|
@@ -31,14 +31,17 @@ describe Panda::Cloud do
|
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
|
+
|
35
|
+
|
36
|
+
|
34
37
|
describe "Using configure bloc" do
|
35
38
|
before(:each) do
|
36
|
-
Panda.configure do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
Panda.configure do
|
40
|
+
access_key "my_access_key"
|
41
|
+
secret_key "my_secret_key"
|
42
|
+
api_host "api.example.com"
|
43
|
+
cloud_id 'my_cloud_id'
|
44
|
+
api_port 85
|
42
45
|
end
|
43
46
|
end
|
44
47
|
|
@@ -85,26 +88,32 @@ describe Panda::Cloud do
|
|
85
88
|
to_return(:body => videos_json)
|
86
89
|
@cloud.videos.create(:source_url => "my_source_url")
|
87
90
|
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "Using options on find" do
|
91
91
|
|
92
|
-
it "should find
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
"api_port" => 85,
|
102
|
-
"format" => "json"
|
103
|
-
}
|
104
|
-
|
105
|
-
@cloud.s3_videos_bucket.should == "my_bucket"
|
92
|
+
it "should find return all cloud" do
|
93
|
+
clouds_json = "[{\"s3_videos_bucket\":\"my_bucket1\",\"id\":\"cloud1\"},{\"s3_videos_bucket\":\"my_bucket2\",\"id\":\"cloud2\"}]"
|
94
|
+
|
95
|
+
stub_http_request(:get, /api.example.com:85\/v2\/clouds.json/).to_return(:body => clouds_json)
|
96
|
+
|
97
|
+
cloud = Panda::Cloud.all
|
98
|
+
cloud.first.id.should == 'cloud1'
|
99
|
+
cloud.first.s3_videos_bucket.should == "my_bucket1"
|
100
|
+
cloud.size.should == 2
|
106
101
|
end
|
107
102
|
end
|
108
103
|
|
104
|
+
|
105
|
+
it "should create a cloud" do
|
106
|
+
cloud_json = "{\"s3_videos_bucket\":\"videobucket\",\"id\":\"my_cloud_id\"}"
|
107
|
+
stub_http_request(:post, /http:\/\/api.example.com:85\/v2\/clouds.json/).
|
108
|
+
with{|r| r.body =~ /s3_videos_bucket=videobucket/ && r.body =~ /user_aws_key=myaccesskey/ && r.body =~ /user_aws_secret=mysecretkey/ }.
|
109
|
+
to_return(:body => cloud_json)
|
110
|
+
|
111
|
+
@cloud = Panda::Cloud.create(:s3_videos_bucket => 'videobucket', :user_aws_key => 'myaccesskey', :user_aws_secret => 'mysecretkey')
|
112
|
+
@cloud.s3_videos_bucket.should == "videobucket"
|
113
|
+
end
|
114
|
+
|
109
115
|
end
|
116
|
+
|
117
|
+
|
118
|
+
|
110
119
|
end
|
data/spec/encoding_spec.rb
CHANGED
@@ -3,12 +3,12 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe Panda::Encoding do
|
4
4
|
before(:each) do
|
5
5
|
|
6
|
-
Panda.configure do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
Panda.configure do
|
7
|
+
access_key "my_access_key"
|
8
|
+
secret_key "my_secret_key"
|
9
|
+
api_host "api.example.com"
|
10
|
+
cloud_id 'my_cloud_id'
|
11
|
+
api_port 85
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
@@ -62,12 +62,12 @@ describe Panda::Encoding do
|
|
62
62
|
encodings.first.id.should == "456"
|
63
63
|
end
|
64
64
|
|
65
|
-
it "should return the
|
65
|
+
it "should return the encoding url" do
|
66
66
|
cloud_json = "{\"s3_videos_bucket\":\"my_bucket\",\"id\":\"my_cloud_id\", \"url\":\"http://my_bucket.s3.amazonaws.com/\"}"
|
67
67
|
stub_http_request(:get, /api.example.com:85\/v2\/clouds\/my_cloud_id.json/).
|
68
68
|
to_return(:body => cloud_json)
|
69
69
|
|
70
|
-
encoding = Panda::Encoding.new({:id => "456", :extname => ".ext", :path => "abc/panda"})
|
70
|
+
encoding = Panda::Encoding.new({:id => "456", :extname => ".ext", :path => "abc/panda", :status => 'success'})
|
71
71
|
encoding.url.should == "http://my_bucket.s3.amazonaws.com/abc/panda.ext"
|
72
72
|
end
|
73
73
|
|
@@ -104,6 +104,25 @@ describe Panda::Encoding do
|
|
104
104
|
encoding.profile_id.should == "901"
|
105
105
|
end
|
106
106
|
|
107
|
+
it "should create an encoding through the association" do
|
108
|
+
video_json = "{\"source_url\":\"my_source_url\",\"id\":\"123\"}"
|
109
|
+
encoding_json = "{\"abc\":\"efg\",\"id\":\"456\", \"video_id\":\"123\", \"profile_id\":\"901\"}"
|
110
|
+
|
111
|
+
stub_http_request(:get, /api.example.com:85\/v2\/videos\/123.json/).
|
112
|
+
to_return(:body => video_json)
|
113
|
+
|
114
|
+
stub_http_request(:post, /api.example.com:85\/v2\/encodings.json/).
|
115
|
+
with{|r| r.body =~ /video_id=123/ && r.body =~ /profile_id=901/}.
|
116
|
+
to_return(:body => encoding_json)
|
117
|
+
|
118
|
+
video = Panda::Video.find("123")
|
119
|
+
|
120
|
+
encoding = video.encodings.create!(:profile_id => "901")
|
121
|
+
encoding.id.should == "456"
|
122
|
+
encoding.profile_id.should == "901"
|
123
|
+
end
|
124
|
+
|
125
|
+
|
107
126
|
it "should filter the profile name after triggering the request" do
|
108
127
|
video_json = "{\"source_url\":\"my_source_url\",\"id\":\"123\"}"
|
109
128
|
encodings_1_json = "[{\"id\":\"456\", \"video_id\":\"123\", \"profile_name\":\"h264\"}]"
|
@@ -195,7 +214,7 @@ describe Panda::Encoding do
|
|
195
214
|
stub_http_request(:get, /api.example.com:85\/v2\/encodings\/456.json/).
|
196
215
|
to_return(:body => encoding_json)
|
197
216
|
|
198
|
-
Panda::Encoding.
|
217
|
+
Panda::Encoding.find("456")
|
199
218
|
end
|
200
219
|
|
201
220
|
it "should tell if the encoding is success" do
|
data/spec/heroku_spec.rb
CHANGED
@@ -3,20 +3,30 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe Panda::Video do
|
4
4
|
before(:each) do
|
5
5
|
cloud_json = "{\"s3_videos_bucket\":\"my_bucket\",\"id\":\"my_cloud_id\"}"
|
6
|
-
stub_http_request(:get, /api.example.com:
|
6
|
+
stub_http_request(:get, /api.example.com:443\/v2\/clouds\/my_cloud_id.json/).
|
7
7
|
to_return(:body => cloud_json)
|
8
8
|
|
9
9
|
my_heroku_url = "http://access_key:secret_key@api.example.com:85/my_cloud_id"
|
10
|
-
|
11
|
-
c.heroku = my_heroku_url
|
12
|
-
end
|
10
|
+
ENV['PANDASTREAM_URL']= my_heroku_url
|
13
11
|
end
|
14
12
|
|
15
13
|
it "should get all videos" do
|
14
|
+
Panda.configure_heroku
|
15
|
+
|
16
16
|
videos_json = "[]"
|
17
|
-
stub_http_request(:get, /api.example.com:
|
17
|
+
stub_http_request(:get, /api.example.com:443\/v2\/videos.json/).to_return(:body => videos_json)
|
18
18
|
|
19
19
|
Panda::Video.all.should be_empty
|
20
20
|
end
|
21
21
|
|
22
|
+
it "should get all videos" do
|
23
|
+
Panda.configure ENV['PANDASTREAM_URL']
|
24
|
+
|
25
|
+
videos_json = "[]"
|
26
|
+
stub_http_request(:get, /api.example.com:443\/v2\/videos.json/).to_return(:body => videos_json)
|
27
|
+
|
28
|
+
Panda::Video.all.should be_empty
|
29
|
+
end
|
30
|
+
|
31
|
+
|
22
32
|
end
|
data/spec/panda_spec.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'timecop'
|
2
3
|
|
3
4
|
describe Panda do
|
4
5
|
before(:each) do
|
6
|
+
new_time = Time.local(20010, 1, 12, 1, 0, 0)
|
7
|
+
Timecop.freeze(new_time)
|
5
8
|
end
|
6
9
|
|
7
10
|
describe "when not connected" do
|
@@ -10,17 +13,17 @@ describe Panda do
|
|
10
13
|
it "should raise error for #{method}" do
|
11
14
|
lambda {
|
12
15
|
Panda.send(method, nil, nil)
|
13
|
-
}.should raise_error("
|
16
|
+
}.should raise_error("Panda is not configured!")
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
20
|
end
|
18
21
|
|
19
|
-
|
22
|
+
shared_examples_for "Connected" do
|
20
23
|
|
21
24
|
it "should make get request with signed request to panda server" do
|
22
|
-
stub_http_request(:get, "myapihost:85/v2/videos?
|
23
|
-
@panda.get("/videos").should ==
|
25
|
+
stub_http_request(:get, "http://myapihost:85/v2/videos?access_key=my_access_key&cloud_id=my_cloud_id&signature=DYpg2K6d7kGo%2FuWPO%2FaQgtQmY3BPtFEtQgdQhVe8teM%3D×tamp=20010-01-12T01%3A00%3A00.000000Z").to_return(:body => "{\"abc\":\"d\"}")
|
26
|
+
@panda.get("/videos").should == {'abc' => 'd'}
|
24
27
|
end
|
25
28
|
|
26
29
|
it "should create a signed version of the parameters" do
|
@@ -30,9 +33,9 @@ describe Panda do
|
|
30
33
|
)
|
31
34
|
signed_params.should == {
|
32
35
|
'access_key' => "my_access_key",
|
33
|
-
'timestamp' => "
|
36
|
+
'timestamp' => "20010-01-12T01:00:00.000000Z",
|
34
37
|
'cloud_id' => 'my_cloud_id',
|
35
|
-
'signature' => '
|
38
|
+
'signature' => 'aTgBGPeMrRk2Pnc13RxhK/ctWjDsL33vOFEC9qKLWV0=',
|
36
39
|
'param1' => 'one',
|
37
40
|
'param2' => 'two'
|
38
41
|
}
|
@@ -41,9 +44,9 @@ describe Panda do
|
|
41
44
|
it "should create a signed version of the parameters without additional arguments" do
|
42
45
|
@panda.signed_params('POST', '/videos.json').should == {
|
43
46
|
'access_key' => "my_access_key",
|
44
|
-
'timestamp' => "
|
47
|
+
'timestamp' => "20010-01-12T01:00:00.000000Z",
|
45
48
|
'cloud_id' => 'my_cloud_id',
|
46
|
-
'signature' => '
|
49
|
+
'signature' => 'g5lAh0cPC/qyUyTQb125vosvZwubQ+HgB04ORt+iw7o='
|
47
50
|
}
|
48
51
|
end
|
49
52
|
|
@@ -55,9 +58,9 @@ describe Panda do
|
|
55
58
|
)
|
56
59
|
signed_params.should == {
|
57
60
|
'access_key' => "my_access_key",
|
58
|
-
'timestamp' => "
|
61
|
+
'timestamp' => "20010-01-12T01:00:00.000000Z",
|
59
62
|
'cloud_id' => 'my_cloud_id',
|
60
|
-
'signature' => '
|
63
|
+
'signature' => 'G6LUFGIseRyDrqnj55t+CDrAGdRWtUWSqZwMmIsuW40=',
|
61
64
|
'tilde' => '~',
|
62
65
|
'space' => ' '
|
63
66
|
}
|
@@ -67,9 +70,9 @@ describe Panda do
|
|
67
70
|
it "should not include file inside the signature" do
|
68
71
|
@panda.signed_params('POST', '/videos.json', { "file" => "my_file" }).should == {
|
69
72
|
'access_key' => "my_access_key",
|
70
|
-
'timestamp' => "
|
73
|
+
'timestamp' => "20010-01-12T01:00:00.000000Z",
|
71
74
|
'cloud_id' => 'my_cloud_id',
|
72
|
-
'signature' => '
|
75
|
+
'signature' => 'g5lAh0cPC/qyUyTQb125vosvZwubQ+HgB04ORt+iw7o=',
|
73
76
|
'file' => "my_file"
|
74
77
|
}
|
75
78
|
end
|
@@ -77,63 +80,32 @@ describe Panda do
|
|
77
80
|
it "should stringify keys" do
|
78
81
|
@panda.signed_params('POST', '/videos.json', { :file => "symbol_key" }).should == {
|
79
82
|
'access_key' => "my_access_key",
|
80
|
-
'timestamp' => "
|
83
|
+
'timestamp' => "20010-01-12T01:00:00.000000Z",
|
81
84
|
'cloud_id' => 'my_cloud_id',
|
82
|
-
'signature' => '
|
85
|
+
'signature' => 'g5lAh0cPC/qyUyTQb125vosvZwubQ+HgB04ORt+iw7o=',
|
83
86
|
'file' => "symbol_key"
|
84
87
|
}
|
85
88
|
end
|
86
|
-
|
87
|
-
it "should return a json file for every http code" do
|
88
|
-
stub_http_request(:get, "http://myapihost:85/v2/videos?timestamp=2009-11-04T17%3A54%3A11%2B00%3A00&signature=CxSYPM65SeeWH4CE%2FLcq7Ny2NtwxlpS8QOXG2BKe4p8%3D&access_key=my_access_key&cloud_id=my_cloud_id").to_return(:body => "abc")
|
89
|
-
|
90
|
-
resource = RestClient::Resource.new("http://myapihost:85/v2")
|
91
|
-
RestClient::Resource.stub!(:new).and_return(resource)
|
92
|
-
|
93
|
-
e = RestClient::Exception.new({:body => "abc", :code => 400})
|
94
|
-
e.stub!(:http_body).and_return("abc")
|
95
|
-
|
96
|
-
resource.stub!(:get).and_raise(e)
|
97
|
-
|
98
|
-
panda = Panda::Connection.new({"access_key" => "my_access_key", "secret_key" => "my_secret_key", "api_host" => "myapihost", "api_port" => 85, "cloud_id" => 'my_cloud_id', "format" => "json" })
|
99
|
-
panda.get("/videos").should == "abc"
|
100
|
-
end
|
101
89
|
end
|
102
|
-
|
103
|
-
describe "Connected with a string url" do
|
104
|
-
before(:each) do
|
105
|
-
@panda = Panda::Connection.new('http://my_access_key:my_secret_key@myapihost:85/my_cloud_id', "format" => "json")
|
106
|
-
end
|
107
90
|
|
108
|
-
it_should_behave_like "Connected"
|
109
|
-
end
|
110
|
-
|
111
91
|
describe "Panda.connect " do
|
112
92
|
before(:each) do
|
113
|
-
@panda = Panda.connect!({"access_key" => "my_access_key", "secret_key" => "my_secret_key", "api_host" => "myapihost", "api_port" => 85, "cloud_id" => 'my_cloud_id'
|
93
|
+
@panda = Panda.connect!({"access_key" => "my_access_key", "secret_key" => "my_secret_key", "api_host" => "myapihost", "api_port" => 85, "cloud_id" => 'my_cloud_id'})
|
114
94
|
end
|
115
95
|
it_should_behave_like "Connected"
|
116
96
|
end
|
117
97
|
|
118
98
|
describe "Panda.connect with symbols" do
|
119
99
|
before(:each) do
|
120
|
-
@panda = Panda.connect!({:access_key => "my_access_key", :secret_key => "my_secret_key", :api_host => "myapihost", :api_port => 85, :cloud_id => 'my_cloud_id'
|
100
|
+
@panda = Panda.connect!({:access_key => "my_access_key", :secret_key => "my_secret_key", :api_host => "myapihost", :api_port => 85, :cloud_id => 'my_cloud_id'})
|
121
101
|
end
|
122
102
|
|
123
103
|
it_should_behave_like "Connected"
|
124
104
|
end
|
125
|
-
|
126
|
-
|
127
|
-
describe "Panda.connect with PANDASTREAM_URL" do
|
128
|
-
before(:each) do
|
129
|
-
@panda = Panda.connect!('http://my_access_key:my_secret_key@myapihost:85/my_cloud_id', "format" => "json")
|
130
|
-
end
|
131
|
-
it_should_behave_like "Connected"
|
132
|
-
end
|
133
105
|
|
134
106
|
describe "Panda::Connection.new" do
|
135
107
|
before(:each) do
|
136
|
-
@panda = Panda::Connection.new({"access_key" => "my_access_key", "secret_key" => "my_secret_key", "api_host" => "myapihost", "api_port" => 85, "cloud_id" => 'my_cloud_id'
|
108
|
+
@panda = Panda::Connection.new({"access_key" => "my_access_key", "secret_key" => "my_secret_key", "api_host" => "myapihost", "api_port" => 85, "cloud_id" => 'my_cloud_id'})
|
137
109
|
end
|
138
110
|
it_should_behave_like "Connected"
|
139
111
|
end
|
@@ -145,34 +117,35 @@ describe Panda do
|
|
145
117
|
end
|
146
118
|
|
147
119
|
it "should make get request" do
|
148
|
-
stub_http_request(:get, "myapihost:85/v2/videos?
|
120
|
+
stub_http_request(:get, "http://myapihost:85/v2/videos?access_key=my_access_key&cloud_id=my_cloud_id&signature=DYpg2K6d7kGo%2FuWPO%2FaQgtQmY3BPtFEtQgdQhVe8teM%3D×tamp=20010-01-12T01%3A00%3A00.000000Z").to_return(:body => "{\"key\":\"value\"}")
|
149
121
|
@panda.get("/videos").should == {'key' => 'value'}
|
150
122
|
end
|
151
123
|
|
152
124
|
end
|
153
|
-
|
154
|
-
describe "ActiveSupport::JSON parsing" do
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
125
|
+
|
126
|
+
# describe "ActiveSupport::JSON parsing" do
|
127
|
+
#
|
128
|
+
# it "should use active support if it has been defined and if restclient is used " do
|
129
|
+
# @panda = Panda::Connection.new({"access_key" => "my_access_key", "secret_key" => "my_secret_key", "api_host" => "myapihost", "api_port" => 85, "cloud_id" => 'my_cloud_id' })
|
130
|
+
# Panda.adapter = 'restclient'
|
131
|
+
#
|
132
|
+
# stub_http_request(:get, "http://myapihost:85/v2/videos?access_key=my_access_key&cloud_id=my_cloud_id&signature=DYpg2K6d7kGo%2FuWPO%2FaQgtQmY3BPtFEtQgdQhVe8teM%3D×tamp=20010-01-12T01%3A00%3A00.000000Z").to_return(:body => "abc")
|
133
|
+
#
|
134
|
+
#
|
135
|
+
# module ActiveSupport
|
136
|
+
# class JSON; end
|
137
|
+
# end
|
138
|
+
#
|
139
|
+
# ActiveSupport::JSON.should_receive(:decode).with("abc").and_return("blah")
|
140
|
+
# @panda.get("/videos").should == "blah"
|
141
|
+
#
|
142
|
+
# Object.send :remove_const, :ActiveSupport
|
143
|
+
# end
|
144
|
+
# end
|
171
145
|
|
172
146
|
describe "parsing" do
|
173
147
|
it "should raise an error if the response is not JSON parsable" do
|
174
148
|
@connection = Panda::Connection.new({"access_key" => "my_access_key", "secret_key" => "my_secret_key", "api_host" => "myapihost", "api_port" => 85, "cloud_id" => 'my_cloud_id' })
|
175
|
-
@connection.raise_error=true
|
176
149
|
|
177
150
|
stub_http_request(:get, //).to_return(:body => "blahblah")
|
178
151
|
|
data/spec/profile_spec.rb
CHANGED
@@ -6,12 +6,12 @@ describe Panda::Profile do
|
|
6
6
|
stub_http_request(:get, /api.example.com:85\/v2\/clouds\/my_cloud_id.json/).
|
7
7
|
to_return(:body => cloud_json)
|
8
8
|
|
9
|
-
Panda.configure do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
Panda.configure do
|
10
|
+
access_key "my_access_key"
|
11
|
+
secret_key "my_secret_key"
|
12
|
+
api_host "api.example.com"
|
13
|
+
cloud_id 'my_cloud_id'
|
14
|
+
api_port 85
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
require 'panda'
|
4
|
-
require '
|
5
|
-
require 'spec/autorun'
|
4
|
+
require 'rspec'
|
6
5
|
|
7
6
|
require 'webmock/rspec'
|
8
7
|
include WebMock::API
|
@@ -11,10 +10,10 @@ def hputs(*args)
|
|
11
10
|
puts ERB::Util.html_escape(args.join("\n")).gsub(/\r?\n/, '<br/>') + '<br/>'
|
12
11
|
end
|
13
12
|
|
14
|
-
|
13
|
+
RSpec.configure do |config|
|
15
14
|
config.before(:each) do
|
16
15
|
Panda.instance_variable_set("@connection", nil)
|
17
16
|
Panda.instance_variable_set("@cloud", nil)
|
18
|
-
Time.stub!(:
|
17
|
+
Time.now.stub!(:utc).and_return(mock("time", :iso8601 => "2009-11-04T17:54:11+00:00"))
|
19
18
|
end
|
20
19
|
end
|