0
votes

I am trying to create a program using ruby and guard to watch .rb files in a directory for changes, then on change I would like to run a set of Rspec specs and capture the results of the specs.

I have it set up to watch the appropriate files, run the specs, and output the spec results as a json string into the guard terminal. How can I capture that json string to analyze in another ruby file?

Guardfile:

guard :rspec, :cli => "--format json" do
  watch(%r{^*\.rb}) { "spec" }
end
1
Are you wanting to capture all Guard output or just the JSON? - FluffyJack
I just want to capture the JSON string that holds the rspec results. - allareri
If you're running it pragmatically with ruby store it in a variable and write it out. If you're doing it with a system command, just use the file feed thing command < the_file. - FluffyJack
Can you please post your code? - FluffyJack
edit: Posted the Guardfile. - allareri

1 Answers

0
votes

Try this:

guard :rspec, :cli => "--format json < ./tmp/spec_results.json" do
  watch(%r{^*\.rb}) { "spec" }
end