Globally Access Variables for All Cucumber Steps from inside Hooks
<p>currently I am loading all YAML files inside Cucumber Hooks like this before- the intention is to ensure we dont code individually for loading YAML files.</p>

<pre><code>@all_Yaml_Files = Dir.entries(@projectData_Path).select {|f| !File.directory? f};
@all_Yaml_Files.each do |file_Name|
    file_Full_Path = @projectData_Path + '/' + file_Name
    instance_variable_set("@" + file_Name.split('.')[0], YAML.load_file(file_Full_Path))
end
</code></pre>

<p>However this code is inside a Before Cucumber Hook. So When the instance variables are loaded they are not available for next scenario. How can I make them run only once and then be available for all scenarios and all features - ie globally. Currently its loading everytime for a scenario.</p>

<pre><code>Before do
....
end
</code></pre>

<p>Note: By doing above , we can directly access a YAML_FileName by @YAML_FileName variable without writing code. Thats my intention. Same happens with all excel files, json files etc etc. They are all called from inside Hooks.</p>