shibkit-meta_meta 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +21 -0
- data/Gemfile.lock +52 -0
- data/Icon.png +0 -0
- data/LICENSE.txt +177 -0
- data/README.md +789 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/examples/biggest_entity_id.rb +4 -0
- data/lib/shibkit/meta_meta.rb +600 -0
- data/lib/shibkit/meta_meta/attribute.rb +73 -0
- data/lib/shibkit/meta_meta/config.rb +463 -0
- data/lib/shibkit/meta_meta/contact.rb +85 -0
- data/lib/shibkit/meta_meta/data/default_metadata/example_federation_metadata.xml +168 -0
- data/lib/shibkit/meta_meta/data/default_metadata/local_metadata.xml +66 -0
- data/lib/shibkit/meta_meta/data/default_metadata/uncommon_federation_metadata.xml +115 -0
- data/lib/shibkit/meta_meta/data/default_metadata_cache.yml +166 -0
- data/lib/shibkit/meta_meta/data/dev_sources.yml +86 -0
- data/lib/shibkit/meta_meta/data/real_sources.yml +163 -0
- data/lib/shibkit/meta_meta/entity.rb +219 -0
- data/lib/shibkit/meta_meta/federation.rb +161 -0
- data/lib/shibkit/meta_meta/idp.rb +81 -0
- data/lib/shibkit/meta_meta/logo.rb +216 -0
- data/lib/shibkit/meta_meta/metadata_item.rb +244 -0
- data/lib/shibkit/meta_meta/mixin/cached_downloads.rb +127 -0
- data/lib/shibkit/meta_meta/mixin/xpath_chores.rb +111 -0
- data/lib/shibkit/meta_meta/organisation.rb +73 -0
- data/lib/shibkit/meta_meta/provider.rb +195 -0
- data/lib/shibkit/meta_meta/provisioning/base.rb +33 -0
- data/lib/shibkit/meta_meta/requested_attribute.rb +29 -0
- data/lib/shibkit/meta_meta/service.rb +94 -0
- data/lib/shibkit/meta_meta/source.rb +558 -0
- data/lib/shibkit/meta_meta/sp.rb +79 -0
- data/shibkit-meta_meta.gemspec +154 -0
- data/spec/meta_meta/attribute/token +0 -0
- data/spec/meta_meta/config/autoloading_and_refreshing_spec.rb +72 -0
- data/spec/meta_meta/config/code_nspec.rb +13 -0
- data/spec/meta_meta/config/configuration_spec.rb +30 -0
- data/spec/meta_meta/config/creation_spec.rb +43 -0
- data/spec/meta_meta/config/downloading_and_caching_settings_spec.rb +216 -0
- data/spec/meta_meta/config/env_platform_settings.rb +129 -0
- data/spec/meta_meta/config/filtering_settings_spec.rb +123 -0
- data/spec/meta_meta/config/init.rb +8 -0
- data/spec/meta_meta/config/logger_settings_spec.rb +91 -0
- data/spec/meta_meta/config/smartcache_settings_spec.rb +110 -0
- data/spec/meta_meta/config/source_file_settings_spec.rb +99 -0
- data/spec/meta_meta/config/tagging_settings_spec.rb +81 -0
- data/spec/meta_meta/config/working_directory_settings_spec.rb +106 -0
- data/spec/meta_meta/config/xml_processing_settings_spec.rb +75 -0
- data/spec/meta_meta/contact/contact_oldspec.rb +0 -0
- data/spec/meta_meta/entity/entity_oldspec.rb +53 -0
- data/spec/meta_meta/federation/federation_oldspec.rb +0 -0
- data/spec/meta_meta/idp/token +0 -0
- data/spec/meta_meta/logo/token +0 -0
- data/spec/meta_meta/meta_meta/cache_example.yaml +141284 -0
- data/spec/meta_meta/meta_meta/meta_meta_spec.rb +269 -0
- data/spec/meta_meta/meta_meta/saved_sources.yaml +46 -0
- data/spec/meta_meta/metadata_item/token +0 -0
- data/spec/meta_meta/organisation/organisation_oldspec.rb +0 -0
- data/spec/meta_meta/provider/token +0 -0
- data/spec/meta_meta/requested_attribute/token +0 -0
- data/spec/meta_meta/service/token +0 -0
- data/spec/meta_meta/source/application_extras_spec.rb +234 -0
- data/spec/meta_meta/source/conversion_spec.rb +75 -0
- data/spec/meta_meta/source/creation_spec.rb +0 -0
- data/spec/meta_meta/source/downloads_and_caching_spec.rb +0 -0
- data/spec/meta_meta/source/federation_information_spec.rb +11 -0
- data/spec/meta_meta/source/fixtures.rb +24 -0
- data/spec/meta_meta/source/init.rb +1 -0
- data/spec/meta_meta/source/loading_and_saving_spec.rb +0 -0
- data/spec/meta_meta/source/metadata_details_spec.rb +0 -0
- data/spec/meta_meta/source/metadata_integrity_spec.rb +0 -0
- data/spec/meta_meta/source/selection_spec.rb +0 -0
- data/spec/meta_meta/source/source_oldspec.rb +353 -0
- data/spec/meta_meta/source/xml_parsing_spec.rb +0 -0
- data/spec/meta_meta/sp/token +0 -0
- data/spec/meta_meta/template +2 -0
- data/spec/moi/config_spec.rb +0 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/supply_xml.rb +0 -0
- metadata +320 -0
@@ -0,0 +1,269 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
|
2
|
+
|
3
|
+
describe Shibkit::MetaMeta do
|
4
|
+
before(:all) do
|
5
|
+
file = File.open("rspec.log",'w')
|
6
|
+
Shibkit::MetaMeta.config.logger= Logger.new(file)
|
7
|
+
Shibkit::MetaMeta.config.logger.level = Logger::DEBUG
|
8
|
+
Shibkit::MetaMeta.config.logger.datetime_format = "%Y-%m-%d %H:%M:%S"
|
9
|
+
Shibkit::MetaMeta.config.logger.formatter = proc { |severity, datetime, progname, msg| "#{datetime}: #{severity} #{msg}\n" }
|
10
|
+
Shibkit::MetaMeta.config.logger.progname = "MetaMeta-RSpec"
|
11
|
+
end
|
12
|
+
|
13
|
+
before(:each) do |test|
|
14
|
+
Shibkit::MetaMeta.reset
|
15
|
+
Shibkit::MetaMeta.config.autoload = true
|
16
|
+
Shibkit::MetaMeta.config.logger.info "Running [#{test.example.metadata[:full_description]}]"
|
17
|
+
end
|
18
|
+
after(:each) do |test|
|
19
|
+
Shibkit::MetaMeta.config.logger.info "Finihed [#{test.example.metadata[:full_description]}]"
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#reset" do
|
23
|
+
it "should reduce the number of sources to zero" do
|
24
|
+
Shibkit::MetaMeta.reset
|
25
|
+
Shibkit::MetaMeta.additional_sources.size.should == 0 &&
|
26
|
+
Shibkit::MetaMeta.loaded_sources.size.should == 0
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#add_source" do
|
31
|
+
|
32
|
+
it "should accept a single source" do
|
33
|
+
Shibkit::MetaMeta.add_source({
|
34
|
+
:uri => 'http://ukfederation.org.uk',
|
35
|
+
:name => 'UK Access Management Federation For Education And Research',
|
36
|
+
:display_name => 'UK Access Management Federation',
|
37
|
+
:type => 'federation',
|
38
|
+
:countries => ['gb'],
|
39
|
+
:metadata => 'http://metadata.ukfederation.org.uk/ukfederation-metadata.xml',
|
40
|
+
:certificate => 'http://metadata.ukfederation.org.uk/ukfederation.pem',
|
41
|
+
:fingerprint => '94:7F:5E:8C:4E:F5:E1:69:E7:DF:68:1E:48:AA:98:44:A5:41:56:EE',
|
42
|
+
:refeds_info => 'https://refeds.terena.org/index.php/FederationUkfed',
|
43
|
+
:homepage => 'http://www.ukfederation.org.uk',
|
44
|
+
:languages => ['en-gb', 'en'],
|
45
|
+
:support_email => ' service@ukfederation.org.uk',
|
46
|
+
:description => 'A single solution for accessing online resources and services',
|
47
|
+
})
|
48
|
+
Shibkit::MetaMeta.additional_sources.size.should == 1 &&
|
49
|
+
Shibkit::MetaMeta.additional_sources.first[0].should == 'http://ukfederation.org.uk'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should accept more than one source" do
|
53
|
+
Shibkit::MetaMeta.add_source({
|
54
|
+
:uri => 'http://ukfederation.org.uk',
|
55
|
+
:name => 'UK Access Management Federation For Education And Research',
|
56
|
+
:display_name => 'UK Access Management Federation',
|
57
|
+
:type => 'federation',
|
58
|
+
:countries => ['gb'],
|
59
|
+
:metadata => 'http://metadata.ukfederation.org.uk/ukfederation-metadata.xml',
|
60
|
+
:certificate => 'http://metadata.ukfederation.org.uk/ukfederation.pem',
|
61
|
+
:fingerprint => '94:7F:5E:8C:4E:F5:E1:69:E7:DF:68:1E:48:AA:98:44:A5:41:56:EE',
|
62
|
+
:refeds_info => 'https://refeds.terena.org/index.php/FederationUkfed',
|
63
|
+
:homepage => 'http://www.ukfederation.org.uk',
|
64
|
+
:languages => ['en-gb', 'en'],
|
65
|
+
:support_email => ' service@ukfederation.org.uk',
|
66
|
+
:description => 'A single solution for accessing online resources and services',
|
67
|
+
})
|
68
|
+
Shibkit::MetaMeta.add_source({
|
69
|
+
:uri => 'urn:mace:aaf.edu.au:AAFProduction',
|
70
|
+
:name => 'Australian Access Federation',
|
71
|
+
:display_name => 'AAF',
|
72
|
+
:type => 'federation',
|
73
|
+
:countries => ['au'],
|
74
|
+
:metadata => 'http://manager.aaf.edu.au/metadata/metadata.aaf.signed.complete.xml',
|
75
|
+
:certificate => 'https://manager.aaf.edu.au/metadata/metadata-cert.pem',
|
76
|
+
:refeds_info => 'https://refeds.terena.org/index.php/FederationAAF',
|
77
|
+
:homepage => 'http://www.aaf.edu.au/',
|
78
|
+
:languages => ['en'],
|
79
|
+
:support_email => 'enquiries@aaf.edu.au',
|
80
|
+
:description => 'The Australian Access Federation.',
|
81
|
+
})
|
82
|
+
Shibkit::MetaMeta.additional_sources.size.should == 2 &&
|
83
|
+
Shibkit::MetaMeta.additional_sources.keys[0].should == 'http://ukfederation.org.uk' &&
|
84
|
+
Shibkit::MetaMeta.additional_sources.keys[1].should == 'urn:mace:aaf.edu.au:AAFProduction'
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#save_sources" do
|
90
|
+
it "should save the sources list to a file" do
|
91
|
+
Shibkit::MetaMeta.add_source({
|
92
|
+
:uri => 'urn:mace:aaf.edu.au:AAFProduction',
|
93
|
+
:name => 'Australian Access Federation',
|
94
|
+
:display_name => 'AAF',
|
95
|
+
:type => 'federation',
|
96
|
+
:countries => ['au'],
|
97
|
+
:metadata => 'http://manager.aaf.edu.au/metadata/metadata.aaf.signed.complete.xml',
|
98
|
+
:certificate => 'https://manager.aaf.edu.au/metadata/metadata-cert.pem',
|
99
|
+
:refeds_info => 'https://refeds.terena.org/index.php/FederationAAF',
|
100
|
+
:homepage => 'http://www.aaf.edu.au/',
|
101
|
+
:languages => ['en'],
|
102
|
+
:support_email => 'enquiries@aaf.edu.au',
|
103
|
+
:description => 'The Australian Access Federation.',
|
104
|
+
})
|
105
|
+
Shibkit::MetaMeta.add_source({
|
106
|
+
:uri => 'http://ukfederation.org.uk',
|
107
|
+
:name => 'UK Access Management Federation For Education And Research',
|
108
|
+
:display_name => 'UK Access Management Federation',
|
109
|
+
:type => 'federation',
|
110
|
+
:countries => ['gb'],
|
111
|
+
:metadata => 'http://metadata.ukfederation.org.uk/ukfederation-metadata.xml',
|
112
|
+
:certificate => 'http://metadata.ukfederation.org.uk/ukfederation.pem',
|
113
|
+
:fingerprint => '94:7F:5E:8C:4E:F5:E1:69:E7:DF:68:1E:48:AA:98:44:A5:41:56:EE',
|
114
|
+
:refeds_info => 'https://refeds.terena.org/index.php/FederationUkfed',
|
115
|
+
:homepage => 'http://www.ukfederation.org.uk',
|
116
|
+
:languages => ['en-gb', 'en'],
|
117
|
+
:support_email => ' service@ukfederation.org.uk',
|
118
|
+
:description => 'A single solution for accessing online resources and services',
|
119
|
+
})
|
120
|
+
tmpfile = Tempfile.new('metametasources')
|
121
|
+
sourcesfile = tmpfile.path
|
122
|
+
sourcesfile = 'mysaved_sources.yaml'
|
123
|
+
tmpfile.close
|
124
|
+
Shibkit::MetaMeta.save_sources(sourcesfile)
|
125
|
+
referencefile = File.open("#{File.dirname(__FILE__)}/saved_sources.yaml").read
|
126
|
+
resultfile = File.open(sourcesfile).read
|
127
|
+
Shibkit::MetaMeta.config.logger.debug "referencefile (MD5:#{Digest::MD5.hexdigest(referencefile)}):\n#{referencefile}\nsavedfile (MD5:#{Digest::MD5.hexdigest(resultfile)}):\n#{resultfile}\n"
|
128
|
+
(File.exists? sourcesfile).should == true &&
|
129
|
+
resultfile.should == referencefile
|
130
|
+
end
|
131
|
+
end
|
132
|
+
describe "#load_sources" do
|
133
|
+
it "should automatically load sources if no source file has been specified." do
|
134
|
+
Shibkit::MetaMeta.load_sources
|
135
|
+
Shibkit::MetaMeta.loaded_sources.size.should == 4 &&
|
136
|
+
Shibkit::MetaMeta.loaded_sources?.should == true &&
|
137
|
+
Shibkit::MetaMeta.loaded_sources.keys[0].should == 'http://ukfederation.org.uk'
|
138
|
+
end
|
139
|
+
it "should be possible to set the file to load from" do
|
140
|
+
Shibkit::MetaMeta.config.sources_file="#{File.dirname(__FILE__)}/saved_sources.yaml"
|
141
|
+
end
|
142
|
+
it "should load sources from a file" do
|
143
|
+
Shibkit::MetaMeta.config.sources_file="#{File.dirname(__FILE__)}/saved_sources.yaml"
|
144
|
+
Shibkit::MetaMeta.load_sources
|
145
|
+
Shibkit::MetaMeta.loaded_sources.size.should == 2 &&
|
146
|
+
Shibkit::MetaMeta.loaded_sources?.should == true &&
|
147
|
+
Shibkit::MetaMeta.loaded_sources.keys[1].should == 'http://ukfederation.org.uk' &&
|
148
|
+
Shibkit::MetaMeta.loaded_sources.keys[0].should == 'urn:mace:aaf.edu.au:AAFProduction'
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
describe "#process_sources" do
|
154
|
+
it "should read it's sources and return an array of federation objects" do
|
155
|
+
federations = Shibkit::MetaMeta.process_sources
|
156
|
+
federations.is_a?(Array).should == true
|
157
|
+
federations.size.should > 0
|
158
|
+
federations.each {|fed| fed.is_a?(Shibkit::MetaMeta::Federation).should == true}
|
159
|
+
end
|
160
|
+
end
|
161
|
+
describe "#save_cache_file" do
|
162
|
+
it "should save the federation cache to a file" do
|
163
|
+
federations = Shibkit::MetaMeta.process_sources
|
164
|
+
tmpfile = Tempfile.new('metametacache')
|
165
|
+
cachefile = tmpfile.path
|
166
|
+
Shibkit::MetaMeta.save_cache_file(cachefile)
|
167
|
+
(File.exists? cachefile).should == true
|
168
|
+
end
|
169
|
+
end
|
170
|
+
describe "#load_cache_file" do
|
171
|
+
it "should load objects from a cache file" do
|
172
|
+
Shibkit::MetaMeta.load_cache_file("#{File.dirname(__FILE__)}/cache_example.yaml")
|
173
|
+
Shibkit::MetaMeta.stocked?.should == true
|
174
|
+
end
|
175
|
+
end
|
176
|
+
describe "#flush" do
|
177
|
+
it "should clear the cache" do
|
178
|
+
Shibkit::MetaMeta.load_cache_file("#{File.dirname(__FILE__)}/cache_example.yaml")
|
179
|
+
Shibkit::MetaMeta.stocked?.should == true &&
|
180
|
+
Shibkit::MetaMeta.flush &&
|
181
|
+
Shibkit::MetaMeta.stocked?.should == false
|
182
|
+
end
|
183
|
+
end
|
184
|
+
describe "#delete_all_cached_files" do
|
185
|
+
it "should prevent me from accidentally harming my system"
|
186
|
+
it "should delete cache file"
|
187
|
+
end
|
188
|
+
describe "#smart_cache" do
|
189
|
+
it "should do 'something smart'"
|
190
|
+
end
|
191
|
+
describe "#refresh" do
|
192
|
+
it "should refresh metadata" do
|
193
|
+
Shibkit::MetaMeta.refresh
|
194
|
+
Shibkit::MetaMeta.stocked?
|
195
|
+
end
|
196
|
+
it "shouldn't refresh, (under certain conditions)"
|
197
|
+
it "should be forcable"
|
198
|
+
end
|
199
|
+
describe "#stockup" do
|
200
|
+
it "should load sources, if it is configured to auto-load" do
|
201
|
+
Shibkit::MetaMeta.config.autoload = true
|
202
|
+
Shibkit::MetaMeta.stockup
|
203
|
+
Shibkit::MetaMeta.stocked?.should == true
|
204
|
+
end
|
205
|
+
it "shouldn't do anything if it isn't configured to auto-load" do
|
206
|
+
Shibkit::MetaMeta.config.autoload = false
|
207
|
+
Shibkit::MetaMeta.stockup
|
208
|
+
Shibkit::MetaMeta.stocked?.should == false
|
209
|
+
end
|
210
|
+
it "shouldn't load sources if federations have already been loaded"
|
211
|
+
end
|
212
|
+
describe "#federations" do
|
213
|
+
it "should auto-initilize" do
|
214
|
+
Shibkit::MetaMeta.federations
|
215
|
+
Shibkit::MetaMeta.stocked?.should == true
|
216
|
+
end
|
217
|
+
it "should return a array of Shibkit::Federation objects" do
|
218
|
+
feds = Shibkit::MetaMeta.federations
|
219
|
+
feds.is_a?(Array).should == true
|
220
|
+
feds.size.should > 0
|
221
|
+
feds.each {|fed| fed.is_a?(Shibkit::MetaMeta::Federation).should == true}
|
222
|
+
end
|
223
|
+
end
|
224
|
+
describe "#entities" do
|
225
|
+
it "should return an array of Shibkit::Entity objects" do
|
226
|
+
ents = Shibkit::MetaMeta.entities
|
227
|
+
ents.is_a?(Array)
|
228
|
+
ents.size.should > 0
|
229
|
+
ents.each {|ent| ent.is_a?(Shibkit::MetaMeta::Entity).should == true}
|
230
|
+
end
|
231
|
+
end
|
232
|
+
describe "#orgs" do
|
233
|
+
it "should return an array of Shibkit::Organisation objects, sorted by druid" do
|
234
|
+
orgs = Shibkit::MetaMeta.orgs
|
235
|
+
orgs.is_a?(Array)
|
236
|
+
orgs.size.should > 0
|
237
|
+
orgs.each {|org| org.is_a?(Shibkit::MetaMeta::Organisation).should == true}
|
238
|
+
end
|
239
|
+
end
|
240
|
+
describe "#idps" do
|
241
|
+
it "should return an array of Shibkit::IDP objects" do
|
242
|
+
idps = Shibkit::MetaMeta.idps
|
243
|
+
idps.is_a?(Array)
|
244
|
+
idps.size.should > 0
|
245
|
+
Shibkit::MetaMeta.config.logger.debug "IDP Array:"
|
246
|
+
idps.each {|idp|
|
247
|
+
Shibkit::MetaMeta.config.logger.debug " object type:#{idp.class}"
|
248
|
+
idp.is_a?(Shibkit::MetaMeta::Entity).should == true
|
249
|
+
idp.idp?.should == true
|
250
|
+
}
|
251
|
+
end
|
252
|
+
end
|
253
|
+
describe "#sps" do
|
254
|
+
it "should return an array of Shibkit::SP objects" do
|
255
|
+
sps = Shibkit::MetaMeta.sps
|
256
|
+
sps.is_a?(Array)
|
257
|
+
sps.size.should > 0
|
258
|
+
Shibkit::MetaMeta.config.logger.debug "SP Array:"
|
259
|
+
sps.each {|sp|
|
260
|
+
Shibkit::MetaMeta.config.logger.debug " object type:#{sp.class}"
|
261
|
+
sp.is_a?(Shibkit::MetaMeta::Entity).should == true
|
262
|
+
sp.sp?.should == true
|
263
|
+
}
|
264
|
+
end
|
265
|
+
end
|
266
|
+
describe "#from_uri" do
|
267
|
+
# TODO I don't know what this is for
|
268
|
+
end
|
269
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
urn:mace:aaf.edu.au:AAFProduction:
|
3
|
+
uri: urn:mace:aaf.edu.au:AAFProduction
|
4
|
+
name: Australian Access Federation
|
5
|
+
refresh: 0
|
6
|
+
display_name: AAF
|
7
|
+
type: federation
|
8
|
+
countries:
|
9
|
+
- au
|
10
|
+
metadata: http://manager.aaf.edu.au/metadata/metadata.aaf.signed.complete.xml
|
11
|
+
certificate: https://manager.aaf.edu.au/metadata/metadata-cert.pem
|
12
|
+
fingerprint:
|
13
|
+
refeds_info: https://refeds.terena.org/index.php/FederationAAF
|
14
|
+
homepage: http://www.aaf.edu.au/
|
15
|
+
languages:
|
16
|
+
- en
|
17
|
+
support_email: enquiries@aaf.edu.au
|
18
|
+
description: The Australian Access Federation.
|
19
|
+
trustiness:
|
20
|
+
groups: []
|
21
|
+
|
22
|
+
tags: []
|
23
|
+
|
24
|
+
http://ukfederation.org.uk:
|
25
|
+
uri: http://ukfederation.org.uk
|
26
|
+
name: UK Access Management Federation For Education And Research
|
27
|
+
refresh: 0
|
28
|
+
display_name: UK Access Management Federation
|
29
|
+
type: federation
|
30
|
+
countries:
|
31
|
+
- gb
|
32
|
+
metadata: http://metadata.ukfederation.org.uk/ukfederation-metadata.xml
|
33
|
+
certificate: http://metadata.ukfederation.org.uk/ukfederation.pem
|
34
|
+
fingerprint: 94:7F:5E:8C:4E:F5:E1:69:E7:DF:68:1E:48:AA:98:44:A5:41:56:EE
|
35
|
+
refeds_info: https://refeds.terena.org/index.php/FederationUkfed
|
36
|
+
homepage: http://www.ukfederation.org.uk
|
37
|
+
languages:
|
38
|
+
- en-gb
|
39
|
+
- en
|
40
|
+
support_email: " service@ukfederation.org.uk"
|
41
|
+
description: A single solution for accessing online resources and services
|
42
|
+
trustiness:
|
43
|
+
groups: []
|
44
|
+
|
45
|
+
tags: []
|
46
|
+
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,234 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
|
2
|
+
|
3
|
+
describe Shibkit::MetaMeta::Source, "additional information for applications" do
|
4
|
+
|
5
|
+
##
|
6
|
+
before(:each) do
|
7
|
+
@source = Shibkit::MetaMeta::Source.new
|
8
|
+
end
|
9
|
+
|
10
|
+
subject { @source }
|
11
|
+
|
12
|
+
it { should respond_to :groups= }
|
13
|
+
it { should respond_to :groups }
|
14
|
+
it { should respond_to :tags= }
|
15
|
+
it { should respond_to :tags }
|
16
|
+
it { should respond_to :trustiness= }
|
17
|
+
it { should respond_to :trustiness }
|
18
|
+
|
19
|
+
it "should accept strings as group names" do
|
20
|
+
|
21
|
+
@source.groups = ['one', 'two', 'three']
|
22
|
+
@source.groups.should =~ [:one, :two, :three]
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should accept symbols for group names" do
|
27
|
+
|
28
|
+
@source.groups = [:one, :two, :three]
|
29
|
+
@source.groups.should =~ [:one, :two, :three]
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should accept a single group as a string" do
|
34
|
+
|
35
|
+
@source.groups = :one
|
36
|
+
@source.groups.should =~ [:one]
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should accept an array of groups" do
|
41
|
+
|
42
|
+
@source.groups = [:one, :two]
|
43
|
+
@source.groups.should =~ [:one, :two]
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should replace previously assigned groups with assigned groups" do
|
48
|
+
|
49
|
+
@source.groups = :elephant
|
50
|
+
@source.groups.should =~ [:elephant]
|
51
|
+
|
52
|
+
@source.groups = [:one, :two]
|
53
|
+
@source.groups.should =~ [:one, :two]
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should always return an array of groups" do
|
58
|
+
|
59
|
+
@source.groups = :elephant
|
60
|
+
@source.groups.should be_kind_of Array
|
61
|
+
|
62
|
+
@source.groups = [:one, :two]
|
63
|
+
@source.groups.should be_kind_of Array
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should always return group names as downcased symbols" do
|
68
|
+
|
69
|
+
@source.groups = :elephant
|
70
|
+
@source.groups.should =~ [:elephant]
|
71
|
+
|
72
|
+
@source.groups = :MONKEY
|
73
|
+
@source.groups.should =~ [:monkey]
|
74
|
+
|
75
|
+
@source.groups = 'hippo'
|
76
|
+
@source.groups.should =~ [:hippo]
|
77
|
+
|
78
|
+
@source.groups = 'BEAR'
|
79
|
+
@source.groups.should =~ [:bear]
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should accept strings as tag names" do
|
84
|
+
|
85
|
+
@source.tags = ['one', 'two', 'three']
|
86
|
+
@source.tags.should =~ [:one, :two, :three]
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should accept symbols for tag names" do
|
91
|
+
|
92
|
+
@source.tags = [:one, :two, :three]
|
93
|
+
@source.tags.should =~ [:one, :two, :three]
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should accept a single tag as a string" do
|
98
|
+
|
99
|
+
@source.tags = :one
|
100
|
+
@source.tags.should =~ [:one]
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should accept an array of tags" do
|
105
|
+
|
106
|
+
@source.tags = [:one, :two]
|
107
|
+
@source.tags.should =~ [:one, :two]
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should replace previously assigned tags with assigned tags" do
|
112
|
+
|
113
|
+
@source.tags = :elephant
|
114
|
+
@source.tags.should =~ [:elephant]
|
115
|
+
|
116
|
+
@source.tags = [:one, :two]
|
117
|
+
@source.tags.should =~ [:one, :two]
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should always return an array of tags" do
|
122
|
+
|
123
|
+
@source.tags = :elephant
|
124
|
+
@source.tags.should be_kind_of Array
|
125
|
+
|
126
|
+
@source.tags = [:one, :two]
|
127
|
+
@source.tags.should be_kind_of Array
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should always return tag names as downcased symbols" do
|
132
|
+
|
133
|
+
@source.tags = :elephant
|
134
|
+
@source.tags.should =~ [:elephant]
|
135
|
+
|
136
|
+
@source.tags = :MONKEY
|
137
|
+
@source.tags.should =~ [:monkey]
|
138
|
+
|
139
|
+
@source.tags = 'hippo'
|
140
|
+
@source.tags.should =~ [:hippo]
|
141
|
+
|
142
|
+
@source.tags = 'BEAR'
|
143
|
+
@source.tags.should =~ [:bear]
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should accept floating point decimal fractions as trustiness" do
|
148
|
+
|
149
|
+
dfs = [0.1,0.0,0.4,0.9,1.0].each do |df|
|
150
|
+
|
151
|
+
@source.trustiness = df
|
152
|
+
@source.trustiness.should == df
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should accept strings starting with numbers followed by a percentage" do
|
159
|
+
|
160
|
+
@source.trustiness = "50%"
|
161
|
+
@source.trustiness.should == 0.5
|
162
|
+
|
163
|
+
@source.trustiness = "70 %"
|
164
|
+
@source.trustiness.should == 0.7
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should accept strings with numbers as trustiness and trim before converting to floating point" do
|
169
|
+
|
170
|
+
@source.trustiness = "5 things"
|
171
|
+
@source.trustiness.should == 1.0
|
172
|
+
|
173
|
+
@source.trustiness = "80"
|
174
|
+
@source.trustiness.should == 1.0
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should store numbers greater than 1 as 1.0" do
|
179
|
+
|
180
|
+
@source.trustiness = 100
|
181
|
+
@source.trustiness.should == 1.0
|
182
|
+
|
183
|
+
@source.trustiness = 5
|
184
|
+
@source.trustiness.should == 1.0
|
185
|
+
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should store numbers less than 0 as 0.0" do
|
190
|
+
|
191
|
+
@source.trustiness = -100
|
192
|
+
@source.trustiness.should == 0.0
|
193
|
+
|
194
|
+
@source.trustiness = -5
|
195
|
+
@source.trustiness.should == 0.0
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should only return trustiness of between 0 and 1, as a floating point number/decimal fraction" do
|
200
|
+
|
201
|
+
@source.trustiness = 100
|
202
|
+
@source.trustiness.should be_kind_of Float
|
203
|
+
|
204
|
+
@source.trustiness = 0.5
|
205
|
+
@source.trustiness.should be_kind_of Float
|
206
|
+
|
207
|
+
@source.trustiness = -5
|
208
|
+
@source.trustiness.should be_kind_of Float
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
context "by default" do
|
213
|
+
|
214
|
+
it "should return 1.0 as the default trustiness" do
|
215
|
+
|
216
|
+
@source.trustiness.should == 1.0
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
it "should return an empty array as groups" do
|
221
|
+
|
222
|
+
@source.groups.should =~ []
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should return an empty array as tags" do
|
227
|
+
|
228
|
+
@source.tags.should =~ []
|
229
|
+
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|