radiant-ray-extension 3.0.0.alpha → 3.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/Rakefile +2 -0
- data/doc/NilClass.html +178 -0
- data/doc/Ray/CLI.html +211 -197
- data/doc/Ray/Extension/Git.html +435 -0
- data/doc/Ray/Extension/RubyGem.html +858 -0
- data/doc/Ray/Extension/Zip.html +453 -0
- data/doc/Ray/Extension.html +755 -0
- data/doc/Ray/{Cache.html → Search/Cache.html} +108 -256
- data/doc/Ray/{GitHub.html → Search/GitHub.html} +167 -81
- data/doc/Ray/{RubyGems.html → Search/RubyGems.html} +118 -68
- data/doc/Ray/Search.html +822 -0
- data/doc/Ray.html +89 -34
- data/doc/String.html +99 -29
- data/doc/_index.html +1 -1
- data/doc/file.LICENSE.html +1 -1
- data/doc/file.README.html +2 -4
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +3 -3
- data/lib/ray/cli.rb +146 -193
- data/lib/ray/constants.rb +7 -12
- data/lib/ray/extension.rb +203 -89
- data/lib/ray/search.rb +198 -43
- data/lib/ray/utility.rb +31 -0
- data/lib/ray.rb +2 -7
- data/spec/fixtures/cache_single.yml +2 -1
- data/spec/fixtures/cassettes/combined_search_empty.yml +71 -0
- data/spec/fixtures/cassettes/combined_search_multiple.yml +264 -0
- data/spec/fixtures/cassettes/combined_search_single.yml +108 -0
- data/spec/fixtures/cassettes/github_reorder_children_zip_file.yml +487 -0
- data/spec/fixtures/cassettes/github_sitemap_xml_zip_file.yml +553 -0
- data/spec/fixtures/cassettes/{github_v2_api_no_matches.yml → github_v2_search_empty.yml} +3 -3
- data/spec/fixtures/cassettes/github_v2_search_multiple.yml +225 -0
- data/spec/fixtures/cassettes/github_v2_search_single.yml +76 -0
- data/spec/fixtures/cassettes/{zip_file.yml → github_zip_file.yml} +3 -3
- data/spec/fixtures/cassettes/{rubygems_v1_api_gem_info.yml → rubygems_v1_gem_info.yml} +5 -5
- data/spec/fixtures/cassettes/{rubygems_v1_api_no_matches.yml → rubygems_v1_search_empty.yml} +3 -3
- data/spec/fixtures/cassettes/rubygems_v1_search_multiple.yml +40 -0
- data/spec/fixtures/cassettes/{rubygems_v1_api_search_reorder_children.yml → rubygems_v1_search_single.yml} +6 -6
- data/spec/fixtures/dummy.zip +0 -0
- data/spec/ray/extension_spec.rb +172 -0
- data/spec/ray/search_spec.rb +300 -0
- data/spec/spec_helper.rb +36 -9
- metadata +50 -85
- data/doc/Extension.html +0 -1189
- data/doc/Ray/Gem.html +0 -760
- data/doc/Ray/Git.html +0 -278
- data/doc/Ray/Zip.html +0 -300
- data/doc/Search.html +0 -433
- data/lib/ray/extension/gem.rb +0 -96
- data/lib/ray/extension/git.rb +0 -30
- data/lib/ray/extension/zip.rb +0 -44
- data/lib/ray/search/cache.rb +0 -61
- data/lib/ray/search/github.rb +0 -40
- data/lib/ray/search/rubygems.rb +0 -36
- data/lib/ray/string.rb +0 -18
- data/spec/fixtures/Gemfile +0 -4
- data/spec/fixtures/cassettes/github_v2_api_search_no_matches.yml +0 -38
- data/spec/fixtures/cassettes/github_v2_api_search_reorder_children.yml +0 -75
- data/spec/fixtures/cassettes/github_v2_api_search_single.yml +0 -74
- data/spec/fixtures/cassettes/github_v3_api_owner_name.yml +0 -75
- data/spec/fixtures/cassettes/rubygems_v1_api_search_no_matches.yml +0 -34
- data/spec/fixtures/cassettes/rubygems_v1_api_search_reorder.yml +0 -36
- data/spec/fixtures/cassettes/rubygems_v1_api_search_single.yml +0 -41
- data/spec/fixtures/dummy/README +0 -1
- data/spec/fixtures/dummy/Rakefile +0 -109
- data/spec/fixtures/dummy/config/initializers/radiant_config.rb +0 -3
- data/spec/fixtures/dummy/config/locales/en.yml +0 -3
- data/spec/fixtures/dummy/config/routes.rb +0 -5
- data/spec/fixtures/dummy/dummy_extension.rb +0 -21
- data/spec/fixtures/dummy/lib/radiant-dummy-extension.rb +0 -8
- data/spec/fixtures/dummy/lib/tasks/dummy_extension_tasks.rake +0 -47
- data/spec/fixtures/dummy/public/stylesheets/extensions/dummy/dummy.css +0 -0
- data/spec/fixtures/dummy/radiant-dummy-extension.gemspec +0 -29
- data/spec/ray/extension/gem_spec.rb +0 -214
- data/spec/ray/extension/git_spec.rb +0 -216
- data/spec/ray/extension/zip_spec.rb +0 -239
- data/spec/ray/search/cache_spec.rb +0 -74
- data/spec/ray/search/github_spec.rb +0 -137
- data/spec/ray/search/rubygems_spec.rb +0 -127
- data/spec/ray/string_spec.rb +0 -30
@@ -1,239 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "ray/extension/zip"
|
3
|
-
|
4
|
-
module Extension
|
5
|
-
def run_task task, options = {} ; "" ; end
|
6
|
-
end
|
7
|
-
|
8
|
-
describe Ray::Zip do
|
9
|
-
|
10
|
-
describe "install" do
|
11
|
-
|
12
|
-
before do
|
13
|
-
FileUtils.mkdir_p Ray::EXT_DIR
|
14
|
-
@extension = Ray::Zip.new({
|
15
|
-
:name => "dummy",
|
16
|
-
:uri => "https://github.com/johnmuhl/ray-dummy-extension/zipball/master"
|
17
|
-
})
|
18
|
-
end
|
19
|
-
|
20
|
-
after { cleanup }
|
21
|
-
|
22
|
-
it "must raise if the extension is already installed" do
|
23
|
-
FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
|
24
|
-
proc { @extension.install }.must_raise RuntimeError
|
25
|
-
end
|
26
|
-
|
27
|
-
it "must install the extension" do
|
28
|
-
VCR.use_cassette("zip_file") do
|
29
|
-
@extension.install
|
30
|
-
File.exist?("#{Ray::EXT_DIR}/dummy/dummy_extension.rb").must_equal true
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "download" do
|
37
|
-
|
38
|
-
before do
|
39
|
-
FileUtils.mkdir_p Ray::TMP_DIR
|
40
|
-
end
|
41
|
-
|
42
|
-
after { cleanup }
|
43
|
-
|
44
|
-
it "must raise if the name is not given" do
|
45
|
-
proc {
|
46
|
-
Ray::Zip.new({ :uri => "x" }).download
|
47
|
-
}.must_raise RuntimeError
|
48
|
-
end
|
49
|
-
|
50
|
-
it "must raise if the uri is not given" do
|
51
|
-
proc {
|
52
|
-
Ray::Zip.new({ :name => "x" }).download
|
53
|
-
}.must_raise RuntimeError
|
54
|
-
end
|
55
|
-
|
56
|
-
it "must download the file" do
|
57
|
-
VCR.use_cassette("zip_file") do
|
58
|
-
Ray::Zip.new({
|
59
|
-
:name => "dummy",
|
60
|
-
:uri => "https://github.com/johnmuhl/ray-dummy-extension/zipball/master"
|
61
|
-
}).download
|
62
|
-
end
|
63
|
-
File.exist?("#{Ray::TMP_DIR}/master").must_equal true
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "extract" do
|
69
|
-
|
70
|
-
before do
|
71
|
-
FileUtils.mkdir_p Ray::TMP_DIR
|
72
|
-
end
|
73
|
-
|
74
|
-
after { cleanup }
|
75
|
-
|
76
|
-
it "must raise if the file does not exist" do
|
77
|
-
proc {
|
78
|
-
Ray::Zip.new.extract
|
79
|
-
}.must_raise RuntimeError
|
80
|
-
end
|
81
|
-
|
82
|
-
it "must extract zip archives" do
|
83
|
-
FileUtils.cp "#{Dir.pwd}/spec/fixtures/dummy.zip", "#{Ray::TMP_DIR}/dummy.zip"
|
84
|
-
Ray::Zip.new.extract
|
85
|
-
File.exist?("#{Ray::TMP_DIR}/dummy/dummy_extension.rb").must_equal true
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "disable" do
|
91
|
-
|
92
|
-
before do
|
93
|
-
FileUtils.mkdir_p Ray::EXT_DIR
|
94
|
-
FileUtils.mkdir_p Ray::TMP_DIR
|
95
|
-
@extension = Ray::Zip.new({ :name => "dummy" })
|
96
|
-
end
|
97
|
-
|
98
|
-
after { cleanup }
|
99
|
-
|
100
|
-
it "must raise if the extension is not installed" do
|
101
|
-
proc { @extension.disable }.must_raise RuntimeError
|
102
|
-
end
|
103
|
-
|
104
|
-
it "must disable the extension" do
|
105
|
-
FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
|
106
|
-
@extension.disable
|
107
|
-
File.exist?("#{Ray::EXT_DIR}/.disabled/dummy/dummy_extension.rb").must_equal true
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
describe "enable" do
|
113
|
-
|
114
|
-
before do
|
115
|
-
FileUtils.mkdir_p "#{Ray::EXT_DIR}/.disabled"
|
116
|
-
FileUtils.mkdir_p Ray::TMP_DIR
|
117
|
-
@extension = Ray::Zip.new({ :name => "dummy" })
|
118
|
-
end
|
119
|
-
|
120
|
-
after { cleanup }
|
121
|
-
|
122
|
-
it "must raise if the extension is not disabled" do
|
123
|
-
proc { @extension.enable }.must_raise RuntimeError
|
124
|
-
end
|
125
|
-
|
126
|
-
it "must enable the extension" do
|
127
|
-
FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/.disabled/dummy"
|
128
|
-
@extension.enable
|
129
|
-
File.exist?("#{Ray::EXT_DIR}/dummy/dummy_extension.rb").must_equal true
|
130
|
-
end
|
131
|
-
|
132
|
-
end
|
133
|
-
|
134
|
-
describe "uninstall" do
|
135
|
-
|
136
|
-
before do
|
137
|
-
FileUtils.mkdir_p Ray::EXT_DIR
|
138
|
-
FileUtils.mkdir_p Ray::TMP_DIR
|
139
|
-
@extension = Ray::Zip.new({ :name => "dummy" })
|
140
|
-
end
|
141
|
-
|
142
|
-
after { cleanup }
|
143
|
-
|
144
|
-
it "must raise if the extension is not installed" do
|
145
|
-
proc { @extension.uninstall }.must_raise RuntimeError
|
146
|
-
end
|
147
|
-
|
148
|
-
it "must uninstall the extension" do
|
149
|
-
FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
|
150
|
-
@extension.uninstall
|
151
|
-
File.exist?("#{Ray::EXT_DIR}/dummy/dummy_extension.rb").must_equal false
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
|
156
|
-
describe "load_tasks" do
|
157
|
-
|
158
|
-
before do
|
159
|
-
FileUtils.mkdir_p Ray::EXT_DIR
|
160
|
-
FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
|
161
|
-
end
|
162
|
-
|
163
|
-
after { cleanup }
|
164
|
-
|
165
|
-
it "must load available Rake tasks" do
|
166
|
-
tasks = Ray::Zip.new({ :name => "dummy" }).load_tasks - ["default", "spec", "spec:cli"]
|
167
|
-
tasks.must_equal ["radiant:extensions:dummy:migrate", "radiant:extensions:dummy:sync", "radiant:extensions:dummy:update"]
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
describe "run_task" do
|
173
|
-
|
174
|
-
before do
|
175
|
-
FileUtils.mkdir_p Ray::EXT_DIR
|
176
|
-
FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
|
177
|
-
end
|
178
|
-
|
179
|
-
after { cleanup }
|
180
|
-
|
181
|
-
it "must run Rake tasks" do
|
182
|
-
task = Ray::Zip.new({ :name => "dummy" }).run_task "migrate"
|
183
|
-
task.must_equal ""
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
187
|
-
|
188
|
-
describe "run_tasks" do
|
189
|
-
|
190
|
-
before do
|
191
|
-
FileUtils.mkdir_p Ray::EXT_DIR
|
192
|
-
FileUtils.cp_r "#{Dir.pwd}/spec/fixtures/dummy", "#{Ray::EXT_DIR}/dummy"
|
193
|
-
end
|
194
|
-
|
195
|
-
after { cleanup }
|
196
|
-
|
197
|
-
it "must run the appropriate Rake tasks" do
|
198
|
-
extension = Ray::Zip.new({ :name => "dummy" })
|
199
|
-
tasks = extension.run_tasks - ["default", "spec", "spec:cli"]
|
200
|
-
tasks.must_equal ["radiant:extensions:dummy:migrate", "radiant:extensions:dummy:sync", "radiant:extensions:dummy:update"]
|
201
|
-
end
|
202
|
-
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "name=" do
|
206
|
-
|
207
|
-
it "must convert the name to a proper extension name" do
|
208
|
-
extension = Ray::Zip.new
|
209
|
-
extension.name = "what-ever"
|
210
|
-
extension.name.must_equal "what_ever"
|
211
|
-
extension.name = "radiant-what-ever"
|
212
|
-
extension.name.must_equal "what_ever"
|
213
|
-
extension.name = "what-ever-extension"
|
214
|
-
extension.name.must_equal "what_ever"
|
215
|
-
extension.name = "radiant-what-ever-extension"
|
216
|
-
extension.name.must_equal "what_ever"
|
217
|
-
extension.name = "what_ever"
|
218
|
-
extension.name.must_equal "what_ever"
|
219
|
-
extension.name = "radiant_what_ever"
|
220
|
-
extension.name.must_equal "what_ever"
|
221
|
-
extension.name = "what_ever_extension"
|
222
|
-
extension.name.must_equal "what_ever"
|
223
|
-
extension.name = "radiant_what_ever_extension"
|
224
|
-
extension.name.must_equal "what_ever"
|
225
|
-
extension.name = "whatever"
|
226
|
-
extension.name.must_equal "whatever"
|
227
|
-
extension.name = "radiant_whatever"
|
228
|
-
extension.name.must_equal "whatever"
|
229
|
-
extension.name = "whatever_extension"
|
230
|
-
extension.name.must_equal "whatever"
|
231
|
-
extension.name = "radiant_whatever_extension"
|
232
|
-
extension.name.must_equal "whatever"
|
233
|
-
extension.name = "RADIANT-WHAT-EVER-EXTENSION"
|
234
|
-
extension.name.must_equal "what_ever"
|
235
|
-
end
|
236
|
-
|
237
|
-
end
|
238
|
-
|
239
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "ray/search/cache"
|
3
|
-
|
4
|
-
describe Ray::Cache do
|
5
|
-
|
6
|
-
describe "new" do
|
7
|
-
|
8
|
-
before do
|
9
|
-
FileUtils.mkdir_p Ray::RAY
|
10
|
-
FileUtils.cp "#{Dir.pwd}/spec/fixtures/cache_single.yml", Ray::CACHE
|
11
|
-
end
|
12
|
-
|
13
|
-
after { cleanup }
|
14
|
-
|
15
|
-
it "must have search results when there are matches" do
|
16
|
-
search = Ray::Cache.new "reorder-children"
|
17
|
-
search.results.must_equal({
|
18
|
-
"reorder_children" => {
|
19
|
-
:author => "Benny Degezelle",
|
20
|
-
:description => "Makes Radiant better by adding reorder_children!",
|
21
|
-
:homepage => "http://github.com/jomz/radiant-reorder_children-extension",
|
22
|
-
:name => "reorder_children",
|
23
|
-
:uri => "http://rubygems.org/gems/radiant-reorder_children-extension-1.0.5.gem",
|
24
|
-
:version => "1.0.5"
|
25
|
-
}
|
26
|
-
})
|
27
|
-
end
|
28
|
-
|
29
|
-
it "won't have search results when there are no matches" do
|
30
|
-
search = Ray::Cache.new "no-matches"
|
31
|
-
search.results.must_equal({})
|
32
|
-
end
|
33
|
-
|
34
|
-
it "won't have search results when there is no cache" do
|
35
|
-
FileUtils.rm_r Ray::RAY
|
36
|
-
search = Ray::Cache.new "no-matches"
|
37
|
-
search.results.must_equal({})
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "clear" do
|
43
|
-
|
44
|
-
before do
|
45
|
-
FileUtils.mkdir_p Ray::RAY
|
46
|
-
FileUtils.cp "#{Dir.pwd}/spec/fixtures/cache_single.yml", Ray::CACHE
|
47
|
-
end
|
48
|
-
|
49
|
-
after { cleanup }
|
50
|
-
|
51
|
-
it "must clear the cache" do
|
52
|
-
Ray::Cache.clear
|
53
|
-
File.exist?(Ray::CACHE).must_equal false
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "match?" do
|
59
|
-
|
60
|
-
it "must match by name or description" do
|
61
|
-
search = Ray::Cache.new "match"
|
62
|
-
search.match?("this", "will match").must_equal true
|
63
|
-
search.match?("match", "this will").must_equal true
|
64
|
-
end
|
65
|
-
|
66
|
-
it "must match by proper extension name" do
|
67
|
-
search = Ray::Cache.new "match-by-name"
|
68
|
-
search.match?("match_by_name", "").must_equal true
|
69
|
-
search.match?("", "match_by_name").must_equal false
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
@@ -1,137 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "ray/search/github"
|
3
|
-
|
4
|
-
describe Ray::GitHub do
|
5
|
-
|
6
|
-
describe "new" do
|
7
|
-
|
8
|
-
it "must have search results when there are matches" do
|
9
|
-
VCR.use_cassette("github_v2_api_search_single") do
|
10
|
-
search = Ray::GitHub.new "ray"
|
11
|
-
search.results.must_equal({
|
12
|
-
"ray" => {
|
13
|
-
:author => "john muhl",
|
14
|
-
:description => "friendly extension management for radiant cms using git or http.",
|
15
|
-
:homepage => "https://github.com/johnmuhl/radiant-ray-extension",
|
16
|
-
:name => "ray",
|
17
|
-
:uri => "https://github.com/johnmuhl/radiant-ray-extension",
|
18
|
-
:version => "latest"
|
19
|
-
}
|
20
|
-
})
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "won't have search results when there are no matches" do
|
25
|
-
VCR.use_cassette("github_v2_api_search_no_matches") do
|
26
|
-
search = Ray::GitHub.new "no-matches"
|
27
|
-
search.results.must_equal({})
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "real_name" do
|
34
|
-
|
35
|
-
it "must find the repository owner's real name" do
|
36
|
-
VCR.use_cassette("github_v3_api_owner_name") do
|
37
|
-
search = Ray::GitHub.new "ray"
|
38
|
-
search.real_name("johnmuhl").must_equal "john muhl"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "cache" do
|
45
|
-
|
46
|
-
before do
|
47
|
-
FileUtils.mkdir_p Ray::RAY
|
48
|
-
VCR.use_cassette("github_v2_api_search_single") do
|
49
|
-
@search = Ray::GitHub.new "ray"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
after { cleanup }
|
54
|
-
|
55
|
-
it "must create the cache in none exist" do
|
56
|
-
@search.cache
|
57
|
-
File.exist?(Ray::CACHE).must_equal true
|
58
|
-
end
|
59
|
-
|
60
|
-
it "must cache search" do
|
61
|
-
@search.cache
|
62
|
-
cache = YAML.load_file Ray::CACHE
|
63
|
-
cache.must_equal @search.results
|
64
|
-
end
|
65
|
-
|
66
|
-
it "must add to an existing cache" do
|
67
|
-
FileUtils.mkdir_p Ray::RAY
|
68
|
-
FileUtils.cp "#{Dir.pwd}/spec/fixtures/cache_single.yml", Ray::CACHE
|
69
|
-
old_cache = YAML.load_file Ray::CACHE
|
70
|
-
@search.cache
|
71
|
-
cache = YAML.load_file Ray::CACHE
|
72
|
-
cache.must_equal old_cache.merge(@search.results)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "must update existing cache entries" do
|
76
|
-
FileUtils.mkdir_p Ray::RAY
|
77
|
-
FileUtils.cp "#{Dir.pwd}/spec/fixtures/cache_single.yml", Ray::CACHE
|
78
|
-
VCR.use_cassette("github_v2_api_search_reorder_children") do
|
79
|
-
search = Ray::GitHub.new "reorder_children"
|
80
|
-
search.cache
|
81
|
-
cache = YAML.load_file Ray::CACHE
|
82
|
-
cache.must_equal search.results
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "output" do
|
89
|
-
|
90
|
-
it "must output formatted search results" do
|
91
|
-
VCR.use_cassette("github_v2_api_search_single") do
|
92
|
-
search = Ray::GitHub.new "ray"
|
93
|
-
search.output.must_match /ray install ray/
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
it "must output an explaination when there are no search results" do
|
98
|
-
VCR.use_cassette("github_v2_api_no_matches") do
|
99
|
-
search = Ray::GitHub.new "no-matches"
|
100
|
-
search.output.must_match /no extensions matched/i
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "merge" do
|
107
|
-
|
108
|
-
it "must merge search results" do
|
109
|
-
VCR.use_cassette("github_v2_api_search_single") do
|
110
|
-
@first = Ray::GitHub.new "ray"
|
111
|
-
end
|
112
|
-
VCR.use_cassette("github_v2_api_search_reorder_children") do
|
113
|
-
@second = Ray::GitHub.new "reorder_children"
|
114
|
-
end
|
115
|
-
@first.merge(@second).results.must_equal({
|
116
|
-
"ray" => {
|
117
|
-
:author => "john muhl",
|
118
|
-
:description => "friendly extension management for radiant cms using git or http.",
|
119
|
-
:homepage => "https://github.com/johnmuhl/radiant-ray-extension",
|
120
|
-
:name => "ray",
|
121
|
-
:uri => "https://github.com/johnmuhl/radiant-ray-extension",
|
122
|
-
:version => "latest"
|
123
|
-
},
|
124
|
-
"reorder_children" => {
|
125
|
-
:author => "Benny Degezelle",
|
126
|
-
:description => "Adds the ability to reorder the children of a certain page with drag and drop.",
|
127
|
-
:homepage => "https://github.com/jomz/radiant-reorder_children-extension",
|
128
|
-
:name => "reorder_children",
|
129
|
-
:uri => "https://github.com/jomz/radiant-reorder_children-extension",
|
130
|
-
:version => "latest"
|
131
|
-
}
|
132
|
-
})
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
@@ -1,127 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "ray/search/rubygems"
|
3
|
-
|
4
|
-
describe Ray::RubyGems do
|
5
|
-
|
6
|
-
describe "new" do
|
7
|
-
|
8
|
-
it "must have search results when there are matches" do
|
9
|
-
VCR.use_cassette("rubygems_v1_api_search_reorder") do
|
10
|
-
search = Ray::RubyGems.new "reorder"
|
11
|
-
search.results.must_equal({
|
12
|
-
"reorder_children" => {
|
13
|
-
:author => "Benny Degezelle",
|
14
|
-
:description => "Makes Radiant better by adding reorder_children!",
|
15
|
-
:homepage => "http://github.com/jomz/radiant-reorder_children-extension",
|
16
|
-
:name => "reorder_children",
|
17
|
-
:uri => "http://rubygems.org/gems/radiant-reorder_children-extension-1.0.5.gem",
|
18
|
-
:version => "1.0.5"
|
19
|
-
}
|
20
|
-
})
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "won't have search results when there are no matches" do
|
25
|
-
VCR.use_cassette("rubygems_v1_api_search_no_matches") do
|
26
|
-
search = Ray::RubyGems.new "no-matches"
|
27
|
-
search.results.must_equal({})
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "cache" do
|
34
|
-
|
35
|
-
before do
|
36
|
-
FileUtils.mkdir_p Ray::RAY
|
37
|
-
VCR.use_cassette("rubygems_v1_api_search_single") do
|
38
|
-
@search = Ray::RubyGems.new "ray"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
after { cleanup }
|
43
|
-
|
44
|
-
it "must create the cache in none exist" do
|
45
|
-
@search.cache
|
46
|
-
File.exist?(Ray::CACHE).must_equal true
|
47
|
-
end
|
48
|
-
|
49
|
-
it "must cache search" do
|
50
|
-
@search.cache
|
51
|
-
cache = YAML.load_file Ray::CACHE
|
52
|
-
cache.must_equal @search.results
|
53
|
-
end
|
54
|
-
|
55
|
-
it "must add to an existing cache" do
|
56
|
-
FileUtils.mkdir_p Ray::RAY
|
57
|
-
FileUtils.cp "#{Dir.pwd}/spec/fixtures/cache_single.yml", Ray::CACHE
|
58
|
-
old_cache = YAML.load_file Ray::CACHE
|
59
|
-
@search.cache
|
60
|
-
cache = YAML.load_file Ray::CACHE
|
61
|
-
cache.must_equal old_cache.merge(@search.results)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "must update existing cache entries" do
|
65
|
-
FileUtils.mkdir_p Ray::RAY
|
66
|
-
FileUtils.cp "#{Dir.pwd}/spec/fixtures/cache_single.yml", Ray::CACHE
|
67
|
-
VCR.use_cassette("rubygems_v1_api_search_reorder_children") do
|
68
|
-
search = Ray::RubyGems.new "reorder_children"
|
69
|
-
search.cache
|
70
|
-
cache = YAML.load_file Ray::CACHE
|
71
|
-
cache.must_equal search.results
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "output" do
|
78
|
-
|
79
|
-
it "must output formatted search results" do
|
80
|
-
VCR.use_cassette("rubygems_v1_api_search_single") do
|
81
|
-
search = Ray::RubyGems.new "ray"
|
82
|
-
search.output.must_match /ray install ray/
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
it "must output an explaination when there are no search results" do
|
87
|
-
VCR.use_cassette("rubygems_v1_api_no_matches") do
|
88
|
-
search = Ray::RubyGems.new "no-matches"
|
89
|
-
search.output.must_match /no extensions matched/i
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "merge" do
|
96
|
-
|
97
|
-
it "must merge search results" do
|
98
|
-
VCR.use_cassette("rubygems_v1_api_search_single") do
|
99
|
-
@first = Ray::RubyGems.new "ray"
|
100
|
-
@first.results["ray"][:description] = ""
|
101
|
-
end
|
102
|
-
VCR.use_cassette("rubygems_v1_api_search_reorder_children") do
|
103
|
-
@second = Ray::RubyGems.new "reorder_children"
|
104
|
-
end
|
105
|
-
@first.merge(@second).results.must_equal({
|
106
|
-
"ray" => {
|
107
|
-
:author => "john muhl",
|
108
|
-
:description => "",
|
109
|
-
:homepage => "http://johnmuhl.github.com/radiant-ray-extension/",
|
110
|
-
:name => "ray",
|
111
|
-
:uri => "http://rubygems.org/gems/radiant-ray-extension-3.0.0.pre.gem",
|
112
|
-
:version => "3.0.0.pre"
|
113
|
-
},
|
114
|
-
"reorder_children" => {
|
115
|
-
:author => "Benny Degezelle",
|
116
|
-
:description => "Makes Radiant better by adding reorder_children!",
|
117
|
-
:homepage => "http://github.com/jomz/radiant-reorder_children-extension",
|
118
|
-
:name => "reorder_children",
|
119
|
-
:uri => "http://rubygems.org/gems/radiant-reorder_children-extension-1.0.5.gem",
|
120
|
-
:version => "1.0.5"
|
121
|
-
}
|
122
|
-
})
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
end
|
data/spec/ray/string_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.expand_path "../../spec_helper", __FILE__
|
2
|
-
require "ray/string"
|
3
|
-
|
4
|
-
describe String do
|
5
|
-
|
6
|
-
describe "to_extension_name" do
|
7
|
-
|
8
|
-
it "must convert the name to a proper extension name" do
|
9
|
-
"what-ever".to_extension_name.must_equal "what_ever"
|
10
|
-
"radiant-what-ever".to_extension_name.must_equal "what_ever"
|
11
|
-
"what-ever-extension".to_extension_name.must_equal "what_ever"
|
12
|
-
"radiant-what-ever-extension".to_extension_name.must_equal "what_ever"
|
13
|
-
"what_ever".to_extension_name.must_equal "what_ever"
|
14
|
-
"radiant_what_ever".to_extension_name.must_equal "what_ever"
|
15
|
-
"what_ever_extension".to_extension_name.must_equal "what_ever"
|
16
|
-
"radiant_what_ever_extension".to_extension_name.must_equal "what_ever"
|
17
|
-
"whatever".to_extension_name.must_equal "whatever"
|
18
|
-
"radiant_whatever".to_extension_name.must_equal "whatever"
|
19
|
-
"whatever_extension".to_extension_name.must_equal "whatever"
|
20
|
-
"radiant_whatever_extension".to_extension_name.must_equal "whatever"
|
21
|
-
"RADIANT-WHAT-EVER-EXTENSION".to_extension_name.must_equal "what_ever"
|
22
|
-
end
|
23
|
-
|
24
|
-
it "must return nil if the name is emtpy" do
|
25
|
-
"".to_extension_name.must_equal nil
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|