spec/lib/ruby-conf_spec.rb in ruby-conf-2.6.4 vs spec/lib/ruby-conf_spec.rb in ruby-conf-2.6.5
- old
+ new
@@ -427,23 +427,23 @@
end
end
end
- describe "Automatically sets the RAILS_CONF variable" do
+ describe "Automatically sets the RUBY_CONF variable" do
after do
dir = Dir["./**/test_conf.rb.tmpl"].first[/^(.*?)\/test_conf.rb.tmpl$/, 1]
- File.delete("#{dir}/test_conf.rb") if File.exists?("#{dir}/test_conf.rb")
+ File.delete("#{dir}/test_conf.rbc") if File.exists?("#{dir}/test_conf.rbc")
end
it "will autoload the first ruby-conf that it can find if none is provided" do
dir = Dir["./**/test_conf.rb.tmpl"].first[/^(.*?)\/test_conf.rb.tmpl$/, 1]
val = Random.rand.to_s
- File.write("#{dir}/test_conf.rb", File.read("#{dir}/test_conf.rb.tmpl").gsub('{{VALUE}}', val))
+ File.write("#{dir}/test_conf.rbc", File.read("#{dir}/test_conf.rb.tmpl").gsub('{{VALUE}}', val))
RUBY_CONF.should be_nil
RUBY_CONF.ident.should == "FOUND AND LOADED BASIC CONFIG #{val}"
loaded = RUBY_CONF.__rc_loaded_conf
@@ -451,11 +451,11 @@
File.mtime(loaded[:path]).to_i.should_not == loaded[:mtime]
RUBY_CONF.ident.should == "FOUND AND LOADED BASIC CONFIG #{val}"
RUBY_CONF.__rc_loaded_conf[:mtime].should == loaded[:mtime]
val = Random.rand.to_s
- File.write("#{dir}/test_conf.rb", File.read("#{dir}/test_conf.rb.tmpl").gsub('{{VALUE}}', val))
+ File.write("#{dir}/test_conf.rbc", File.read("#{dir}/test_conf.rb.tmpl").gsub('{{VALUE}}', val))
FileUtils.touch(loaded[:path], mtime: 100)
RUBY_CONF.ident.should == "FOUND AND LOADED BASIC CONFIG #{val}"
RUBY_CONF.__rc_loaded_conf[:mtime].should_not == loaded[:mtime]
RubyConf.clear
@@ -463,9 +463,18 @@
def self.env() "foo" end
end
::Object.const_defined?(:Rails).should be_true
RUBY_CONF.should be_nil
RUBY_CONF.ident.should == "FOUND AND LOADED RAILS ENV CONFIG #{val}"
+
+ RubyConf.clear
+ module ::Rails
+ def self.env() "bar" end
+ end
+ ::Object.const_defined?(:Rails).should be_true
+ RUBY_CONF.should be_nil
+ RUBY_CONF.ident.should == "FOUND AND LOADED BASIC CONFIG #{val}"
+
end
it "sets the first unnamed config as default" do
RUBY_CONF.should be_nil
first = RubyConf.define { ident "first" }