libgems 0.0.1

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.
Files changed (177) hide show
  1. data/ChangeLog +5811 -0
  2. data/History.txt +887 -0
  3. data/LICENSE.txt +51 -0
  4. data/README.md +87 -0
  5. data/Rakefile +113 -0
  6. data/lib/gauntlet_libgems.rb +50 -0
  7. data/lib/libgems.rb +1246 -0
  8. data/lib/libgems/builder.rb +102 -0
  9. data/lib/libgems/command.rb +534 -0
  10. data/lib/libgems/command_manager.rb +182 -0
  11. data/lib/libgems/commands/build_command.rb +53 -0
  12. data/lib/libgems/commands/cert_command.rb +86 -0
  13. data/lib/libgems/commands/check_command.rb +80 -0
  14. data/lib/libgems/commands/cleanup_command.rb +106 -0
  15. data/lib/libgems/commands/contents_command.rb +98 -0
  16. data/lib/libgems/commands/dependency_command.rb +195 -0
  17. data/lib/libgems/commands/environment_command.rb +133 -0
  18. data/lib/libgems/commands/fetch_command.rb +67 -0
  19. data/lib/libgems/commands/generate_index_command.rb +133 -0
  20. data/lib/libgems/commands/help_command.rb +172 -0
  21. data/lib/libgems/commands/install_command.rb +178 -0
  22. data/lib/libgems/commands/list_command.rb +35 -0
  23. data/lib/libgems/commands/lock_command.rb +110 -0
  24. data/lib/libgems/commands/mirror_command.rb +111 -0
  25. data/lib/libgems/commands/outdated_command.rb +33 -0
  26. data/lib/libgems/commands/owner_command.rb +75 -0
  27. data/lib/libgems/commands/pristine_command.rb +93 -0
  28. data/lib/libgems/commands/push_command.rb +56 -0
  29. data/lib/libgems/commands/query_command.rb +280 -0
  30. data/lib/libgems/commands/rdoc_command.rb +91 -0
  31. data/lib/libgems/commands/search_command.rb +31 -0
  32. data/lib/libgems/commands/server_command.rb +86 -0
  33. data/lib/libgems/commands/sources_command.rb +157 -0
  34. data/lib/libgems/commands/specification_command.rb +125 -0
  35. data/lib/libgems/commands/stale_command.rb +27 -0
  36. data/lib/libgems/commands/uninstall_command.rb +83 -0
  37. data/lib/libgems/commands/unpack_command.rb +121 -0
  38. data/lib/libgems/commands/update_command.rb +160 -0
  39. data/lib/libgems/commands/which_command.rb +86 -0
  40. data/lib/libgems/config_file.rb +345 -0
  41. data/lib/libgems/custom_require.rb +44 -0
  42. data/lib/libgems/defaults.rb +101 -0
  43. data/lib/libgems/dependency.rb +227 -0
  44. data/lib/libgems/dependency_installer.rb +286 -0
  45. data/lib/libgems/dependency_list.rb +208 -0
  46. data/lib/libgems/doc_manager.rb +242 -0
  47. data/lib/libgems/errors.rb +35 -0
  48. data/lib/libgems/exceptions.rb +91 -0
  49. data/lib/libgems/ext.rb +18 -0
  50. data/lib/libgems/ext/builder.rb +56 -0
  51. data/lib/libgems/ext/configure_builder.rb +25 -0
  52. data/lib/libgems/ext/ext_conf_builder.rb +24 -0
  53. data/lib/libgems/ext/rake_builder.rb +39 -0
  54. data/lib/libgems/format.rb +81 -0
  55. data/lib/libgems/gem_openssl.rb +92 -0
  56. data/lib/libgems/gem_path_searcher.rb +100 -0
  57. data/lib/libgems/gem_runner.rb +79 -0
  58. data/lib/libgems/gemcutter_utilities.rb +49 -0
  59. data/lib/libgems/indexer.rb +720 -0
  60. data/lib/libgems/install_update_options.rb +125 -0
  61. data/lib/libgems/installer.rb +604 -0
  62. data/lib/libgems/local_remote_options.rb +135 -0
  63. data/lib/libgems/old_format.rb +153 -0
  64. data/lib/libgems/package.rb +97 -0
  65. data/lib/libgems/package/f_sync_dir.rb +23 -0
  66. data/lib/libgems/package/tar_header.rb +266 -0
  67. data/lib/libgems/package/tar_input.rb +222 -0
  68. data/lib/libgems/package/tar_output.rb +144 -0
  69. data/lib/libgems/package/tar_reader.rb +106 -0
  70. data/lib/libgems/package/tar_reader/entry.rb +141 -0
  71. data/lib/libgems/package/tar_writer.rb +241 -0
  72. data/lib/libgems/package_task.rb +126 -0
  73. data/lib/libgems/platform.rb +183 -0
  74. data/lib/libgems/remote_fetcher.rb +414 -0
  75. data/lib/libgems/require_paths_builder.rb +18 -0
  76. data/lib/libgems/requirement.rb +153 -0
  77. data/lib/libgems/security.rb +814 -0
  78. data/lib/libgems/server.rb +872 -0
  79. data/lib/libgems/source_index.rb +597 -0
  80. data/lib/libgems/source_info_cache.rb +395 -0
  81. data/lib/libgems/source_info_cache_entry.rb +56 -0
  82. data/lib/libgems/spec_fetcher.rb +337 -0
  83. data/lib/libgems/specification.rb +1487 -0
  84. data/lib/libgems/test_utilities.rb +147 -0
  85. data/lib/libgems/text.rb +65 -0
  86. data/lib/libgems/uninstaller.rb +278 -0
  87. data/lib/libgems/user_interaction.rb +527 -0
  88. data/lib/libgems/validator.rb +240 -0
  89. data/lib/libgems/version.rb +316 -0
  90. data/lib/libgems/version_option.rb +65 -0
  91. data/lib/rbconfig/datadir.rb +20 -0
  92. data/test/bogussources.rb +8 -0
  93. data/test/data/gem-private_key.pem +27 -0
  94. data/test/data/gem-public_cert.pem +20 -0
  95. data/test/fake_certlib/openssl.rb +7 -0
  96. data/test/foo/discover.rb +0 -0
  97. data/test/gem_installer_test_case.rb +97 -0
  98. data/test/gem_package_tar_test_case.rb +132 -0
  99. data/test/gemutilities.rb +605 -0
  100. data/test/insure_session.rb +43 -0
  101. data/test/mockgemui.rb +56 -0
  102. data/test/plugin/exception/libgems_plugin.rb +2 -0
  103. data/test/plugin/load/libgems_plugin.rb +1 -0
  104. data/test/plugin/standarderror/libgems_plugin.rb +2 -0
  105. data/test/private_key.pem +27 -0
  106. data/test/public_cert.pem +20 -0
  107. data/test/rubygems_plugin.rb +21 -0
  108. data/test/simple_gem.rb +66 -0
  109. data/test/test_config.rb +12 -0
  110. data/test/test_gem.rb +780 -0
  111. data/test/test_gem_builder.rb +27 -0
  112. data/test/test_gem_command.rb +178 -0
  113. data/test/test_gem_command_manager.rb +207 -0
  114. data/test/test_gem_commands_build_command.rb +74 -0
  115. data/test/test_gem_commands_cert_command.rb +124 -0
  116. data/test/test_gem_commands_check_command.rb +18 -0
  117. data/test/test_gem_commands_contents_command.rb +156 -0
  118. data/test/test_gem_commands_dependency_command.rb +216 -0
  119. data/test/test_gem_commands_environment_command.rb +144 -0
  120. data/test/test_gem_commands_fetch_command.rb +76 -0
  121. data/test/test_gem_commands_generate_index_command.rb +135 -0
  122. data/test/test_gem_commands_install_command.rb +315 -0
  123. data/test/test_gem_commands_list_command.rb +36 -0
  124. data/test/test_gem_commands_lock_command.rb +68 -0
  125. data/test/test_gem_commands_mirror_command.rb +60 -0
  126. data/test/test_gem_commands_outdated_command.rb +40 -0
  127. data/test/test_gem_commands_owner_command.rb +105 -0
  128. data/test/test_gem_commands_pristine_command.rb +108 -0
  129. data/test/test_gem_commands_push_command.rb +81 -0
  130. data/test/test_gem_commands_query_command.rb +426 -0
  131. data/test/test_gem_commands_server_command.rb +59 -0
  132. data/test/test_gem_commands_sources_command.rb +209 -0
  133. data/test/test_gem_commands_specification_command.rb +139 -0
  134. data/test/test_gem_commands_stale_command.rb +38 -0
  135. data/test/test_gem_commands_uninstall_command.rb +83 -0
  136. data/test/test_gem_commands_unpack_command.rb +199 -0
  137. data/test/test_gem_commands_update_command.rb +207 -0
  138. data/test/test_gem_commands_which_command.rb +66 -0
  139. data/test/test_gem_config_file.rb +287 -0
  140. data/test/test_gem_dependency.rb +149 -0
  141. data/test/test_gem_dependency_installer.rb +661 -0
  142. data/test/test_gem_dependency_list.rb +230 -0
  143. data/test/test_gem_doc_manager.rb +31 -0
  144. data/test/test_gem_ext_configure_builder.rb +84 -0
  145. data/test/test_gem_ext_ext_conf_builder.rb +173 -0
  146. data/test/test_gem_ext_rake_builder.rb +81 -0
  147. data/test/test_gem_format.rb +70 -0
  148. data/test/test_gem_gem_path_searcher.rb +78 -0
  149. data/test/test_gem_gem_runner.rb +45 -0
  150. data/test/test_gem_gemcutter_utilities.rb +103 -0
  151. data/test/test_gem_indexer.rb +673 -0
  152. data/test/test_gem_install_update_options.rb +68 -0
  153. data/test/test_gem_installer.rb +857 -0
  154. data/test/test_gem_local_remote_options.rb +97 -0
  155. data/test/test_gem_package_tar_header.rb +130 -0
  156. data/test/test_gem_package_tar_input.rb +112 -0
  157. data/test/test_gem_package_tar_output.rb +97 -0
  158. data/test/test_gem_package_tar_reader.rb +46 -0
  159. data/test/test_gem_package_tar_reader_entry.rb +109 -0
  160. data/test/test_gem_package_tar_writer.rb +144 -0
  161. data/test/test_gem_package_task.rb +59 -0
  162. data/test/test_gem_platform.rb +264 -0
  163. data/test/test_gem_remote_fetcher.rb +740 -0
  164. data/test/test_gem_requirement.rb +292 -0
  165. data/test/test_gem_server.rb +356 -0
  166. data/test/test_gem_silent_ui.rb +113 -0
  167. data/test/test_gem_source_index.rb +461 -0
  168. data/test/test_gem_spec_fetcher.rb +410 -0
  169. data/test/test_gem_specification.rb +1334 -0
  170. data/test/test_gem_stream_ui.rb +218 -0
  171. data/test/test_gem_text.rb +43 -0
  172. data/test/test_gem_uninstaller.rb +146 -0
  173. data/test/test_gem_validator.rb +63 -0
  174. data/test/test_gem_version.rb +181 -0
  175. data/test/test_gem_version_option.rb +89 -0
  176. data/test/test_kernel.rb +59 -0
  177. metadata +402 -0
@@ -0,0 +1,199 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'libgems/commands/unpack_command'
3
+
4
+ class TestGemCommandsUnpackCommand < RubyGemTestCase
5
+
6
+ def setup
7
+ super
8
+
9
+ Dir.chdir @tempdir do
10
+ @cmd = LibGems::Commands::UnpackCommand.new
11
+ end
12
+ end
13
+
14
+ def test_find_in_cache
15
+ util_make_gems
16
+
17
+ assert_equal(
18
+ @cmd.find_in_cache(@a1.file_name),
19
+ File.join(@gemhome, 'cache', @a1.file_name),
20
+ 'found a-1.gem in the cache'
21
+ )
22
+ end
23
+
24
+ def test_get_path
25
+ util_make_gems
26
+ util_setup_fake_fetcher
27
+ util_setup_spec_fetcher @a1
28
+
29
+ a1_data = nil
30
+
31
+ open File.join(@gemhome, 'cache', @a1.file_name), 'rb' do |fp|
32
+ a1_data = fp.read
33
+ end
34
+
35
+ LibGems::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-1.gem'] =
36
+ a1_data
37
+
38
+ dep = LibGems::Dependency.new(@a1.name, @a1.version)
39
+ assert_equal(
40
+ @cmd.get_path(dep),
41
+ File.join(@gemhome, 'cache', @a1.file_name),
42
+ 'fetches a-1 and returns the cache path'
43
+ )
44
+
45
+ FileUtils.rm File.join(@gemhome, 'cache', @a1.file_name)
46
+
47
+ assert_equal(
48
+ @cmd.get_path(dep),
49
+ File.join(@gemhome, 'cache', @a1.file_name),
50
+ 'when removed from cache, refetches a-1'
51
+ )
52
+ end
53
+
54
+ def test_execute
55
+ util_make_gems
56
+
57
+ @cmd.options[:args] = %w[a b]
58
+
59
+ use_ui @ui do
60
+ Dir.chdir @tempdir do
61
+ @cmd.execute
62
+ end
63
+ end
64
+
65
+ assert File.exist?(File.join(@tempdir, 'a-3.a')), 'a should be unpacked'
66
+ assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked'
67
+ end
68
+
69
+ def test_execute_gem_path
70
+ util_make_gems
71
+
72
+ LibGems.clear_paths
73
+
74
+ gemhome2 = File.join @tempdir, 'gemhome2'
75
+
76
+ LibGems.send :set_paths, [gemhome2, @gemhome].join(File::PATH_SEPARATOR)
77
+ LibGems.send :set_home, gemhome2
78
+
79
+ @cmd.options[:args] = %w[a]
80
+
81
+ use_ui @ui do
82
+ Dir.chdir @tempdir do
83
+ @cmd.execute
84
+ end
85
+ end
86
+
87
+ assert File.exist?(File.join(@tempdir, 'a-3.a'))
88
+ end
89
+
90
+ def test_execute_gem_path_missing
91
+ util_make_gems
92
+ util_setup_spec_fetcher
93
+
94
+ LibGems.clear_paths
95
+
96
+ gemhome2 = File.join @tempdir, 'gemhome2'
97
+
98
+ LibGems.send :set_paths, [gemhome2, @gemhome].join(File::PATH_SEPARATOR)
99
+ LibGems.send :set_home, gemhome2
100
+
101
+ @cmd.options[:args] = %w[z]
102
+
103
+ use_ui @ui do
104
+ Dir.chdir @tempdir do
105
+ @cmd.execute
106
+ end
107
+ end
108
+
109
+ assert_equal '', @ui.output
110
+ end
111
+
112
+ def test_execute_remote
113
+ util_setup_fake_fetcher
114
+ util_setup_spec_fetcher @a1, @a2
115
+ util_clear_gems
116
+
117
+ a2_data = nil
118
+ open File.join(@gemhome, 'cache', @a2.file_name), 'rb' do |fp|
119
+ a2_data = fp.read
120
+ end
121
+
122
+ LibGems::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-2.gem'] =
123
+ a2_data
124
+
125
+ LibGems.configuration.verbose = :really
126
+ @cmd.options[:args] = %w[a]
127
+
128
+ use_ui @ui do
129
+ Dir.chdir @tempdir do
130
+ @cmd.execute
131
+ end
132
+ end
133
+
134
+ assert File.exist?(File.join(@tempdir, 'a-2')), 'a should be unpacked'
135
+ end
136
+
137
+ def test_execute_sudo
138
+ util_make_gems
139
+
140
+ File.chmod 0555, @gemhome
141
+
142
+ @cmd.options[:args] = %w[b]
143
+
144
+ use_ui @ui do
145
+ Dir.chdir @tempdir do
146
+ @cmd.execute
147
+ end
148
+ end
149
+
150
+ assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked'
151
+ ensure
152
+ File.chmod 0755, @gemhome
153
+ end
154
+
155
+ def test_execute_with_target_option
156
+ util_make_gems
157
+
158
+ target = 'with_target'
159
+ @cmd.options[:args] = %w[a]
160
+ @cmd.options[:target] = target
161
+
162
+ use_ui @ui do
163
+ Dir.chdir @tempdir do
164
+ @cmd.execute
165
+ end
166
+ end
167
+
168
+ assert File.exist?(File.join(@tempdir, target, 'a-3.a'))
169
+ end
170
+
171
+ def test_execute_exact_match
172
+ foo_spec = quick_gem 'foo'
173
+ foo_bar_spec = quick_gem 'foo_bar'
174
+
175
+ use_ui @ui do
176
+ Dir.chdir @tempdir do
177
+ LibGems::Builder.new(foo_spec).build
178
+ LibGems::Builder.new(foo_bar_spec).build
179
+ end
180
+ end
181
+
182
+ foo_path = File.join(@tempdir, "#{foo_spec.full_name}.gem")
183
+ foo_bar_path = File.join(@tempdir, "#{foo_bar_spec.full_name}.gem")
184
+ LibGems::Installer.new(foo_path).install
185
+ LibGems::Installer.new(foo_bar_path).install
186
+
187
+ @cmd.options[:args] = %w[foo]
188
+
189
+ use_ui @ui do
190
+ Dir.chdir @tempdir do
191
+ @cmd.execute
192
+ end
193
+ end
194
+
195
+ assert File.exist?(File.join(@tempdir, foo_spec.full_name))
196
+ end
197
+
198
+ end
199
+
@@ -0,0 +1,207 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'libgems/commands/update_command'
3
+
4
+ class TestGemCommandsUpdateCommand < RubyGemTestCase
5
+
6
+ def setup
7
+ super
8
+
9
+ @oldpath = Dir.pwd
10
+ Dir.chdir(File.dirname(__FILE__))
11
+
12
+ @cmd = LibGems::Commands::UpdateCommand.new
13
+
14
+ @cmd.options[:generate_rdoc] = false
15
+ @cmd.options[:generate_ri] = false
16
+
17
+ util_setup_fake_fetcher
18
+
19
+ @a1_path = File.join @gemhome, 'cache', @a1.file_name
20
+ @a2_path = File.join @gemhome, 'cache', @a2.file_name
21
+
22
+ util_setup_spec_fetcher @a1, @a2
23
+
24
+ @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
25
+ read_binary @a1_path
26
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
27
+ read_binary @a2_path
28
+ end
29
+
30
+ def teardown
31
+ super
32
+ Dir.chdir(@oldpath)
33
+ end
34
+
35
+ def test_execute
36
+ util_clear_gems
37
+
38
+ LibGems::Installer.new(@a1_path).install
39
+
40
+ @cmd.options[:args] = []
41
+ @cmd.options[:generate_rdoc] = true
42
+ @cmd.options[:generate_ri] = true
43
+
44
+ use_ui @ui do
45
+ @cmd.execute
46
+ end
47
+
48
+ out = @ui.output.split "\n"
49
+ assert_match "Updating installed gems", out.shift
50
+ assert_match "Updating #{@a2.name}", out.shift
51
+ assert_match "Successfully installed #{@a2.full_name}", out.shift
52
+ assert_match "Gems updated: #{@a2.name}", out.shift
53
+ assert_match "Installing ri documentation for a-2...", out.join
54
+ assert_match "Installing RDoc documentation for a-2...", out.join
55
+ end
56
+
57
+ def util_setup_rubygem version
58
+ gem = quick_gem(LibGems::GEM_NAME, version.to_s) do |s|
59
+ s.files = %w[setup.rb]
60
+ end
61
+ write_file File.join(*%W[gems #{gem.original_name} setup.rb])
62
+ util_build_gem gem
63
+ util_setup_spec_fetcher gem
64
+ gem
65
+ end
66
+
67
+ def util_setup_rubygem8
68
+ @rubygem8 = util_setup_rubygem 8
69
+ end
70
+
71
+ def util_setup_rubygem9
72
+ @rubygem9 = util_setup_rubygem 9
73
+ end
74
+
75
+ def util_setup_rubygem_current
76
+ @rubygem_current = util_setup_rubygem LibGems::VERSION
77
+ end
78
+
79
+ def util_add_to_fetcher *specs
80
+ specs.each do |spec|
81
+ gem_file = File.join @gemhome, 'cache', spec.file_name
82
+
83
+ @fetcher.data["http://gems.example.com/gems/#{spec.file_name}"] =
84
+ LibGems.read_binary gem_file
85
+ end
86
+ end
87
+
88
+ # before:
89
+ # a1 -> c1.2
90
+ # after:
91
+ # a2 -> b2 # new dependency
92
+ # a2 -> c2
93
+
94
+ def test_execute_dependencies
95
+ @a1.add_dependency 'c', '1.2'
96
+
97
+ @c2 = quick_gem 'c', '2' do |s|
98
+ s.files = %w[lib/code.rb]
99
+ s.require_paths = %w[lib]
100
+ end
101
+
102
+ @a2.add_dependency 'c', '2'
103
+ @a2.add_dependency 'b', '2'
104
+
105
+ @b2_path = File.join @gemhome, 'cache', @b2.file_name
106
+ @c1_2_path = File.join @gemhome, 'cache', @c1_2.file_name
107
+ @c2_path = File.join @gemhome, 'cache', @c2.file_name
108
+
109
+ @source_index = LibGems::SourceIndex.new
110
+ @source_index.add_spec @a1
111
+ @source_index.add_spec @a2
112
+ @source_index.add_spec @b2
113
+ @source_index.add_spec @c1_2
114
+ @source_index.add_spec @c2
115
+
116
+ util_build_gem @a1
117
+ util_build_gem @a2
118
+ util_build_gem @c2
119
+
120
+ @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = read_binary @a1_path
121
+ @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] = read_binary @a2_path
122
+ @fetcher.data["#{@gem_repo}gems/#{@b2.file_name}"] = read_binary @b2_path
123
+ @fetcher.data["#{@gem_repo}gems/#{@c1_2.file_name}"] =
124
+ read_binary @c1_2_path
125
+ @fetcher.data["#{@gem_repo}gems/#{@c2.file_name}"] = read_binary @c2_path
126
+
127
+ util_setup_spec_fetcher @a1, @a2, @b2, @c1_2, @c2
128
+ util_clear_gems
129
+
130
+ LibGems::Installer.new(@c1_2_path).install
131
+ LibGems::Installer.new(@a1_path).install
132
+
133
+ @cmd.options[:args] = []
134
+
135
+ use_ui @ui do
136
+ @cmd.execute
137
+ end
138
+
139
+ out = @ui.output.split "\n"
140
+ assert_equal "Updating installed gems", out.shift
141
+ assert_equal "Updating #{@a2.name}", out.shift
142
+ assert_equal "Successfully installed #{@c2.full_name}", out.shift
143
+ assert_equal "Successfully installed #{@b2.full_name}", out.shift
144
+ assert_equal "Successfully installed #{@a2.full_name}", out.shift
145
+ assert_equal "Gems updated: #{@c2.name}, #{@b2.name}, #{@a2.name}",
146
+ out.shift
147
+
148
+ assert_empty out
149
+ end
150
+
151
+ def test_execute_named
152
+ util_clear_gems
153
+
154
+ LibGems::Installer.new(@a1_path).install
155
+
156
+ @cmd.options[:args] = [@a1.name]
157
+
158
+ use_ui @ui do
159
+ @cmd.execute
160
+ end
161
+
162
+ out = @ui.output.split "\n"
163
+ assert_equal "Updating installed gems", out.shift
164
+ assert_equal "Updating #{@a2.name}", out.shift
165
+ assert_equal "Successfully installed #{@a2.full_name}", out.shift
166
+ assert_equal "Gems updated: #{@a2.name}", out.shift
167
+
168
+ assert_empty out
169
+ end
170
+
171
+ def test_execute_named_up_to_date
172
+ util_clear_gems
173
+
174
+ LibGems::Installer.new(@a2_path).install
175
+
176
+ @cmd.options[:args] = [@a2.name]
177
+
178
+ use_ui @ui do
179
+ @cmd.execute
180
+ end
181
+
182
+ out = @ui.output.split "\n"
183
+ assert_equal "Updating installed gems", out.shift
184
+ assert_equal "Nothing to update", out.shift
185
+
186
+ assert_empty out
187
+ end
188
+
189
+ def test_execute_up_to_date
190
+ util_clear_gems
191
+
192
+ LibGems::Installer.new(@a2_path).install
193
+
194
+ @cmd.options[:args] = []
195
+
196
+ use_ui @ui do
197
+ @cmd.execute
198
+ end
199
+
200
+ out = @ui.output.split "\n"
201
+ assert_equal "Updating installed gems", out.shift
202
+ assert_equal "Nothing to update", out.shift
203
+
204
+ assert_empty out
205
+ end
206
+
207
+ end
@@ -0,0 +1,66 @@
1
+ require File.expand_path('../gemutilities', __FILE__)
2
+ require 'libgems/commands/which_command'
3
+
4
+ class TestGemCommandsWhichCommand < RubyGemTestCase
5
+
6
+ def setup
7
+ super
8
+ @cmd = LibGems::Commands::WhichCommand.new
9
+ end
10
+
11
+ def test_execute
12
+ util_foo_bar
13
+
14
+ @cmd.handle_options %w[foo_bar]
15
+
16
+ use_ui @ui do
17
+ @cmd.execute
18
+ end
19
+
20
+ assert_equal "#{@foo_bar.full_gem_path}/lib/foo_bar.rb\n", @ui.output
21
+ assert_equal '', @ui.error
22
+ end
23
+
24
+ def test_execute_one_missing
25
+ util_foo_bar
26
+
27
+ @cmd.handle_options %w[foo_bar missing]
28
+
29
+ use_ui @ui do
30
+ @cmd.execute
31
+ end
32
+
33
+ assert_equal "#{@foo_bar.full_gem_path}/lib/foo_bar.rb\n", @ui.output
34
+ assert_match %r%Can't find ruby library file or shared library missing\n%,
35
+ @ui.error
36
+ end
37
+
38
+ def test_execute_missing
39
+ @cmd.handle_options %w[missing]
40
+
41
+ use_ui @ui do
42
+ assert_raises MockGemUi::TermError do
43
+ @cmd.execute
44
+ end
45
+ end
46
+
47
+ assert_equal '', @ui.output
48
+ assert_match %r%Can't find ruby library file or shared library missing\n%,
49
+ @ui.error
50
+ end
51
+
52
+ def util_foo_bar
53
+ files = %w[lib/foo_bar.rb Rakefile]
54
+ @foo_bar = quick_gem 'foo_bar' do |gem|
55
+ gem.files = files
56
+ end
57
+
58
+ files.each do |file|
59
+ filename = @foo_bar.full_gem_path + "/#{file}"
60
+ FileUtils.mkdir_p File.dirname(filename)
61
+ FileUtils.touch filename
62
+ end
63
+ end
64
+
65
+ end
66
+