Tips for Job Interviews as a Junior Software Developer Sep 27, 2020
As coding bootcamps such as Coder Academy and General Assembly churn out more and more software developers, and as more and more people…
The other day a colleague asked whether or not it’s possible to have SimpleCov return a group that only contains uncommitted changes.
The answer is yes! After some digging around, we found the following way:
# in spec_helper.rb
SimpleCov.start 'rails' do
add_group 'Changed' do |source_file|
`git ls-files --exclude-standard --others \
&& git diff --name-only \
&& git diff --name-only --cached`.split("\n").detect do |filename|
source_file.filename.ends_with?(filename)
end
end
endBasically use git ls-files --exclude-standard --others for untracked files, git diff --name-only for unstaged files and git diff --name-only --cached for staged files.