goncalossilva-kaltura_fu 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe "General Configuration testing" do
4
+ before(:all) do
5
+ KalturaFu.config = {}
6
+ KalturaFu.client_configuration =nil
7
+ KalturaFu.clear_session_key!
8
+ KalturaFu.client = nil
9
+ end
10
+ it "Should start with an empty config" do
11
+ KalturaFu.config.should be_empty
12
+ end
13
+
14
+ it "Shouldn't generate a Kaltura session on an empty config" do
15
+ lambda {KalturaFu.generate_session_key}.should raise_error(RuntimeError, "Missing Partner Identifier")
16
+ end
17
+
18
+ it "Shouldn't generate a Kaltura session without an administrator secret" do
19
+ KalturaFu.config[:partner_id] = '121413'
20
+ lambda {KalturaFu.generate_session_key}.should raise_error(RuntimeError, "Missing Administrator Secret")
21
+ end
22
+
23
+ it "Should respect the Service URL when constructing a Client configuration" do
24
+ KalturaFu.config[:parnter_id] = '123434'
25
+ lambda {KalturaFu.create_client_config}.should_not raise_error
26
+
27
+ KalturaFu.client_configuration.service_url.should == "http://www.kaltura.com"
28
+
29
+ service_url = "http://www.waffletastic.com"
30
+ KalturaFu.config[:service_url] = service_url
31
+ KalturaFu.create_client_config
32
+ KalturaFu.client_configuration.service_url.should == service_url
33
+ end
34
+
35
+ it "Should raise a Kaltura::APIError when you provide incorrect information." do
36
+ KalturaFu.config = {}
37
+ KalturaFu.config[:partner_id] , KalturaFu.config[:administrator_secret] = '1241' , 'a3$35casd'
38
+ lambda {KalturaFu.generate_session_key}.should raise_error(Kaltura::APIError)
39
+ end
40
+ end
41
+ describe "Valid Configuration tests" do
42
+ before :each do
43
+ KalturaFuTestConfiguration.setup
44
+ end
45
+
46
+ it "Should function just fine with proper credentials" do
47
+ lambda {KalturaFu.generate_session_key}.should_not raise_error
48
+ end
49
+
50
+ it "Should allow you to clear the session" do
51
+ KalturaFu.generate_session_key
52
+ KalturaFu.clear_session_key!
53
+
54
+ KalturaFu.session_key.should be nil
55
+ end
56
+
57
+ it "Should generate a valid session if you ask politely" do
58
+ KalturaFu.clear_session_key!
59
+ KalturaFu.check_for_client_session
60
+
61
+ KalturaFu.session_key.should_not be nil
62
+ end
63
+ end
@@ -0,0 +1,271 @@
1
+ require 'spec_helper'
2
+
3
+ class MetadataSpecTester
4
+ include KalturaFu::Entry::Metadata
5
+ end
6
+
7
+ class EntryUploader
8
+ include KalturaFu::Entry
9
+ end
10
+
11
+ describe "Actions on an entries metadata" do
12
+ before(:all) do
13
+ KalturaFuTestConfiguration.setup
14
+ end
15
+
16
+ before(:each) do
17
+ @entry_id = EntryUploader.upload(KalturaFuTestConfiguration.video,:source=>:file)
18
+ end
19
+
20
+ after(:each) do
21
+ EntryUploader.new.delete_entry(@entry_id)
22
+ end
23
+
24
+ it "should respond to getting valid entry attributes" do
25
+ test = MetadataSpecTester.new
26
+ test.should respond_to :get_name
27
+ end
28
+
29
+ it "should respond to getting valid entry attributes" do
30
+ test = MetadataSpecTester.new
31
+ test.should respond_to :get_description
32
+ end
33
+
34
+ it "should respond to getting valid entry attributes" do
35
+ test = MetadataSpecTester.new
36
+ test.should respond_to :get_categories
37
+ end
38
+
39
+ it "should respond to setting valid entry attributes" do
40
+ test = MetadataSpecTester.new
41
+ test.should respond_to :set_description
42
+ end
43
+
44
+ it "should respond to setting valid entry attributes" do
45
+ test = MetadataSpecTester.new
46
+ test.should respond_to :set_name
47
+ end
48
+
49
+ it "should respond to setting valid entry attributes" do
50
+ test = MetadataSpecTester.new
51
+ test.should respond_to :set_categories
52
+ end
53
+
54
+ it "should respond to adding valid entry attributes" do
55
+ test = MetadataSpecTester.new
56
+ test.should respond_to :add_categories
57
+ end
58
+
59
+ it "should respond to adding valid entry attributes" do
60
+ test = MetadataSpecTester.new
61
+ test.should respond_to :add_tags
62
+ end
63
+
64
+ it "should respond to adding valid entry attributes" do
65
+ test = MetadataSpecTester.new
66
+ test.should respond_to :add_admin_tags
67
+ end
68
+
69
+ it "should not respond to getting invalid entry attributes" do
70
+ test = MetadataSpecTester.new
71
+ test.should_not respond_to :get_barack_obama
72
+ end
73
+
74
+ it "should not respond to setting invalid entry attributes" do
75
+ test = MetadataSpecTester.new
76
+ test.should_not respond_to :set_magic
77
+ end
78
+
79
+ it "should not respond to adding invalid entry attributes" do
80
+ test = MetadataSpecTester.new
81
+ test.should_not respond_to :add_waffles
82
+ end
83
+
84
+ it "should not respond to adding invalid entry attributes" do
85
+ test = MetadataSpecTester.new
86
+ test.should_not respond_to :add_category
87
+ end
88
+
89
+ it "should not respond to adding invalid entry attributes" do
90
+ test = MetadataSpecTester.new
91
+ test.should_not respond_to :add_tag
92
+ end
93
+
94
+ it "should not respond to adding invalid entry attributes" do
95
+ test = MetadataSpecTester.new
96
+ test.should_not respond_to :add_admin_tag
97
+ end
98
+
99
+ it "should not respond to adding valid entry attributes, but improperly typed" do
100
+ test = MetadataSpecTester.new
101
+ test.should_not respond_to :add_name
102
+ end
103
+
104
+ it "should not respond to adding valid entry attributes, but improperly typed" do
105
+ test = MetadataSpecTester.new
106
+ test.should_not respond_to :add_names
107
+ end
108
+
109
+ it "should set the name field when asked kindly" do
110
+ test = MetadataSpecTester.new
111
+ test.set_name(@entry_id,"waffles").should == "waffles"
112
+ end
113
+
114
+ it "should set the desription field when asked kindly" do
115
+ test = MetadataSpecTester.new
116
+ test.set_description(@entry_id,"The beginning of the end of the beginning").should == "The beginning of the end of the beginning"
117
+ end
118
+
119
+ it "should be a little weirder when setting a group of tags" do
120
+ test = MetadataSpecTester.new
121
+ test.set_tags(@entry_id,"waffles,awesome,rock,hard").should == "waffles, awesome, rock, hard"
122
+ test.get_tags(@entry_id).should == "waffles, awesome, rock, hard"
123
+ end
124
+
125
+ it "should just be weird with tags, admin tags don't act this way either" do
126
+ test = MetadataSpecTester.new
127
+ test.set_admin_tags(@entry_id,"waffles,awesome,rock,hard").should == "waffles,awesome,rock,hard"
128
+ test.get_admin_tags(@entry_id).should == "waffles,awesome,rock,hard"
129
+ end
130
+
131
+ it "shouldn't act like tags with categories" do
132
+ test = MetadataSpecTester.new
133
+ test.set_categories(@entry_id,"waffles,awesome,rock,hard").should == "waffles,awesome,rock,hard"
134
+ end
135
+
136
+ it "should raise a Kaltura::APIError when you give it a bogus entry" do
137
+ test = MetadataSpecTester.new
138
+
139
+ lambda {test.set_name("waffles","waffles")}.should raise_error(Kaltura::APIError)
140
+ end
141
+
142
+ it "should not increment the version when you perform set actions" do
143
+ test = MetadataSpecTester.new
144
+
145
+ version_count = test.get_version(@entry_id).to_i
146
+
147
+ test.set_name(@entry_id,"my new name")
148
+ test.get_version(@entry_id).to_i.should == version_count
149
+ end
150
+
151
+ it "should not increment the version when you perform set actions on tags" do
152
+ test = MetadataSpecTester.new
153
+
154
+ version_count = test.get_version(@entry_id).to_i
155
+
156
+ test.set_tags(@entry_id,"buttons,kittens,pirates")
157
+ test.get_version(@entry_id).to_i.should == version_count
158
+ end
159
+
160
+ it "should be making KMC categories for every category you set unless it already exists." do
161
+ test = MetadataSpecTester.new
162
+
163
+ categories = "waffles#{rand(10)},pirates#{rand(18)},peanuts#{rand(44)}"
164
+ categories.split(",").each do |category|
165
+ test.category_exists?(category).should be_false
166
+ end
167
+
168
+ test.set_categories(@entry_id,categories)
169
+
170
+ categories.split(",").each do |category|
171
+ cat = test.category_exists?(category)
172
+ cat.should_not be_false
173
+ end
174
+
175
+ bob = KalturaFu.client.category_service.list.objects
176
+ bob.each do |cat|
177
+ if cat.name =~/^(waffles|pirates|peanuts)(.*)/
178
+ KalturaFu.client.category_service.delete(cat.id)
179
+ end
180
+ end
181
+
182
+ end
183
+
184
+ it "should allow you to add tags onto an existing tag string without knowing the original tags" do
185
+ test = MetadataSpecTester.new
186
+
187
+ original_tags = test.set_tags(@entry_id,"gorillaz, pop, damon, albarn")
188
+
189
+ test.add_tags(@entry_id,"mos,def").should == original_tags + ", mos, def"
190
+ end
191
+
192
+ it "no longer responds to adding a single tag. dynamic dispatches are cooler than syntax sugar." do
193
+ test = MetadataSpecTester.new
194
+
195
+ original_tags = test.set_tags(@entry_id,"gorillaz, pop, damon, albarn")
196
+
197
+ lambda {test.add_tag(@entry_id,"mos")}.should raise_error
198
+ end
199
+
200
+ it "should allow you to add admin tags onto an existing tag string without knowing the original tags" do
201
+ test = MetadataSpecTester.new
202
+
203
+ original_tags = test.set_admin_tags(@entry_id,"gorillaz,pop,damon,albarn")
204
+
205
+ test.add_admin_tags(@entry_id,"mos,def").should == original_tags + ",mos,def"
206
+ end
207
+
208
+ it "no longer responds to adding a single admin tag" do
209
+ test = MetadataSpecTester.new
210
+
211
+ original_tags = test.set_admin_tags(@entry_id,"gorillaz, pop, damon, albarn")
212
+
213
+ lambda {test.add_admin_tag(@entry_id,"mos")}.should raise_error
214
+ end
215
+
216
+ it "should let you add categories onto an existing category string as well." do
217
+ test = MetadataSpecTester.new
218
+
219
+ original_categories = test.set_categories(@entry_id,"peanuts#{rand(10)}")
220
+
221
+ new_cats = "pirates#{rand(10)},waffles#{rand(10)}"
222
+ test.add_categories(@entry_id,new_cats).should == original_categories + ",#{new_cats}"
223
+ check_string = original_categories + ",#{new_cats}"
224
+ check_string.split(",").each do |category|
225
+ cat = test.category_exists?(category)
226
+ cat.should_not be_false
227
+ end
228
+ bob = KalturaFu.client.category_service.list.objects
229
+ bob.each do |cat|
230
+ if cat.name =~/^(waffles|pirates|peanuts)(.*)/
231
+ KalturaFu.client.category_service.delete(cat.id)
232
+ end
233
+ end
234
+ end
235
+
236
+ it "should create categories for each one you add if they don't exist." do
237
+ test = MetadataSpecTester.new
238
+
239
+ original_categories = test.set_categories(@entry_id,"peanuts#{rand(10)}")
240
+
241
+ new_cats = "pirates#{rand(10)},waffles#{rand(10)}"
242
+ test.add_categories(@entry_id,new_cats)
243
+ check_string = original_categories + ",#{new_cats}"
244
+ check_string.split(",").each do |category|
245
+ cat = test.category_exists?(category)
246
+ cat.should_not be_false
247
+ end
248
+ bob = KalturaFu.client.category_service.list.objects
249
+ bob.each do |cat|
250
+ if cat.name =~/^(waffles|pirates|peanuts)(.*)/
251
+ KalturaFu.client.category_service.delete(cat.id)
252
+ end
253
+ end
254
+ end
255
+
256
+ it "should no longer respond to adding a single category" do
257
+ test = MetadataSpecTester.new
258
+
259
+ original_categories = test.set_categories(@entry_id,"peanuts#{rand(10)},pirates#{rand(10)}")
260
+
261
+ new_cat = "waffles#{rand(10)}"
262
+ lambda{test.add_category(@entry_id,new_cat)}.should raise_error
263
+
264
+ bob = KalturaFu.client.category_service.list.objects
265
+ bob.each do |cat|
266
+ if cat.name =~/^(waffles|pirates|peanuts)(.*)/
267
+ KalturaFu.client.category_service.delete(cat.id)
268
+ end
269
+ end
270
+ end
271
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,28 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'kaltura_fu'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+ require 'rubygems'
7
+ require 'kaltura'
8
+ require 'yaml'
9
+ require 'active_support/core_ext/hash'
10
+
11
+ Spec::Runner.configure do |config|
12
+
13
+ end
14
+
15
+ class KalturaFuTestConfiguration
16
+ def self.setup
17
+ kaltura_yml = File.join(File.dirname(__FILE__),'config','kaltura.yml')
18
+ KalturaFu.config = YAML.load_file(kaltura_yml).symbolize_keys
19
+
20
+ #remove any lingering and possibly incorrect client information
21
+ KalturaFu.client = nil
22
+ KalturaFu.client_configuration = nil
23
+ end
24
+
25
+ def self.video
26
+ File.open(File.join(File.dirname(__FILE__),'config','video.flv'))
27
+ end
28
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: goncalossilva-kaltura_fu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease: !!null
6
+ platform: ruby
7
+ authors:
8
+ - Patrick Robertson
9
+ autorequire: !!null
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2010-11-06 00:00:00.000000000 +00:00
13
+ default_executable: !!null
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: &19430220 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - =
21
+ - !ruby/object:Gem::Version
22
+ version: 1.3.0
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *19430220
26
+ - !ruby/object:Gem::Dependency
27
+ name: activesupport
28
+ requirement: &19429740 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.5
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *19429740
37
+ description: !!null
38
+ email: patrick.robertson@velir.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files:
42
+ - README.markdown
43
+ files:
44
+ - .gitignore
45
+ - MIT-LICENSE
46
+ - README.markdown
47
+ - Rakefile
48
+ - VERSION.yml
49
+ - generators/kaltura_fu_install/kaltura_fu_install_generator.rb
50
+ - generators/kaltura_fu_install/templates/kaltura.yml
51
+ - generators/kaltura_fu_install/templates/kaltura_upload.js
52
+ - install.rb
53
+ - kaltura_fu.gemspec
54
+ - lib/kaltura_fu.rb
55
+ - lib/kaltura_fu/configuration.rb
56
+ - lib/kaltura_fu/entry.rb
57
+ - lib/kaltura_fu/entry/class_methods.rb
58
+ - lib/kaltura_fu/entry/flavor.rb
59
+ - lib/kaltura_fu/entry/instance_methods.rb
60
+ - lib/kaltura_fu/entry/metadata.rb
61
+ - lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb
62
+ - lib/kaltura_fu/entry/metadata/class_methods.rb
63
+ - lib/kaltura_fu/railtie.rb
64
+ - lib/kaltura_fu/view_helpers.rb
65
+ - rails/init.rb
66
+ - spec/debug.log
67
+ - spec/entry_spec.rb
68
+ - spec/flavor_spec.rb
69
+ - spec/kaltura_fu_spec.rb
70
+ - spec/metadata_spec.rb
71
+ - spec/spec.opts
72
+ - spec/spec_helper.rb
73
+ - uninstall.rb
74
+ has_rdoc: true
75
+ homepage: http://github.com/goncalossilva/kaltura_fu
76
+ licenses: []
77
+ post_install_message: !!null
78
+ rdoc_options:
79
+ - --charset=UTF-8
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project: !!null
96
+ rubygems_version: 1.5.0
97
+ signing_key: !!null
98
+ specification_version: 3
99
+ summary: Rails gem for making Kaltura integrations easier.
100
+ test_files:
101
+ - spec/entry_spec.rb
102
+ - spec/flavor_spec.rb
103
+ - spec/kaltura_fu_spec.rb
104
+ - spec/metadata_spec.rb
105
+ - spec/spec_helper.rb