Class: Dumper::Json

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/flaky/dumper/json.rb

Instance Method Summary collapse

Instance Method Details

#dump!(location, status, tables) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/rspec/flaky/dumper/json.rb', line 7

def dump!(location, status, tables)
  tables.each do |table|
    json = JSON.pretty_generate(table.all.map(&:attributes))
    FileUtils.mkdir_p(dump_path(location, table)) unless File.exists?(dump_path(location, table))
    File.open("#{dump_path(location, table)}/#{status}.json", 'w') do |f|
      f.write(json)
    end
  end
end