$:.unshift(File.dirname(__FILE__)) require 'abstract_unit' class ConfigurationTest < Test::Unit::TestCase def setup super end def teardown super end def test_default_config default_config = Luruju::Configuration.default assert_equal :drb, default_config.access_jruby_with assert_equal 3937, default_config.drb_port assert_equal true, default_config.use_jude_cache end def test_set_config config = Luruju::Configuration.new do |config| config.access_jruby_with = :command config.drb_port = 9999 end assert_equal :command, config.access_jruby_with assert_equal 9999, config.drb_port end def test_access_jruby_with_validate_invarid assert_raise ArgumentError do Luruju::Configuration.new do |config| config.access_jruby_with = :hoge end end end def test_drb_port_validate_invarid assert_raise ArgumentError do Luruju::Configuration.new do |config| config.drb_port = "hoge" end end end def test_install_default Luruju::Configuration.install assert_equal :drb, Luruju.config.access_jruby_with end def test_install_with_arg config = Luruju::Configuration.new do |config| config.access_jruby_with = :command config.use_jude_cache = false end Luruju::Configuration.install config assert_equal :command, Luruju.config.access_jruby_with assert_equal false, Luruju.config.use_jude_cache end def test_install_with_block Luruju::Configuration.install do |config| config.access_jruby_with = :command end assert_equal :command, Luruju.config.access_jruby_with end def test_uninstall Luruju::Configuration.install do |config| config.access_jruby_with = :command end assert_equal :command, Luruju.config.access_jruby_with Luruju::Configuration.uninstall assert_equal :drb, Luruju.config.access_jruby_with end def test_define_method Object.module_eval <<-EOD module Luruju class Configuration define_config :hoge def self.default_hoge() "foo" end end end EOD Luruju::Configuration.install assert_equal "foo", Luruju.config.hoge end module ConfigTest end def test_multiple_configs ConfigTest.class_eval <<-EOD class HogeConfig include Luruju::Configuratable define_config :foo, :default => "bar" end EOD assert_equal :drb, Luruju.config.access_jruby_with assert_equal 3937, Luruju.config.drb_port assert_equal true, Luruju.config.use_jude_cache assert_equal "bar", ConfigTest.config.foo end end p Luruju.parent