Class: RSpec::Signal::Writer
- Inherits:
-
Object
- Object
- RSpec::Signal::Writer
- Defined in:
- lib/rspec/signal/writer.rb
Overview
Puts artifacts on disk.
A run with no failures removes artifacts from previous runs, so an agent can never be handed a stale report that describes failures you already fixed.
Defined Under Namespace
Classes: Result
Constant Summary collapse
Instance Method Summary collapse
- #dir ⇒ Object
-
#initialize(config) ⇒ Writer
constructor
A new instance of Writer.
-
#relative(path) ⇒ Object
Relative to the project root when possible, because that is what you type and what an agent resolves.
- #write(report) ⇒ Object
Constructor Details
#initialize(config) ⇒ Writer
Returns a new instance of Writer.
20 21 22 |
# File 'lib/rspec/signal/writer.rb', line 20 def initialize(config) @config = config end |
Instance Method Details
#dir ⇒ Object
24 |
# File 'lib/rspec/signal/writer.rb', line 24 def dir = @config.output_path |
#relative(path) ⇒ Object
Relative to the project root when possible, because that is what you type and what an agent resolves.
42 43 44 45 |
# File 'lib/rspec/signal/writer.rb', line 42 def relative(path) root = "#{@config.root}/" path.start_with?(root) ? path[root.length..] : path end |
#write(report) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rspec/signal/writer.rb', line 26 def write(report) return clean if report.failures.empty? && report.errors_outside_examples.zero? FileUtils.mkdir_p(dir) write_gitignore markdown = Reporters::Markdown.new(report, @config).render written = [write_file(SIGNAL, markdown)] written.concat(optional_artifacts(report)) stale = MANAGED - written.map { |path| File.basename(path) } Result.new(summary_path: File.join(dir, SIGNAL), written: written, cleaned: remove(stale)) end |