require 'spec_helper' require 'fileutils' require 'logger' TMP_DIR = File.dirname(__FILE__) + "/tmp" FileUtils.rm_rf(TMP_DIR) class Rails def self.configuration self.new end def self.logger Logger.new(STDOUT) end def self.root TMP_DIR end def self.env "test" end def middleware self end def use(mod) end end class ActionController class Base end end require 'td/logger/agent/rails' describe TreasureData::Logger::Agent::Rails::Config do before(:each) do FileUtils.rm_rf(TMP_DIR) FileUtils.mkdir_p(TMP_DIR) ENV.delete('TREASURE_DATA_API_KEY') ENV.delete('TREASURE_DATA_DB') end context 'init' do it 'load_env' do ENV['TREASURE_DATA_API_KEY'] = 'test1' ENV['TREASURE_DATA_DB'] = 'db1' c = TreasureData::Logger::Agent::Rails::Config.init c.agent_mode?.should == false c.apikey.should == 'test1' c.database.should == 'db1' c.auto_create_table.should == true end it 'load_file' do FileUtils.mkdir_p("#{TMP_DIR}/config") File.open("#{TMP_DIR}/config/treasure_data.yml", "w") {|f| f.write <