Class: RSpec::Undefined::Reporters::Json
- Inherits:
-
Object
- Object
- RSpec::Undefined::Reporters::Json
- Defined in:
- lib/rspec/undefined/reporters/json.rb
Instance Method Summary collapse
-
#initialize(path, stderr: $stderr) ⇒ Json
constructor
A new instance of Json.
- #write ⇒ Object
Constructor Details
#initialize(path, stderr: $stderr) ⇒ Json
Returns a new instance of Json.
10 11 12 13 |
# File 'lib/rspec/undefined/reporters/json.rb', line 10 def initialize(path, stderr: $stderr) @path = path @stderr = stderr end |
Instance Method Details
#write ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rspec/undefined/reporters/json.rb', line 15 def write entries = RSpec::Undefined.registry.all tmp_path = "#{@path}.tmp.#{Process.pid}" begin write_body(tmp_path, entries) File.rename(tmp_path, @path) rescue SystemCallError, IOError => ex File.delete(tmp_path) if File.exist?(tmp_path) @stderr.puts "[rspec-undefined] failed to write #{@path}: #{ex.}" end end |