title: How to load and read yml fixture files for rspec in ruby
body: <h1>frozen_string_literal: true</h1>
  
  <p>require 'yaml'
  require 'singleton'</p>
  
  <p>module OrionTechCurrencyPlugin
    module Rules
      class RulesLoader
        include Singleton</p>
  
  <pre><code>  PATH = '**/data/**/*.yml'
  
    def initialize
      @rule = load
    end
  
    def fetch(key)
      @rule[key]
    end
  
    private
  
    def load
      hash_def = {}
      files = Dir[PATH]
  
      files.each do |file_name|
        definition = YAML.load_file(file_name).deep_symbolize_keys
        Hash.merge!(definition)
      end
      hash_def
    end
  end
  </code></pre>
  
  <p>end
  end</p>
  
  <p>This is the class i have. I Want to write specs for this class. Earlier i had mocked the load methos but now i want to use fixtures to store the mock data and load and read from those files. </p>
  
  <p>yml files are stored in the folder structure as shown below.
  data
  --test
  test.yml
  test2.yml
  test3.yml</p>
  
  <p>the fixture folder and files are as shown below
  specs
  --main
    --fixtures 
      test.yml
      test1.yml</p>