lib/testrbl.rb in testrbl-0.7.0 vs lib/testrbl.rb in testrbl-0.8.0

- old
+ new

@@ -112,12 +112,24 @@ end end end def changed_files - changed_files = `git status -s`.split("\n").map { |l| l.strip.split(/\s+/, 2)[1] } - raise "Failed: #{changed_files}" unless $?.success? + changed_files = sh("git status -s").split("\n").map { |l| l.strip.split(/\s+/, 2)[1] } + + if changed_files.empty? + # user wants to test last commit and not current diff + changed_files = sh("git show --name-only").split("\n\n").last.split("\n") + end + + # we only want test files that were added or changed (not deleted) changed_files.select { |f| f =~ /_(test|spec)\.rb$/ && File.exist?(f) } + end + + def sh(command) + result = `#{command}` + raise "Failed: #{command} -> #{result}" unless $?.success? + result end def ruby if File.file?("Gemfile") ["ruby", "-rbundler/setup"] # faster then bundle exec ruby