2008-03-30 02:17:28 +00:00
|
|
|
require 'plugin_test_helper'
|
|
|
|
|
2008-04-21 17:23:15 +00:00
|
|
|
class Rails::GemDependency
|
|
|
|
public :install_command, :unpack_command
|
|
|
|
end
|
|
|
|
|
2008-03-30 02:17:28 +00:00
|
|
|
uses_mocha "Plugin Tests" do
|
|
|
|
class GemDependencyTest < Test::Unit::TestCase
|
|
|
|
def setup
|
|
|
|
@gem = Rails::GemDependency.new "hpricot"
|
|
|
|
@gem_with_source = Rails::GemDependency.new "hpricot", :source => "http://code.whytheluckystiff.net"
|
|
|
|
@gem_with_version = Rails::GemDependency.new "hpricot", :version => "= 0.6"
|
2008-06-02 14:54:36 +00:00
|
|
|
@gem_with_lib = Rails::GemDependency.new "aws-s3", :lib => "aws/s3"
|
2008-08-02 00:01:10 +00:00
|
|
|
@gem_without_load = Rails::GemDependency.new "hpricot", :lib => false
|
2008-03-30 02:17:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_configuration_adds_gem_dependency
|
|
|
|
config = Rails::Configuration.new
|
|
|
|
config.gem "aws-s3", :lib => "aws/s3", :version => "0.4.0"
|
2008-06-02 14:54:36 +00:00
|
|
|
assert_equal [["install", "aws-s3", "--version", '"= 0.4.0"']], config.gems.collect(&:install_command)
|
2008-03-30 02:17:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_creates_install_command
|
|
|
|
assert_equal %w(install hpricot), @gem.install_command
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_with_source_creates_install_command
|
|
|
|
assert_equal %w(install hpricot --source http://code.whytheluckystiff.net), @gem_with_source.install_command
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_with_version_creates_install_command
|
2008-06-02 14:54:36 +00:00
|
|
|
assert_equal ["install", "hpricot", "--version", '"= 0.6"'], @gem_with_version.install_command
|
2008-03-30 02:17:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_creates_unpack_command
|
|
|
|
assert_equal %w(unpack hpricot), @gem.unpack_command
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_with_version_unpack_install_command
|
Fix a number of errors in the config.gem mechanism.
* Rails::GemDependency was missing definitions for hash and eql?, causing Array#uniq to not work.
* If several versions of a gem are unpacked in vendor, now chooses the highest if no version is specified.
* streamlined add_load_path. Now sets up Rubygems correctly to allow 'gem' to find frozen gems, with
gems frozen to vendor/gems and specifications in vendor/gems/<gem-name>/.specification
* Rails::GemDependency#specification would return a spec for the highest installed version, even for
frozen gems and/or previously loaded lower versions. See in part ticket #1123.
* removed vendor from default_load_paths - it was causing autoloading to append Gems::Gems::<gem-dir> to
constant names
* added additional tests for loading frozen gems.
* incorporates the fix from #1107 for vendor rails
* defers to freeze:gems for handling the Rails framework. gems:unpack WILL NOT place a copy of Rails
in vendor/gems. Should close #1123 completely.
* incorporates, via using the gem loader for frozen gems, fixes corresponding to #227, #324, #362, #527, and #742.
* gem plugins now work the same whether frozen or not. Correctness of the behavior is a matter for another ticket...
Signed-off-by: rick <technoweenie@gmail.com>
2008-10-04 17:51:23 +00:00
|
|
|
# stub out specification method, or else test will fail if hpricot 0.6 isn't installed
|
|
|
|
mock_spec = mock()
|
|
|
|
mock_spec.stubs(:version).returns('0.6')
|
|
|
|
@gem_with_version.stubs(:specification).returns(mock_spec)
|
2008-09-24 16:45:53 +00:00
|
|
|
assert_equal ["unpack", "hpricot", "--version", '= 0.6'], @gem_with_version.unpack_command
|
2008-03-30 02:17:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_adds_load_paths
|
Fix a number of errors in the config.gem mechanism.
* Rails::GemDependency was missing definitions for hash and eql?, causing Array#uniq to not work.
* If several versions of a gem are unpacked in vendor, now chooses the highest if no version is specified.
* streamlined add_load_path. Now sets up Rubygems correctly to allow 'gem' to find frozen gems, with
gems frozen to vendor/gems and specifications in vendor/gems/<gem-name>/.specification
* Rails::GemDependency#specification would return a spec for the highest installed version, even for
frozen gems and/or previously loaded lower versions. See in part ticket #1123.
* removed vendor from default_load_paths - it was causing autoloading to append Gems::Gems::<gem-dir> to
constant names
* added additional tests for loading frozen gems.
* incorporates the fix from #1107 for vendor rails
* defers to freeze:gems for handling the Rails framework. gems:unpack WILL NOT place a copy of Rails
in vendor/gems. Should close #1123 completely.
* incorporates, via using the gem loader for frozen gems, fixes corresponding to #227, #324, #362, #527, and #742.
* gem plugins now work the same whether frozen or not. Correctness of the behavior is a matter for another ticket...
Signed-off-by: rick <technoweenie@gmail.com>
2008-10-04 17:51:23 +00:00
|
|
|
@gem.expects(:gem).with(Gem::Dependency.new(@gem.name, nil))
|
2008-03-30 02:17:28 +00:00
|
|
|
@gem.add_load_paths
|
|
|
|
end
|
2008-06-02 14:54:36 +00:00
|
|
|
|
2008-03-30 02:17:28 +00:00
|
|
|
def test_gem_with_version_adds_load_paths
|
Fix a number of errors in the config.gem mechanism.
* Rails::GemDependency was missing definitions for hash and eql?, causing Array#uniq to not work.
* If several versions of a gem are unpacked in vendor, now chooses the highest if no version is specified.
* streamlined add_load_path. Now sets up Rubygems correctly to allow 'gem' to find frozen gems, with
gems frozen to vendor/gems and specifications in vendor/gems/<gem-name>/.specification
* Rails::GemDependency#specification would return a spec for the highest installed version, even for
frozen gems and/or previously loaded lower versions. See in part ticket #1123.
* removed vendor from default_load_paths - it was causing autoloading to append Gems::Gems::<gem-dir> to
constant names
* added additional tests for loading frozen gems.
* incorporates the fix from #1107 for vendor rails
* defers to freeze:gems for handling the Rails framework. gems:unpack WILL NOT place a copy of Rails
in vendor/gems. Should close #1123 completely.
* incorporates, via using the gem loader for frozen gems, fixes corresponding to #227, #324, #362, #527, and #742.
* gem plugins now work the same whether frozen or not. Correctness of the behavior is a matter for another ticket...
Signed-off-by: rick <technoweenie@gmail.com>
2008-10-04 17:51:23 +00:00
|
|
|
@gem_with_version.expects(:gem).with(Gem::Dependency.new(@gem_with_version.name, @gem_with_version.requirement.to_s))
|
2008-03-30 02:17:28 +00:00
|
|
|
@gem_with_version.add_load_paths
|
|
|
|
end
|
2008-06-02 14:54:36 +00:00
|
|
|
|
2008-03-30 02:17:28 +00:00
|
|
|
def test_gem_loading
|
Fix a number of errors in the config.gem mechanism.
* Rails::GemDependency was missing definitions for hash and eql?, causing Array#uniq to not work.
* If several versions of a gem are unpacked in vendor, now chooses the highest if no version is specified.
* streamlined add_load_path. Now sets up Rubygems correctly to allow 'gem' to find frozen gems, with
gems frozen to vendor/gems and specifications in vendor/gems/<gem-name>/.specification
* Rails::GemDependency#specification would return a spec for the highest installed version, even for
frozen gems and/or previously loaded lower versions. See in part ticket #1123.
* removed vendor from default_load_paths - it was causing autoloading to append Gems::Gems::<gem-dir> to
constant names
* added additional tests for loading frozen gems.
* incorporates the fix from #1107 for vendor rails
* defers to freeze:gems for handling the Rails framework. gems:unpack WILL NOT place a copy of Rails
in vendor/gems. Should close #1123 completely.
* incorporates, via using the gem loader for frozen gems, fixes corresponding to #227, #324, #362, #527, and #742.
* gem plugins now work the same whether frozen or not. Correctness of the behavior is a matter for another ticket...
Signed-off-by: rick <technoweenie@gmail.com>
2008-10-04 17:51:23 +00:00
|
|
|
@gem.expects(:gem).with(Gem::Dependency.new(@gem.name, nil))
|
2008-03-30 02:17:28 +00:00
|
|
|
@gem.expects(:require).with(@gem.name)
|
|
|
|
@gem.add_load_paths
|
|
|
|
@gem.load
|
|
|
|
end
|
2008-06-02 14:54:36 +00:00
|
|
|
|
2008-03-30 02:17:28 +00:00
|
|
|
def test_gem_with_lib_loading
|
Fix a number of errors in the config.gem mechanism.
* Rails::GemDependency was missing definitions for hash and eql?, causing Array#uniq to not work.
* If several versions of a gem are unpacked in vendor, now chooses the highest if no version is specified.
* streamlined add_load_path. Now sets up Rubygems correctly to allow 'gem' to find frozen gems, with
gems frozen to vendor/gems and specifications in vendor/gems/<gem-name>/.specification
* Rails::GemDependency#specification would return a spec for the highest installed version, even for
frozen gems and/or previously loaded lower versions. See in part ticket #1123.
* removed vendor from default_load_paths - it was causing autoloading to append Gems::Gems::<gem-dir> to
constant names
* added additional tests for loading frozen gems.
* incorporates the fix from #1107 for vendor rails
* defers to freeze:gems for handling the Rails framework. gems:unpack WILL NOT place a copy of Rails
in vendor/gems. Should close #1123 completely.
* incorporates, via using the gem loader for frozen gems, fixes corresponding to #227, #324, #362, #527, and #742.
* gem plugins now work the same whether frozen or not. Correctness of the behavior is a matter for another ticket...
Signed-off-by: rick <technoweenie@gmail.com>
2008-10-04 17:51:23 +00:00
|
|
|
@gem_with_lib.expects(:gem).with(Gem::Dependency.new(@gem_with_lib.name, nil))
|
2008-03-30 02:17:28 +00:00
|
|
|
@gem_with_lib.expects(:require).with(@gem_with_lib.lib)
|
|
|
|
@gem_with_lib.add_load_paths
|
|
|
|
@gem_with_lib.load
|
|
|
|
end
|
2008-08-02 00:01:10 +00:00
|
|
|
|
|
|
|
def test_gem_without_lib_loading
|
Fix a number of errors in the config.gem mechanism.
* Rails::GemDependency was missing definitions for hash and eql?, causing Array#uniq to not work.
* If several versions of a gem are unpacked in vendor, now chooses the highest if no version is specified.
* streamlined add_load_path. Now sets up Rubygems correctly to allow 'gem' to find frozen gems, with
gems frozen to vendor/gems and specifications in vendor/gems/<gem-name>/.specification
* Rails::GemDependency#specification would return a spec for the highest installed version, even for
frozen gems and/or previously loaded lower versions. See in part ticket #1123.
* removed vendor from default_load_paths - it was causing autoloading to append Gems::Gems::<gem-dir> to
constant names
* added additional tests for loading frozen gems.
* incorporates the fix from #1107 for vendor rails
* defers to freeze:gems for handling the Rails framework. gems:unpack WILL NOT place a copy of Rails
in vendor/gems. Should close #1123 completely.
* incorporates, via using the gem loader for frozen gems, fixes corresponding to #227, #324, #362, #527, and #742.
* gem plugins now work the same whether frozen or not. Correctness of the behavior is a matter for another ticket...
Signed-off-by: rick <technoweenie@gmail.com>
2008-10-04 17:51:23 +00:00
|
|
|
@gem_without_load.expects(:gem).with(Gem::Dependency.new(@gem_without_load.name, nil))
|
2008-08-02 00:01:10 +00:00
|
|
|
@gem_without_load.expects(:require).with(@gem_without_load.lib).never
|
|
|
|
@gem_without_load.add_load_paths
|
|
|
|
@gem_without_load.load
|
|
|
|
end
|
|
|
|
|
Fix a number of errors in the config.gem mechanism.
* Rails::GemDependency was missing definitions for hash and eql?, causing Array#uniq to not work.
* If several versions of a gem are unpacked in vendor, now chooses the highest if no version is specified.
* streamlined add_load_path. Now sets up Rubygems correctly to allow 'gem' to find frozen gems, with
gems frozen to vendor/gems and specifications in vendor/gems/<gem-name>/.specification
* Rails::GemDependency#specification would return a spec for the highest installed version, even for
frozen gems and/or previously loaded lower versions. See in part ticket #1123.
* removed vendor from default_load_paths - it was causing autoloading to append Gems::Gems::<gem-dir> to
constant names
* added additional tests for loading frozen gems.
* incorporates the fix from #1107 for vendor rails
* defers to freeze:gems for handling the Rails framework. gems:unpack WILL NOT place a copy of Rails
in vendor/gems. Should close #1123 completely.
* incorporates, via using the gem loader for frozen gems, fixes corresponding to #227, #324, #362, #527, and #742.
* gem plugins now work the same whether frozen or not. Correctness of the behavior is a matter for another ticket...
Signed-off-by: rick <technoweenie@gmail.com>
2008-10-04 17:51:23 +00:00
|
|
|
def test_gem_dependencies_compare_for_uniq
|
|
|
|
gem1 = Rails::GemDependency.new "gem1"
|
|
|
|
gem1a = Rails::GemDependency.new "gem1"
|
|
|
|
gem2 = Rails::GemDependency.new "gem2"
|
|
|
|
gem2a = Rails::GemDependency.new "gem2"
|
|
|
|
gem3 = Rails::GemDependency.new "gem2", :version => ">=0.1"
|
|
|
|
gem3a = Rails::GemDependency.new "gem2", :version => ">=0.1"
|
|
|
|
gem4 = Rails::GemDependency.new "gem3"
|
|
|
|
gems = [gem1, gem2, gem1a, gem3, gem2a, gem4, gem3a, gem2, gem4]
|
|
|
|
assert_equal 4, gems.uniq.size
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_load_frozen
|
|
|
|
dummy_gem = Rails::GemDependency.new "dummy-gem-a"
|
|
|
|
dummy_gem.add_load_paths
|
|
|
|
dummy_gem.load
|
|
|
|
assert_not_nil DUMMY_GEM_A_VERSION
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_load_frozen_specific_version
|
|
|
|
dummy_gem = Rails::GemDependency.new "dummy-gem-b", :version => '0.4.0'
|
|
|
|
dummy_gem.add_load_paths
|
|
|
|
dummy_gem.load
|
|
|
|
assert_not_nil DUMMY_GEM_B_VERSION
|
|
|
|
assert_equal '0.4.0', DUMMY_GEM_B_VERSION
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_load_frozen_minimum_version
|
|
|
|
dummy_gem = Rails::GemDependency.new "dummy-gem-c", :version => '>=0.5.0'
|
|
|
|
dummy_gem.add_load_paths
|
|
|
|
dummy_gem.load
|
|
|
|
assert_not_nil DUMMY_GEM_C_VERSION
|
|
|
|
assert_equal '0.6.0', DUMMY_GEM_C_VERSION
|
|
|
|
end
|
|
|
|
|
2008-03-30 02:17:28 +00:00
|
|
|
end
|
2008-06-02 14:54:36 +00:00
|
|
|
end
|