Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Eliminate constant redef warnings during test runs.

Under ruby 1.8, requires are only tracked by the literal path that's passed
to `require`. This commit ensures that `'composite_primary_keys/version'` is
only ever required by that specific path, preventing its contents from being
redefined when the test suite is loaded.
  • Loading branch information...
1 parent 07389e0 commit df3408db296eca14707161268440d19c1c6bfb40 @rsutphin rsutphin committed
Showing with 5 additions and 4 deletions.
  1. +3 −2 composite_primary_keys.gemspec
  2. +2 −2 test/abstract_unit.rb
5 composite_primary_keys.gemspec
@@ -1,5 +1,6 @@
# Read the current version
-require File.join(File.dirname(__FILE__), 'lib', 'composite_primary_keys', 'version')
+$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
+require 'composite_primary_keys/version' do |s| = 'composite_primary_keys'
@@ -26,4 +27,4 @@ do |s|
# Dependencies
s.required_ruby_version = '>= 1.8.7'
s.add_dependency('activerecord', '~> 3.1.0')
4 test/abstract_unit.rb
@@ -5,8 +5,8 @@
require "./hash_tricks"
# To make debugging easier, test within this source tree versus an installed gem
-#require 'composite_primary_keys'
-require File.join(PROJECT_ROOT, "lib", "composite_primary_keys")
+$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
+require 'composite_primary_keys'
# Now load the connection spec
require File.join(PROJECT_ROOT, "test", "connections", "connection_spec")

0 comments on commit df3408d

Please sign in to comment.
Something went wrong with that request. Please try again.