aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/gem_dependency_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/gem_dependency_test.rb')
-rw-r--r--railties/test/gem_dependency_test.rb45
1 files changed, 44 insertions, 1 deletions
diff --git a/railties/test/gem_dependency_test.rb b/railties/test/gem_dependency_test.rb
index 189ad02b76..ff27af5572 100644
--- a/railties/test/gem_dependency_test.rb
+++ b/railties/test/gem_dependency_test.rb
@@ -1,4 +1,5 @@
require 'plugin_test_helper'
+require 'rails/gem_dependency'
class Rails::GemDependency
public :install_command, :unpack_command
@@ -18,7 +19,7 @@ class GemDependencyTest < Test::Unit::TestCase
def test_configuration_adds_gem_dependency
config = Rails::Configuration.new
config.gem "xaws-s3x", :lib => "aws/s3", :version => "0.4.0"
- assert_equal [["install", "xaws-s3x", "--version", '"= 0.4.0"']], config.gems.collect(&:install_command)
+ assert_equal [["install", "xaws-s3x", "--version", '"= 0.4.0"']], config.gems.collect { |g| g.install_command }
end
def test_gem_creates_install_command
@@ -144,4 +145,46 @@ class GemDependencyTest < Test::Unit::TestCase
end
end
+ def test_gem_ignores_development_dependencies
+ dummy_gem = Rails::GemDependency.new "dummy-gem-k"
+ dummy_gem.add_load_paths
+ dummy_gem.load
+ assert_equal 1, dummy_gem.dependencies.size
+ end
+
+ def test_gem_guards_against_duplicate_unpacks
+ dummy_gem = Rails::GemDependency.new "dummy-gem-a"
+ dummy_gem.stubs(:frozen?).returns(true)
+ dummy_gem.expects(:unpack_base).never
+ dummy_gem.unpack
+ end
+
+ def test_gem_does_not_unpack_framework_gems
+ dummy_gem = Rails::GemDependency.new "dummy-gem-a"
+ dummy_gem.stubs(:framework_gem?).returns(true)
+ dummy_gem.expects(:unpack_base).never
+ dummy_gem.unpack
+ end
+
+ def test_gem_from_directory_name
+ dummy_gem = Rails::GemDependency.from_directory_name('dummy-gem-1.1')
+ assert_equal 'dummy-gem', dummy_gem.name
+ assert_equal '= 1.1', dummy_gem.version_requirements.to_s
+ end
+
+ def test_gem_from_invalid_directory_name
+ assert_raises RuntimeError do
+ dummy_gem = Rails::GemDependency.from_directory_name('dummy-gem')
+ end
+ assert_raises RuntimeError do
+ dummy_gem = Rails::GemDependency.from_directory_name('dummy')
+ end
+ end
+
+ def test_gem_determines_build_status
+ assert_equal true, Rails::GemDependency.new("dummy-gem-a").built?
+ assert_equal true, Rails::GemDependency.new("dummy-gem-i").built?
+ assert_equal false, Rails::GemDependency.new("dummy-gem-j").built?
+ end
+
end