describe "DataHelpers::Data" do
  subject { DataHelpers::Data }

  let(:hash_fixture) { { key1: { nested: "ok" } } }

  around(:each) do |example|
    yml_path = File.join(Support::Paths.cucumber_root, "features", "yml")
    expected_path = File.join(yml_path, "data.yml")
    FakeFS::FileSystem.clone(yml_path)

    FakeFS do
      File.open(expected_path, "w") { |f| f.write hash_fixture.to_yaml }
      example.run
    end
  end

  context ".all_data" do
    it "returns a hash" do
      expect(subject.all_data.is_a?(Hash)).to be true
    end

    it 'reads a .yml file named the snake_case\'d class in the yml directory' do
      expect(subject.all_data).to eq hash_fixture
    end

    it "does not back-propagate changes made to a clone" do
      duped = subject.all_data
      duped[:key1][:another] = "this should not be here"
      expect(duped).not_to eq subject.all_data
    end
  end
end
