mirror of
https://github.com/jbranchaud/til
synced 2026-01-20 23:48:02 +00:00
Compare commits
2 Commits
5e63e420bc
...
a726b2ec30
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a726b2ec30 | ||
|
|
7387786343 |
@@ -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).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1338 TILs and counting..._
|
_1340 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)
|
- [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)
|
- [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)
|
- [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)
|
- [Use Specific Cache Store In A Single Test](rspec/use-specific-cache-store-in-a-single-test.md)
|
||||||
|
|
||||||
@@ -1256,6 +1257,7 @@ _1338 TILs and counting..._
|
|||||||
- [Configure cd To Behave Like pushd In Zsh](unix/configure-cd-to-behave-like-pushd-in-zsh.md)
|
- [Configure cd To Behave Like pushd In Zsh](unix/configure-cd-to-behave-like-pushd-in-zsh.md)
|
||||||
- [Copying File Contents To System Paste Buffer](unix/copying-file-contents-to-system-paste-buffer.md)
|
- [Copying File Contents To System Paste Buffer](unix/copying-file-contents-to-system-paste-buffer.md)
|
||||||
- [Copying Nested Directories With Ditto](unix/copying-nested-directories-with-ditto.md)
|
- [Copying Nested Directories With Ditto](unix/copying-nested-directories-with-ditto.md)
|
||||||
|
- [Count The Lines In A CSV Where A Column Is Empty](unix/count-the-lines-in-a-csv-where-a-column-is-empty.md)
|
||||||
- [Count The Number Of Matches In A Grep](unix/count-the-number-of-matches-in-a-grep.md)
|
- [Count The Number Of Matches In A Grep](unix/count-the-number-of-matches-in-a-grep.md)
|
||||||
- [Count The Number Of ripgrep Pattern Matches](unix/count-the-number-of-ripgrep-pattern-matches.md)
|
- [Count The Number Of ripgrep Pattern Matches](unix/count-the-number-of-ripgrep-pattern-matches.md)
|
||||||
- [Create A File Descriptor with Process Substitution](unix/create-a-file-descriptor-with-process-substitution.md)
|
- [Create A File Descriptor with Process Substitution](unix/create-a-file-descriptor-with-process-substitution.md)
|
||||||
|
|||||||
21
rspec/format-test-results-as-a-json-file.md
Normal file
21
rspec/format-test-results-as-a-json-file.md
Normal file
@@ -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.
|
||||||
25
unix/count-the-lines-in-a-csv-where-a-column-is-empty.md
Normal file
25
unix/count-the-lines-in-a-csv-where-a-column-is-empty.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Count The Lines In A CSV Where A Column Is Empty
|
||||||
|
|
||||||
|
The [`xsv` utility](https://github.com/BurntSushi/xsv) is a fast way to analyze
|
||||||
|
and work with CSV files from the command line.
|
||||||
|
|
||||||
|
With the `search` subcommand, I can seach for lines that match a pattern and
|
||||||
|
even narrow that search to focus on a selected column.
|
||||||
|
|
||||||
|
For instance, to search for any lines where column 3 is empty:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ xsv search -s 3 '^$' data.csv
|
||||||
|
```
|
||||||
|
|
||||||
|
The `-s 3` narrows the search to just column 3. The `'^$'` regex pattern
|
||||||
|
matches on cells where there is the start character (`^`) and end character
|
||||||
|
(`$`) with nothing in between, hence empty.
|
||||||
|
|
||||||
|
I can then pipe that to `wc -l` to get a count of the number of empty lines.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ xsv search -s 3 '^$' data.csv | wc -l
|
||||||
|
```
|
||||||
|
|
||||||
|
See `xsv search --help` for more details.
|
||||||
Reference in New Issue
Block a user