Sha256: 846ee8b3ec85b6327583426a0ef456cf3e8f7656fec0be97ad36a11dab70ddfd

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

require "test_helper"

describe YamlToConstants do
  let(:path) { "#{Rails.root}/test/data/config/yaml_autoload" }

  it "responds to load_configurations" do
    YamlToConstants.load_configurations do |config|
      config.directory_load_path= path
      config.recursive = true
    end

    assert_equal path, YamlToConstants.directory_load_path
    YamlToConstants.initilize_all_files
    refute_nil defined?(Configuration::TestA)
    refute_nil defined?(Configuration::TestB)
    refute_nil defined?(Configuration::TestC)
  end
#
#  describe "Once configured with recursive" do
#    before do
#      YamlToConstants.stubs(:initilize_all_files).returns({})
#      YamlToConstants.load_configurations do |config|
#        config.directory_load_path= path
#        config.recursive = true
#      end
#    end
#
#    it "correctly lists files in directory to be loaded" do
#      assert YamlToConstants.recursive?
#      assert_equal Dir.glob(path + "/**/*").select { |fn| File.file?(fn) }, YamlToConstants.loaded_file_paths
#    end
#
#    it "creates objects" do
#      refute_nil defined?(Configuration::TestA)
#      refute_nil defined?(Configuration::TestB)
#      refute_nil defined?(Configuration::TestC)
#      raise YamlToConstants.purge!
#    end
#  end
#
#  describe "Once configured without recursion"  do
#    before do
#      YamlToConstants.load_configurations do |config|
#        config.directory_load_path= path
#        config.recursive = false
#      end
#    end
#
#    it "correctly lists files in directory to be loaded" do
#      refute YamlToConstants.recursive?
#      assert_equal Dir.glob(path).select { |fn| File.file?(fn) }, YamlToConstants.loaded_file_paths
#    end
#
#    it "creates objects from parsed yaml" do
#      refute_nil defined?(Configuration::TestA)
#      refute_nil defined?(Configuration::TestB)
#      refute_nil defined?(Configuration::TestC)
#    end
#  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yaml_constant_creation-0.0.1 test/yaml_to_constants_test.rb