Sha256: b25ae639b5d910dd8de5a46ece46e4fad6ab69bc1348143c0f21fefe3fac2e24

Contents?: true

Size: 1.18 KB

Versions: 12

Compression:

Stored size: 1.18 KB

Contents

require "helper"

if SimpleCov.usable?
  describe SimpleCov::LastRun do
    subject { SimpleCov::LastRun }

    it "defines a last_run_path" do
      expect(subject.last_run_path).to include "tmp/coverage/.last_run.json"
    end

    it "writes json to its last_run_path that can be parsed again" do
      structure = [{"key" => "value"}]
      subject.write(structure)
      file_contents = File.read(subject.last_run_path)
      expect(JSON.parse(file_contents)).to eq structure
    end

    context "reading" do
      context "but the last_run file does not exist" do
        before { File.delete(subject.last_run_path) if File.exist?(subject.last_run_path) }

        it "returns nil" do
          expect(subject.read).to be_nil
        end
      end

      context "a non empty result" do
        before { subject.write([]) }

        it "reads json from its last_run_path" do
          expect(subject.read).to eq([])
        end
      end

      context "an empty result" do
        before do
          File.open(subject.last_run_path, "w+") do |f|
            f.puts ""
          end
        end

        it "returns nil" do
          expect(subject.read).to be_nil
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 5 rubygems

Version Path
tdiary-5.0.9 vendor/bundle/gems/simplecov-0.14.1/spec/last_run_spec.rb
simplecov-0.15.1 spec/last_run_spec.rb
simplecov-0.15.0 spec/last_run_spec.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/spec/last_run_spec.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/spec/last_run_spec.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/spec/last_run_spec.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/simplecov-0.14.1/spec/last_run_spec.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/simplecov-0.14.1/spec/last_run_spec.rb
simplecov-patched-0.14.3 spec/last_run_spec.rb
simplecov-patched-0.14.2 spec/last_run_spec.rb
simplecov-0.14.1 spec/last_run_spec.rb
simplecov-0.14.0 spec/last_run_spec.rb