How can I get the data from my Rspec tests in JSON format? like, how many tests failed etc.
I know that I can get it if I run Rspec from ruby, as described here I'll just paste the code here for convenience.
run(paths) # runs rspec tests from ruby # source: https://stackoverflow.com/a/10412793/805156 config = RSpec.configuration formatter = RSpec::Core::Formatters::JsonFormatter.new(config.output_stream) # create reporter with json formatter reporter = RSpec::Core::Reporter.new(config) config.instance_variable_set(:@reporter, reporter) # internal hack # api may not be stable, make sure lock down Rspec version loader = config.send(:formatter_loader) notifications = loader.send(:notifications_for, RSpec::Core::Formatters::JsonFormatter) reporter.register_listener(formatter, *notifications) RSpec::Core::Runner.run(paths) formatter.output_hash end Is there a way to write this json output to a file whenever Rspec test suite runs?