Report failed expectation line

In output listing the failures, the comment line now shows the failed expectation line.
Previously this showed the example's source line.
This commit is contained in:
Michael Miller 2022-01-03 18:47:56 -07:00
parent 66e3155a0d
commit 07aa968d68
No known key found for this signature in database
GPG key ID: AC78B32D30CE34A2
2 changed files with 13 additions and 0 deletions

View file

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- Source line reported by failure list changed to line containing `expect` instead of example start line.
## [0.10.3] - 2021-10-13
### Fixed
- Fixed runtime error with `expect` outside of test block - now gives compilation error.
@ -358,6 +362,7 @@ This has been changed so that it compiles and raises an error at runtime with a
First version ready for public use.
[Unreleased]: https://gitlab.com/arctic-fox/spectator/-/compare/v0.10.3...master
[0.10.3]: https://gitlab.com/arctic-fox/spectator/-/compare/v0.10.2...v0.10.3
[0.10.2]: https://gitlab.com/arctic-fox/spectator/-/compare/v0.10.1...v0.10.2
[0.10.1]: https://gitlab.com/arctic-fox/spectator/-/compare/v0.10.0...v0.10.1

View file

@ -45,5 +45,13 @@ module Spectator::Formatting::Components
io << padding << key.colorize(:red) << ": ".colorize(:red) << value
end
end
# Produces the location line.
# This is where the result was determined.
private def location_line(io)
return unless location = @expectation.location? || @example.location?
line(io) { io << Comment.colorize(location) }
end
end
end