Permalink
Browse files

gathering rubygems information

  • Loading branch information...
tenderlove committed Feb 6, 2009
1 parent 0469db7 commit c19932018e6d46183025d0f33b429ed9c0c85d72
Showing with 65 additions and 1 deletion.
  1. +10 −0 lib/busted/gem.rb
  2. +20 −0 templates/gem_info.erb
  3. +1 −1 templates/ruby_info.erb
  4. +34 −0 test/busted/test_gem.rb
View
@@ -44,6 +44,16 @@ def ruby_info_file
target
end
+ def gem_info_file
+ template_file = File.join(BASEDIR, 'templates', 'gem_info.erb')
+ template = ERB.new(File.read(template_file))
+ target = File.join(Dir::tmpdir, 'gem_info.txt')
+ File.open(target, 'wb') { |f|
+ f.write template.result(binding)
+ }
+ target
+ end
+
private
def copy_gem
dirname = File.join(Dir::tmpdir, File.basename(@gemspec.full_gem_path))
View
@@ -0,0 +1,20 @@
+# RubyGems Environment #
+
+ - RUBYGEMS VERSION: <%= ::Gem::RubyGemsVersion %>
+ - RUBY VERSION: <%= RUBY_VERSION %> (<%= RUBY_RELEASE_DATE %> patchlevel <%= defined?(RUBY_PATCHLEVEL) ? RUBY_PATCHLEVEL : 'none' %>) [<%= RUBY_PLATFORM %>]
+ - INSTALLATION DIRECTORY: <%= ::Gem.dir %>
+ - RUBYGEMS PREFIX: <%= ::Gem.prefix %>
+ - RUBY EXECUTABLE: <%= ::Gem.ruby %>
+ - EXECUTABLE DIRECTORY: <%= ::Gem.bindir %>
+ - RUBYGEMS PLATFORMS:
+ <% ::Gem.platforms.each do |platform| %> - <%= platform %>
+ <% end %>
+ - GEM PATHS:
+ <% ::Gem.path.each do |path| %> - <%= path %>
+ <% end %>
+ - GEM CONFIGURATION:
+ <% ::Gem.configuration.each do |name, value| %> - <%= name.inspect %> => <%= value.inspect %>
+ <% end %>
+ - REMOTE SOURCES:
+ <% ::Gem.sources.each do |s| %> - <%= s %>
+ <% end %>
View
@@ -1,3 +1,3 @@
-# Ruby Information
+# Ruby Information #
<% Config::CONFIG.sort_by { |x,y| x }.each do |k,v| %><%= k %>: <%= v %>
<% end %>
View
@@ -30,6 +30,40 @@ def test_ruby_info
assert_match Dir::tmpdir, filename
assert File.exists?(filename)
assert_match /txt$/, filename
+ contents = File.read(filename)
+ Config::CONFIG.each { |k,v|
+ assert_match k, contents
+ assert_match v, contents
+ }
+ end
+
+ def test_gem_information
+ broken = Busted::Gem.new(@spec)
+ filename = broken.gem_info_file
+ assert_match Dir::tmpdir, filename
+ assert File.exists?(filename)
+ assert_match /txt$/, filename
+ contents = File.read(filename)
+ assert_match ::Gem::RubyGemsVersion, contents
+ assert_match RUBY_VERSION, contents
+ assert_match RUBY_RELEASE_DATE, contents
+ assert_match RUBY_PLATFORM, contents
+ assert_match ::Gem.dir, contents
+ assert_match ::Gem.ruby, contents
+ assert_match ::Gem.bindir, contents
+ ::Gem.platforms.each { |platform|
+ assert_match platform, contents
+ }
+ ::Gem.path.each { |path|
+ assert_match path, contents
+ }
+ ::Gem.configuration.each do |name,value|
+ assert_match name.inspect, contents
+ assert_match value.inspect, contents
+ end
+ ::Gem.sources.each do |s|
+ assert_match s, contents
+ end
end
end
end

0 comments on commit c199320

Please sign in to comment.