You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ KNAPSACK_GENERATE_REPORT=true bundle exec rspec spec/pending_spec.rb
Knapsack report generator started!
Pending
example at ./spec/pending_spec.rb:2 (PENDING: Temporarily skipped with xit)
An error occurred in an `after(:context)` hook.
Failure/Error: raise("test_path needs to be set by Knapsack Adapter's bind method") unless @test_path
RuntimeError:
test_path needs to be set by Knapsack Adapter's bind method
# /Users/artur/Documents/github/knapsack-pro/knapsack/lib/knapsack/tracker.rb:33:in `test_path'
# /Users/artur/Documents/github/knapsack-pro/knapsack/lib/knapsack/tracker.rb:70:in `update_test_file_time'
# /Users/artur/Documents/github/knapsack-pro/knapsack/lib/knapsack/tracker.rb:28:in `stop_timer'
# /Users/artur/Documents/github/knapsack-pro/knapsack/lib/knapsack/adapters/rspec_adapter.rb:24:in `block (2 levels) in bind_time_tracker'
Knapsack report was generated. Preview:
{
}
Knapsack global time execution for tests: 0.0006259996443986893s
Pending: (Failures listed here are expected and do not affect your suite's status)
1) Pending
# Temporarily skipped with xit
# ./spec/pending_spec.rb:2
Finished in 0.05341 seconds (files took 3.58 seconds to load)
1 example, 0 failures, 1 pending, 1 error occurred outside of examples
The crash happens because the test file path was not set.
Test file path is set Knapsack.tracker.test_path only when at least 1 example was executed in the test file. But for pending test file there are no examples executed so the test path is not set. This leads to exception.
If a pending test file is executed after another test file then this can lead to attributing time measured for pending test file to the previously executed test file path.
When generating a JSON report for a pending spec file then knapsack gem crashes.
Here is a project we use for development purpose:
https://github.com/KnapsackPro/rails-app-with-knapsack
It has a pending spec file: KnapsackPro/rails-app-with-knapsack@586ce81
The crash happens because the test file path was not set.
source: https://github.com/KnapsackPro/knapsack/blob/5eb650a71e5df40fb4157afda3dd265c867a162a/lib/knapsack/adapters/rspec_adapter.rb#L7,L31
Problems
Test file path is set
Knapsack.tracker.test_path
only when at least 1 example was executed in the test file. But for pending test file there are no examples executed so the test path is not set. This leads to exception.If a pending test file is executed after another test file then this can lead to attributing time measured for pending test file to the previously executed test file path.
Related
This bug was introduced after merging PR: #107
The text was updated successfully, but these errors were encountered: