mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Better handling with be
match against Value types and nil
Releates to https://github.com/icy-arctic-fox/spectator/issues/37
This commit is contained in:
parent
99ced17516
commit
a95c5bcab7
2 changed files with 4 additions and 1 deletions
|
@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix usage of `be ===` and `be =~` [#34](https://github.com/icy-arctic-fox/spectator/issues/34)
|
- Fix usage of `be ===` and `be =~` [#34](https://github.com/icy-arctic-fox/spectator/issues/34)
|
||||||
|
- Better handling of the `be(nil)` when used with value types. [#37](https://github.com/icy-arctic-fox/spectator/issues/37)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Elegantly handle missing/undefined methods with `have_attributes` matcher.
|
- Elegantly handle missing/undefined methods with `have_attributes` matcher.
|
||||||
|
|
|
@ -14,7 +14,9 @@ module Spectator::Matchers
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisifed with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
value = expected.value
|
value = expected.value
|
||||||
if value && value.responds_to?(:same?)
|
if value.nil?
|
||||||
|
actual.value.nil?
|
||||||
|
elsif value.responds_to?(:same?)
|
||||||
value.same?(actual.value)
|
value.same?(actual.value)
|
||||||
else
|
else
|
||||||
# Value type (struct) comparison.
|
# Value type (struct) comparison.
|
||||||
|
|
Loading…
Reference in a new issue