Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Improve logic that finds the failure line to print. #2088

Merged
merged 4 commits into from
Oct 14, 2015

Conversation

myronmarston
Copy link
Member

  • Introduce project_source_dirs config setting.
  • Look for the first backtrace line in one of the
    project_source_dirs rather than the first line
    from your spec file. This helps in situations where
    you define a helper method in a support file that
    has a failing expectation, and call it from your
    spec. Previously it would have shown the helper
    method call site rather than the expectation in
    the helper method itself.
  • If no backtrace line can be found in a
    project_source_dirs, pick the first backtrace
    line. While we don’t generally want to show lines
    from gems, it’s better than showing no line at all.

Fixes #1991.

- Introduce `project_source_dirs` config setting.
- Look for the first backtrace line in one of the
  `project_source_dirs` rather than the first line
  from your spec file. This helps in situations where
  you define a helper method in a support file that
  has a failing expectation, and call it from your
  spec. Previously it would have shown the helper
  method call site rather than the expectation in
  the helper method itself.
- If no backtrace line can be found in a
  `project_source_dirs`, pick the first backtrace
  line. While we don’t generally want to show lines
  from gems, it’s better than showing no line at all.

Fixes #1991.
@myronmarston myronmarston force-pushed the find-failed-line-improvement branch from 3a38db5 to aadd339 Compare October 14, 2015 06:31
As of rspec/rspec-support#245, `rspec/support/ruby_features`
relies upon `rspec/support` being loaded first.
For some reason, this `load` wasn’t working as written on JRuby.
@myronmarston
Copy link
Member Author

This is green -- anyone from @rspec/rspec want to review it?

and exclude("raise(AssertionFailed, msg)")
end

it "falls back to finding a line in a gem when there are no backtrace lines in the app, lib or spec directories" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat

@xaviershay
Copy link
Member

LGTM, didn't notice anything to improve.

myronmarston added a commit that referenced this pull request Oct 14, 2015
Improve logic that finds the failure line to print.
@myronmarston myronmarston merged commit e37b7b8 into master Oct 14, 2015
@myronmarston myronmarston deleted the find-failed-line-improvement branch October 14, 2015 15:44
myronmarston added a commit to myronmarston/rspec-given that referenced this pull request Jan 12, 2016
RSpec changed how it detects source lines to print in
rspec/rspec-core#2088, which necessitates us configuring
`project_source_dirs` for our specs. (This should not affect
end-users).

In addition, we now print multi-line code snippets as of
rspec/rspec-core#2083. Multiline snippets are not printed
on the same line as `Failure/Error:` so our regex has to
be updated to accommodate a line break.
searls pushed a commit to rspec-given/rspec-given that referenced this pull request Jan 14, 2016
RSpec changed how it detects source lines to print in
rspec/rspec-core#2088, which necessitates us configuring
`project_source_dirs` for our specs. (This should not affect
end-users).

In addition, we now print multi-line code snippets as of
rspec/rspec-core#2083. Multiline snippets are not printed
on the same line as `Failure/Error:` so our regex has to
be updated to accommodate a line break.
MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
Improve logic that finds the failure line to print.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants