Class Gem::TestCase
In: lib/rubygems/test_case.rb
Parent: MiniTest::Unit::TestCase

RubyGemTestCase provides a variety of methods for testing rubygems and gem-related behavior in a sandbox. Through RubyGemTestCase you can install and uninstall gems, fetch remote gems through a stub fetcher and be assured your normal set of gems is not affected.

Tests are always run at a safe level of 1.

Methods

Included Modules

Gem::DefaultUserInteraction

Public Class methods

Returns the make command for the current platform. For versions of Ruby built on MS Windows with VC++ or Borland it will return ‘nmake’. On all other platforms, including Cygwin, it will return ‘make’.

Allows tests to use a random (but controlled) port number instead of a hardcoded one. This helps CI tools when running parallels builds on the same builder slave.

Finds the path to the ruby executable

Returns whether or not we‘re on a version of Ruby built with VC++ (or Borland) versus Cygwin, Mingw, etc.

Is this test being run on a Windows platform?

Public Instance methods

Allows the proper version of rake to be used for the test.

creates a temporary directory with hax

Builds and installs the Gem::Specification spec into the user dir

Install the provided specs

Returns the make command for the current platform. For versions of Ruby built on MS Windows with VC++ or Borland it will return ‘nmake’. On all other platforms, including Cygwin, it will return ‘make’.

Enables pretty-print for all tests

Create a new spec (or gem if passed an array of files) and set it up properly. Use this instead of util_spec and util_gem.

Returns whether or not the nmake command could be found.

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 to the current source_index.

Use this with write_file to build an installed gem.

Reads a binary file at path

Reads a Marshal file at path

setup prepares a sandboxed location to install gems. All installs are directed to a temporary directory. All install plugins are removed.

If the RUBY environment variable is set the given path is used for Gem::ruby. The local platform is set to i386-mswin32 for Windows or i686-darwin8.10.1 otherwise.

If the KEEP_FILES environment variable is set the files will not be removed from /tmp/test_rubygems_#{$$}.#{Time.now.to_i}.

teardown restores the process to its original state and removes the tempdir unless the KEEP_FILES environment variable was set.

Builds a gem from spec and places it in File.join @gemhome, ‘cache‘. Automatically creates files based on +spec.files+

Removes all installed gems from +@gemhome+.

Creates a gem with name, version and deps. The specification will be yielded before gem creation for customization. The gem will be placed in File.join @tempdir, ‘gems‘. The specification and .gem file location are returned.

Gzips data.

Creates several default gems which all have a lib/code.rb file. The gems are not installed but are available in the cache dir.

+@a1+:gem a version 1, this is the best-described gem.
+@a2+:gem a version 2
+@a3a:gem a version 3.a
+@a_evil9+:gem a_evil version 9, use this to ensure similarly-named gems don‘t collide with a.
+@b2+:gem b version 2
+@c1_2+:gem c version 1.2
+@pl1+:gem pl version 1, this gem has a legacy platform of i386-linux.

Additional prerelease gems may also be created:

+@a2_pre+:gem a version 2.a

TODO: nuke this and fix tests. this should speed up a lot

Set the platform to arch

Sets up a fake fetcher using the gems from util_make_gems. Optionally additional prerelease gems may be included.

Gems created by this method may be fetched using Gem::RemoteFetcher.

Sets up Gem::SpecFetcher to return information from the gems in specs. Best used with +@all_gems+ from util_setup_fake_fetcher.

Creates a spec with name, version and deps.

Deflates data

Construct a new Gem::Version.

Returns whether or not we‘re on a version of Ruby built with VC++ (or Borland) versus Cygwin, Mingw, etc.

Is this test being run on a Windows platform?

Writes a binary file to path which is relative to +@gemhome+

[Validate]