Creates a Gem::Specification with a
minimum of extra work. name and version are the gem’s
name and version, platform, author, email, homepage, summary and
description are defaulted. The specification is yielded for customization.
The gem is added to the installed gems in +@gemhome+ and the runtime.
Use this with #write_file to
build an installed gem.
# File lib/rubygems/test_case.rb, line 567
def quick_gem(name, version='2')
require 'rubygems/specification'
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = name
s.version = version
s.author = 'A User'
s.email = '[email protected]'
s.homepage = 'http://example.com'
s.summary = "this is a summary"
s.description = "This is a test description"
yield(s) if block_given?
end
Gem::Specification.map # HACK: force specs to (re-)load before we write
written_path = write_file spec.spec_file do |io|
io.write spec.to_ruby_for_cache
end
spec.loaded_from = spec.loaded_from = written_path
Gem::Specification.add_spec spec.for_cache
return spec
end