-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for empty last_run files for parallel tests that end up running…
… no tests
- Loading branch information
Chad Shaffer
committed
Nov 4, 2016
1 parent
6e5ec23
commit 19bc92e
Showing
3 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require "helper" | ||
|
||
describe SimpleCov::LastRun do | ||
subject { SimpleCov::LastRun } | ||
|
||
it "defines a last_run_path" do | ||
expect(subject.last_run_path).to eq(File.join(SimpleCov.coverage_path, ".last_run.json")) | ||
end | ||
|
||
it "writes json to its last_run_path" do | ||
json = [] | ||
subject.write(json) | ||
expect(File.read(subject.last_run_path).strip).to eq(JSON.pretty_generate(json)) | ||
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(JSON.parse("[]")) | ||
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 if SimpleCov.usable? |