Class: RSpec::Formatter::GitAutoCommitRSpec3

Inherits:
Core::Formatters::BaseTextFormatter
  • Object
show all
Defined in:
lib/rspec/formatter/git_auto_commit_rspec3.rb

Constant Summary collapse

GIT_PROG =
ENV["GIT_BIN"] || "git"

Instance Method Summary collapse

Instance Method Details

#dump_failures(notification) ⇒ Object



13
14
# File 'lib/rspec/formatter/git_auto_commit_rspec3.rb', line 13

def dump_failures(notification)
end

#dump_pending(notification) ⇒ Object



16
17
# File 'lib/rspec/formatter/git_auto_commit_rspec3.rb', line 16

def dump_pending(notification)
end

#dump_summary(summary) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rspec/formatter/git_auto_commit_rspec3.rb', line 22

def dump_summary(summary)
  state = summary.failure_count == 0 ? "[green]" : "[red]"
  duration = "in #{format_duration(summary.duration)}"
  commit_message = [state, summary.summary_line, duration].join(" ")

  unless failed_examples.empty?
    commit_message << "\n\nFailed Examples:\n\n"
    failed_examples.each_with_index do |example, index|
      commit_message << "#{short_padding}#{index.next}) #{example.full_description}\n\n"
    end
  end

  system("#{GIT_PROG} add -u")
  commit_message << "\n\n"
  commit_message << `#{GIT_PROG} diff --cached`

  commit_message << "\n\n"
  commit_message << "File Status:\n"
  commit_message << `#{GIT_PROG} status -s`

  File.popen("#{GIT_PROG} commit -F -", "r+") do |fd|
    fd.write commit_message
    fd.close
  end

  log = `#{GIT_PROG} log --oneline -n 1`
  output.puts "\nAuto committed.\n"

  if summary.failure_count > 0
    color_config = RSpec.configuration.failure_color
  elsif summary.pending_count > 0
    color_config = RSpec.configuration.pending_color
  else
    color_config = RSpec.configuration.success_color
  end
  output.puts color(log, color_config)
end

#message(message) ⇒ Object



10
11
# File 'lib/rspec/formatter/git_auto_commit_rspec3.rb', line 10

def message(message)
end

#seed(notification) ⇒ Object



19
20
# File 'lib/rspec/formatter/git_auto_commit_rspec3.rb', line 19

def seed(notification)
end