Skip to content

Commit

Permalink
rspec order post
Browse files Browse the repository at this point in the history
  • Loading branch information
bugthing committed Oct 19, 2023
1 parent c9b353f commit 5221522
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions _posts/2023-10-19-record-rspec-tests-in-order.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
layout: default
title: Record Rspec tests in order
---
Recently I had a flakey test that only failed when certains where run. So wanted to record which tests run in which order.
Fist I tried just adding to `spec_helper.rb`

```
config.example_status_persistence_file_path = "tmp/last_run_examples.txt"
```

this was easy but did not record the order inwhich the specs ran, so I ended up doing this

```
$files_executed = []
RSpec.configure do |config|
...
config.before(:each) do |example|
$files_executed.add(example.location)
end
config.after(:suite) do
File.write("./tmp/last_specs_run.txt", $files_executed.join(' '))
end
end
```

0 comments on commit 5221522

Please sign in to comment.