In Files

  • rubygems/test_utilities.rb

Class/Module Index [+]

Quicksearch

Gem::TestCase::SpecFetcherSetup

The SpecFetcherSetup allows easy setup of a remote source in RubyGems tests:

spec_fetcher do |f|
  f.gem  'a', 1
  f.spec 'a', 2
  f.gem  'b', 1' 'a' => '~> 1.0'
  f.clear
end

The above declaration creates two gems, a-1 and b-1, with a dependency from b to a. The declaration creates an additional spec a-2, but no gem for it (so it cannot be installed).

After the gems are created they are removed from Gem.dir.

Public Class Methods

declare(test, repository) click to toggle source

Executes a SpecFetcher setup block. Yields an instance then creates the gems and specifications defined in the instance.

 
               # File rubygems/test_utilities.rb, line 202
def self.declare test, repository
  setup = new test, repository

  yield setup

  setup.execute
end
            

Public Instance Methods

clear() click to toggle source

Removes any created gems or specifications from Gem.dir (the default install location).

 
               # File rubygems/test_utilities.rb, line 223
def clear
  @operations << [:clear]
end
            
created_specs() click to toggle source

Returns a Hash of created Specification full names and the corresponding Specification.

 
               # File rubygems/test_utilities.rb, line 231
def created_specs
  created = {}

  @gems.keys.each do |spec|
    created[spec.full_name] = spec
  end

  created
end
            
gem(name, version, dependencies = nil, &block) click to toggle source

Creates a gem with name, version and deps. The created gem can be downloaded and installed.

The specification will be yielded before gem creation for customization, but only the block or the dependencies may be set, not both.

 
               # File rubygems/test_utilities.rb, line 283
def gem name, version, dependencies = nil, &block
  @operations << [:gem, name, version, dependencies, block]
end
            
legacy_platform() click to toggle source

Creates a legacy platform spec with the name ‘pl’ and version 1

 
               # File rubygems/test_utilities.rb, line 290
def legacy_platform
  spec 'pl', 1 do |s|
    s.platform = Gem::Platform.new 'i386-linux'
    s.instance_variable_set :@original_platform, 'i386-linux'
  end
end
            
spec(name, version, dependencies = nil, &block) click to toggle source

Creates a spec with name, version and deps. The created gem can be downloaded and installed.

The specification will be yielded before creation for customization, but only the block or the dependencies may be set, not both.

 
               # File rubygems/test_utilities.rb, line 341
def spec name, version, dependencies = nil, &block
  @operations << [:spec, name, version, dependencies, block]
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus