require "helper"

describe SimpleCov::Configuration do
  describe "#tracked_files" do
    context "when configured" do
      let(:glob) { "{app,lib}/**/*.rb" }

      before { SimpleCov.track_files(glob) }

      it "returns the configured glob" do
        expect(SimpleCov.tracked_files).to eq glob
      end

      context "and configured again with nil" do
        before { SimpleCov.track_files(nil) }

        it "returns nil" do
          expect(SimpleCov.tracked_files).to be_nil
        end
      end
    end

    context "when unconfigured" do
      it "returns nil" do
        expect(SimpleCov.tracked_files).to be_nil
      end
    end
  end
end

require "helper"

describe SimpleCov::Configuration do
  let(:config_class) do
    Class.new do
      include SimpleCov::Configuration
    end
  end
  let(:config) { config_class.new }

  describe "#tracked_files" do
    context "when configured" do
      let(:glob) { "{app,lib}/**/*.rb" }
      before { config.track_files(glob) }

      it "returns the configured glob" do
        expect(config.tracked_files).to eq glob
      end

      context "and configured again with nil" do
        before { config.track_files(nil) }

        it "returns nil" do
          expect(config.tracked_files).to be_nil
        end
      end
    end

    context "when unconfigured" do
      it "returns nil" do
        expect(config.tracked_files).to be_nil
      end
    end
  end
end

Adjust spec to not modify global state
Adjust spec to not modify global state

This way the second context is also truly unconfigured, plus
no possible test order shenanigans/global influence.
