rmb 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,159 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Drop do
4
+
5
+ before(:each) do
6
+ @client = Rmb::Client.new
7
+ @api = stub(Rmb::Api)
8
+ @client.service = @api
9
+
10
+ Rmb::Resource.stub!(:client).and_return(@client)
11
+ Rmb::Resource.client.should == @client
12
+ Rmb::Resource.client.service.should == @api
13
+
14
+ @mydrop = Rmb::Drop.new(:name => "test_drop")
15
+ end
16
+
17
+ it "should have the attributes of a Drop" do
18
+ Drop.new.should respond_to(:name, :email, :description, :expires_at,
19
+ :expiration_length, :max_bytes, :current_bytes, :asset_count, :chat_password,
20
+ :password, :admin_password, :admin_email, :email_key)
21
+ end
22
+
23
+ it "should find drops by api account" do
24
+ @client.should_receive(:handle).with(:drops,[@mydrop]).and_return([@mydrop])
25
+ @api.should_receive(:all_drops).with(1).and_return([@mydrop])
26
+ Drop.find_all.should == [@mydrop]
27
+ end
28
+
29
+ it "should find drops by name" do
30
+ @client.should_receive(:handle).with(:drop,{}).and_return(@mydrop)
31
+ @api.should_receive(:drop).and_return({})
32
+ Drop.find("mydrop").should == @mydrop
33
+ end
34
+
35
+ it "should find drops by name" do
36
+ @client.should_receive(:handle).with(:drop,{}).and_return(@mydrop)
37
+ @api.should_receive(:drop).with("mydrop").and_return({})
38
+ Drop.find("mydrop").should == @mydrop
39
+ end
40
+
41
+ it "should find a set of related assets" do
42
+ @asset = stub(Asset)
43
+ @asset.should_receive(:drop=).once
44
+ @client.should_receive(:handle).with(:assets,{}).and_return([@asset])
45
+ @api.stub!(:assets).with(@mydrop.name,1,:oldest).and_return({})
46
+ @mydrop.assets.should == [@asset]
47
+ end
48
+
49
+ it "should be able to create a new Drop" do
50
+ @client.should_receive(:handle).with(:drop,{}).and_return(@mydrop)
51
+ @api.should_receive(:create_drop).with({:name => "tester"}).and_return({})
52
+ Drop.create({:name => "tester"}).should == @mydrop
53
+ end
54
+
55
+ it "should be able to empty itself" do
56
+ @client.should_receive(:handle).with(:response,{}).and_return({})
57
+ @api.should_receive(:empty_drop).with(@mydrop.name).and_return({})
58
+ @mydrop.empty
59
+ end
60
+
61
+ it "should be able to promote a nick" do
62
+ @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
63
+ @api.should_receive(:promote_nick).with(@mydrop.name,"jake").and_return({})
64
+ @mydrop.promote("jake")
65
+ end
66
+
67
+ it "should save itself" do
68
+ @client.should_receive(:handle).with(:drop,{}).and_return(@mydrop)
69
+ expected_hash = {:password=>"test_password", :expiration_length=>nil, :admin_password=>nil,
70
+ :chat_password=>nil, :admin_email=>nil, :email_key=>nil, :description=>nil}
71
+ @api.should_receive(:update_drop).with(@mydrop.name,expected_hash).and_return({})
72
+ @mydrop.password = "test_password"
73
+ @mydrop.save
74
+ end
75
+
76
+ it "should destroy itself" do
77
+ @client.should_receive(:handle).with(:response,{}).and_return({"result" => "Success"})
78
+ @api.should_receive(:delete_drop).with(@mydrop.name).and_return({})
79
+ @mydrop.destroy!
80
+ end
81
+
82
+ it "should add files from a url" do
83
+ @asset = stub(Asset)
84
+ @asset.should_receive(:drop=).once
85
+ @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
86
+ @api.should_receive(:add_file_from_url).with(@mydrop.name,"http://myurl.com/myfile.txt", "description", nil, nil).and_return({})
87
+ @mydrop.add_file_from_url("http://myurl.com/myfile.txt","description").should == @asset
88
+ end
89
+
90
+ it "should add files from a url with conversion and pingback url" do
91
+ @asset = stub(Asset)
92
+ @asset.should_receive(:drop=).once
93
+ @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
94
+ @api.should_receive(:add_file_from_url).with(@mydrop.name,"http://myurl.com/myfile.txt", "description", 'H264_HIGH_RES', 'http://rmb.io/test/pinged').and_return({})
95
+ @mydrop.add_file_from_url("http://myurl.com/myfile.txt", "description", 'H264_HIGH_RES', 'http://rmb.io/test/pinged').should == @asset
96
+ end
97
+
98
+ it "should add files from a path" do
99
+ @asset = stub(Asset)
100
+ @asset.should_receive(:drop=).once
101
+ @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
102
+ @api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt", "description", nil, nil, nil).and_return({})
103
+ @mydrop.add_file("/mypath/myfile.txt", "description").should == @asset
104
+ end
105
+
106
+ it "should add files from a path with pingback url and conversion target" do
107
+ @asset = stub(Asset)
108
+ @asset.should_receive(:drop=).once
109
+ @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
110
+ @api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt","description", 'H264_HIGH_RES', 'http://rmb.io/test/pinged', nil).and_return({})
111
+ @mydrop.add_file("/mypath/myfile.txt","description",'H264_HIGH_RES', 'http://rmb.io/test/pinged').should == @asset
112
+ end
113
+
114
+ it "should add files from a path with pingback url, conversion target, and output location" do
115
+ @asset = stub(Asset)
116
+ @asset.should_receive(:drop=).once
117
+ @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
118
+ @api.should_receive(:add_file).with(@mydrop.name,"/mypath/myfile.txt","description", 'H264_HIGH_RES', 'http://rmb.io/test/pinged','RmbS3').and_return({})
119
+ @mydrop.add_file("/mypath/myfile.txt","description",'H264_HIGH_RES', 'http://rmb.io/test/pinged', 'RmbS3').should == @asset
120
+ end
121
+
122
+ it "should create notes from title and contents and description" do
123
+ @asset = stub(Asset)
124
+ @asset.should_receive(:drop=).once
125
+ @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
126
+ @api.should_receive(:create_note).with(@mydrop.name,"contents", "title","description").and_return({})
127
+ @mydrop.create_note("contents","title", "description").should == @asset
128
+ end
129
+
130
+ it "should create links from a url, title, and description" do
131
+ @asset = stub(Asset)
132
+ @asset.should_receive(:drop=).once
133
+ @client.should_receive(:handle).with(:asset,{}).and_return(@asset)
134
+ @api.should_receive(:create_link).with(@mydrop.name,"http://rmb.io","rmb.io","The best!").and_return({})
135
+ @mydrop.create_link("http://rmb.io","rmb.io","The best!").should == @asset
136
+ end
137
+
138
+ it "should be able to create pingback subscriptions" do
139
+ @sub = stub(Subscription)
140
+ @sub.should_receive(:drop=).once
141
+ @client.should_receive(:handle).with(:subscription,{}).and_return(@sub)
142
+ @api.should_receive(:create_pingback_subscription).with(@mydrop.name,"http://rmb.io",{}).and_return({})
143
+ @mydrop.create_pingback_subscription("http://rmb.io")
144
+ end
145
+
146
+ it "should be able to get a list of subscriptions back" do
147
+ @sub = stub(Subscription)
148
+ @sub.should_receive(:drop=).once
149
+ @client.should_receive(:handle).with(:subscriptions,{}).and_return([@sub])
150
+ @api.stub!(:subscriptions).with(@mydrop.name, 1).and_return({})
151
+ @mydrop.subscriptions.should == [@sub]
152
+ end
153
+
154
+ it "should generate a signed url" do
155
+ @api.should_receive(:generate_drop_url).with(@mydrop.name)
156
+ @mydrop.generate_url
157
+ end
158
+
159
+ end
File without changes
data/spec/rmb_spec.rb ADDED
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe Rmb do
4
+ it "should store the API key" do
5
+ Rmb::Config.api_key = "83a05513ddddb73e75c9d8146c115f7fd8e90de6"
6
+ Rmb::Config.api_key.should == "83a05513ddddb73e75c9d8146c115f7fd8e90de6"
7
+ end
8
+
9
+ it "should define exceptions which inherit from StandardError" do
10
+ exception_names = [
11
+ :MissingResourceError,
12
+ :AuthorizationError,
13
+ :RequestError,
14
+ :ServerError
15
+ ]
16
+
17
+ exceptions = exception_names.map do |n|
18
+ Rmb.const_get n
19
+ end
20
+
21
+ exceptions.each do |e|
22
+ assert_nothing_raised do
23
+ begin
24
+ raise e
25
+ rescue StandardError
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --diff
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup :default, :test
4
+
5
+ require 'spec'
6
+ require 'spec/test/unit'
7
+ require 'fakeweb'
8
+
9
+ FakeWeb.allow_net_connect = false
10
+
11
+ $: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
12
+
13
+ require 'rmb'
14
+ include Rmb
15
+
16
+ module Enumerable
17
+ # Apply an expectation to each object in the collection.
18
+ def each_should(*args)
19
+ each {|item| item.should(*args)}
20
+ end
21
+
22
+ # Apply a negative expectation to each object in the collection.
23
+ def each_should_not(*args)
24
+ each {|item| item.should_not(*args)}
25
+ end
26
+ end
27
+
28
+ # Make class mocks and stubs pretend to belong to their given class.
29
+ module Spec::Mocks
30
+ class Mock
31
+ def kind_of?(klass)
32
+ if @name.kind_of?(Class) and @name <= klass
33
+ true
34
+ else
35
+ super
36
+ end
37
+ end
38
+ alias is_a? kind_of?
39
+ end
40
+ end
41
+
42
+ # Reimplement Module#=== in Ruby. Without this, === bypasses message
43
+ # dispatch, so the trick above doesn't wouldn't apply to case statements.
44
+ class Module
45
+ def ===(arg)
46
+ arg.kind_of?(self)
47
+ end
48
+ end
metadata ADDED
@@ -0,0 +1,221 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rmb
3
+ version: !ruby/object:Gem::Version
4
+ hash: 7
5
+ prerelease: false
6
+ segments:
7
+ - 3
8
+ - 0
9
+ - 0
10
+ version: 3.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Jake Good, Eric Skiff, Kunal Shah, Seth Thomas Rasmussen, Matthew Rathbone
14
+ - Bryan Woods
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-09-21 00:00:00 -04:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: mime-types
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: json
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: httparty
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - "="
57
+ - !ruby/object:Gem::Version
58
+ hash: 5
59
+ segments:
60
+ - 0
61
+ - 6
62
+ - 1
63
+ version: 0.6.1
64
+ type: :runtime
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: multipart-post
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - "="
73
+ - !ruby/object:Gem::Version
74
+ hash: 21
75
+ segments:
76
+ - 1
77
+ - 0
78
+ - 1
79
+ version: 1.0.1
80
+ type: :runtime
81
+ version_requirements: *id004
82
+ - !ruby/object:Gem::Dependency
83
+ name: activesupport
84
+ prerelease: false
85
+ requirement: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - "="
89
+ - !ruby/object:Gem::Version
90
+ hash: 17
91
+ segments:
92
+ - 2
93
+ - 3
94
+ - 9
95
+ version: 2.3.9
96
+ type: :runtime
97
+ version_requirements: *id005
98
+ - !ruby/object:Gem::Dependency
99
+ name: rspec
100
+ prerelease: false
101
+ requirement: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ type: :development
111
+ version_requirements: *id006
112
+ - !ruby/object:Gem::Dependency
113
+ name: diff-lcs
114
+ prerelease: false
115
+ requirement: &id007 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ type: :development
125
+ version_requirements: *id007
126
+ - !ruby/object:Gem::Dependency
127
+ name: fakeweb
128
+ prerelease: false
129
+ requirement: &id008 !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
137
+ version: "0"
138
+ type: :development
139
+ version_requirements: *id008
140
+ description: A Ruby client library for the Rich Media Backbone (RMB) API (http://rmb.io). Please send all feedback to backbone@dropio.com
141
+ email:
142
+ - jake@dropio.com
143
+ - eric@dropio.com
144
+ - kunal@dropio.com
145
+ - seth@dropio.com
146
+ - matthew@dropio.com
147
+ - bryan@dropio.com
148
+ executables: []
149
+
150
+ extensions: []
151
+
152
+ extra_rdoc_files:
153
+ - History.rdoc
154
+ - Readme.rdoc
155
+ files:
156
+ - Gemfile
157
+ - History.rdoc
158
+ - LICENSE.txt
159
+ - Manifest
160
+ - Rakefile
161
+ - Readme.rdoc
162
+ - rmb.gemspec
163
+ - lib/rmb.rb
164
+ - lib/rmb/api.rb
165
+ - lib/rmb/asset.rb
166
+ - lib/rmb/client.rb
167
+ - lib/rmb/drop.rb
168
+ - lib/rmb/job.rb
169
+ - lib/rmb/resource.rb
170
+ - lib/rmb/subscription.rb
171
+ - lib/rmb/version.rb
172
+ - spec/rmb/api_spec.rb
173
+ - spec/rmb/asset_spec.rb
174
+ - spec/rmb/client_spec.rb
175
+ - spec/rmb/drop_spec.rb
176
+ - spec/rmb/subscription_spec.rb
177
+ - spec/rmb_spec.rb
178
+ - spec/spec.opts
179
+ - spec/spec_helper.rb
180
+ has_rdoc: true
181
+ homepage: http://github.com/dropio/rmb
182
+ licenses: []
183
+
184
+ post_install_message:
185
+ rdoc_options:
186
+ - --line-numbers
187
+ - --inline-source
188
+ - --title
189
+ - Dropio
190
+ - --main
191
+ - Readme.rdoc
192
+ require_paths:
193
+ - lib
194
+ required_ruby_version: !ruby/object:Gem::Requirement
195
+ none: false
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ hash: 3
200
+ segments:
201
+ - 0
202
+ version: "0"
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
204
+ none: false
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ hash: 11
209
+ segments:
210
+ - 1
211
+ - 2
212
+ version: "1.2"
213
+ requirements: []
214
+
215
+ rubyforge_project: rmb
216
+ rubygems_version: 1.3.7
217
+ signing_key:
218
+ specification_version: 3
219
+ summary: A Ruby client library for the Drop.io Rich Media Backbone (RMB) API (http://rmb.io)
220
+ test_files: []
221
+