Skip to content

Commit

Permalink
Reworked Test Load-Path Unshifting, keeping it in TestUtil.require() …
Browse files Browse the repository at this point in the history
…as much as possible.
  • Loading branch information
rubyjedi committed Feb 18, 2011
1 parent 7c11418 commit 7d6dbf7
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
2 changes: 0 additions & 2 deletions test/helper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
require 'rubygems' require 'rubygems'
require 'test/unit/xml' ## RubyJedi require 'test/unit/xml' ## RubyJedi


# $:.unshift File.dirname(__FILE__) + '/../lib' # needed for TestMapper under Ruby 1.8

ENV['DEBUG_SOAP4R'] = 'true' ## Needed to force wsdl2ruby.rb and xsd2ruby.rb to use DEVELOPMENT soap4r libs instead of installed soap4r libs ENV['DEBUG_SOAP4R'] = 'true' ## Needed to force wsdl2ruby.rb and xsd2ruby.rb to use DEVELOPMENT soap4r libs instead of installed soap4r libs
4 changes: 2 additions & 2 deletions test/soap/calc/server.cgi
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
$:.unshift File.join(File.dirname(__FILE__), '/../../../lib') $:.unshift File.expand_path(File.dirname(__FILE__)+'/../../../lib')
$:.unshift('.') if RUBY_VERSION.to_f >= 1.9 $:.unshift '.' if RUBY_VERSION.to_f >= 1.9
require 'soap/rpc/cgistub' require 'soap/rpc/cgistub'


class CalcServer < SOAP::RPC::CGIStub class CalcServer < SOAP::RPC::CGIStub
Expand Down
1 change: 0 additions & 1 deletion test/soap/calc/test_calc.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,3 @@
$:.unshift('.')
require 'helper' require 'helper'
require 'testutil' require 'testutil'
require 'soap/wsdlDriver' require 'soap/wsdlDriver'
Expand Down
2 changes: 1 addition & 1 deletion test/soap/header/server.cgi
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
$:.unshift File.join(File.dirname(__FILE__), '/../../../lib') $:.unshift File.expand_path(File.dirname(__FILE__)+'/../../../lib')
require 'pstore' require 'pstore'
require 'soap/rpc/cgistub' require 'soap/rpc/cgistub'
require 'soap/header/simplehandler' require 'soap/header/simplehandler'
Expand Down
2 changes: 1 addition & 1 deletion test/soap/ssl/sslsvr.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
$:.unshift File.join(File.dirname(__FILE__), '/../../../lib') $:.unshift File.expand_path(File.dirname(__FILE__)+'/../../../lib')
require 'webrick/https' require 'webrick/https'
require 'logger' require 'logger'
require 'rbconfig' require 'rbconfig'
Expand Down
18 changes: 13 additions & 5 deletions test/testutil.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ def self.require(dir, *features)
begin begin
# avoid 'already initialized constant FizzBuzz' warning # avoid 'already initialized constant FizzBuzz' warning
silent do silent do
Dir.chdir(dir) do $:.unshift(dir)
$:.unshift('.') if RUBY_VERSION.to_f >= 1.9 features.each do |feature|
features.each do |feature| Kernel.require feature
Kernel.require feature
end
end end
$:.shift
end end

# Dir.chdir(dir) do
# # $:.unshift('.') if RUBY_VERSION.to_f >= 1.9
# features.each do |feature|
# Kernel.require feature
# end
# end
# end

ensure ensure
features.each do |feature| features.each do |feature|
$".delete(feature) $".delete(feature)
Expand Down
3 changes: 1 addition & 2 deletions test/wsdl/marshal/test_wsdlmarshal.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,3 @@
$:.unshift File.dirname(__FILE__)
require 'helper' require 'helper'
require 'testutil' require 'testutil'
require 'wsdl/parser' require 'wsdl/parser'
Expand Down Expand Up @@ -31,7 +30,7 @@ def load(io)
end end
end end


require 'person_org' TestUtil.require(File.dirname(__FILE__), 'person_org')


class Person class Person
def ==(rhs) def ==(rhs)
Expand Down
1 change: 0 additions & 1 deletion test/wsdl/soap/wsdl2ruby/soapenc/test_soapenc.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,3 @@
# $:.unshift File.dirname(__FILE__)
require 'helper' require 'helper'
require 'testutil' require 'testutil'
require 'wsdl/parser' require 'wsdl/parser'
Expand Down
6 changes: 1 addition & 5 deletions test/xsd/xsd2ruby/test_xsd2ruby.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,3 @@
$:.unshift File.dirname(__FILE__)
require 'helper' require 'helper'
require 'testutil' require 'testutil'
require 'wsdl/xmlSchema/xsd2ruby' require 'wsdl/xmlSchema/xsd2ruby'
Expand All @@ -23,10 +22,7 @@ def setup
gen.opt['force'] = true gen.opt['force'] = true
gen.run gen.run
end end
# TestUtil.require(DIR, 'mysample.rb', 'mysample_mapping_registry.rb', 'mysample_mapper.rb') TestUtil.require(DIR, 'mysample.rb', 'mysample_mapping_registry.rb', 'mysample_mapper.rb')
require 'mysample'
require 'mysample_mapping_registry.rb'
require 'mysample_mapper.rb'
end end


def teardown def teardown
Expand Down

0 comments on commit 7d6dbf7

Please sign in to comment.