diff --git a/README.md b/README.md index 6551daa..9104666 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1338 TILs and counting..._ +_1339 TILs and counting..._ --- @@ -1020,6 +1020,7 @@ _1338 TILs and counting..._ - [Check Specific Arguments To Received Method](rspec/check-specific-arguments-to-received-method.md) - [Find Minimal Set Of Tests Causing A Flicker](rspec/find-minimal-set-of-tests-causing-a-flicker.md) +- [Format Test Results As A JSON File](rspec/format-test-results-as-a-json-file.md) - [Run Tests With Documentation Formatting](rspec/run-tests-with-documentation-formatting.md) - [Use Specific Cache Store In A Single Test](rspec/use-specific-cache-store-in-a-single-test.md) diff --git a/rspec/format-test-results-as-a-json-file.md b/rspec/format-test-results-as-a-json-file.md new file mode 100644 index 0000000..c4be6a0 --- /dev/null +++ b/rspec/format-test-results-as-a-json-file.md @@ -0,0 +1,21 @@ +# Format Test Results As A JSON File + +The most common output format for RSpec test results is _progress_ which shows +the dot (`.`) or `F` for each test pass and fail. RSpec supports other formats, +including JSON. + +You'd typically want to use the JSON format when you want to programmatically +work with the results. And the results would be most accessible if they ended +up in a file. + +So, when formatting the results to JSON, we typically also want to specify an +output file. We'll need to use two flags — `--format` and `--out`. + +```bash +$ rspec --format json --out test_run_1.json +``` + +When this test run completes, we will have the results in JSON format in the +newly created `test_run_1.json` file in the current directory. + +See `rspec --help` for more details.