mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add DSL for be_close
matcher
This commit is contained in:
parent
196b4d97a5
commit
5389a39231
2 changed files with 16 additions and 1 deletions
|
@ -112,7 +112,7 @@ In no particular order, features that have been implemented and are planned:
|
|||
- [ ] Shared examples - `behaves_like`, `include_examples`
|
||||
- [ ] Matchers
|
||||
- [X] Equality matchers - `eq`, `ne`, `be ==`, `be !=`
|
||||
- [ ] Comparison matchers - `lt`, `le`, `gt`, `ge`, `be <`, `be <=`, `be >`, `be >=`, `be_within[.of]`, `be_close`
|
||||
- [X] Comparison matchers - `lt`, `le`, `gt`, `ge`, `be <`, `be <=`, `be >`, `be >=`, `be_within[.of]`, `be_close`
|
||||
- [ ] Type matchers - `be_a`, `respond_to`
|
||||
- [ ] Collection matchers - `contain`, `have`, `contain_exactly[.in_order|.in_any_order]`, `match_array[.in_order|.in_any_order]`, `start_with`, `end_with`, `be_empty`, `has_key`, `has_value`, `all`, `all_satisfy`
|
||||
- [X] Truthy matchers - `be`, `be_true`, `be_truthy`, `be_false`, `be_falsey`, `be_nil`
|
||||
|
|
|
@ -263,6 +263,21 @@ module Spectator::DSL
|
|||
)
|
||||
end
|
||||
|
||||
# Indicates that some value should be within a delta of an expected value.
|
||||
#
|
||||
# Example:
|
||||
# ```
|
||||
# expect(pi).to be_close(3.14159265359, 0.0000001)
|
||||
# ```
|
||||
#
|
||||
# This is functionly equivalent to:
|
||||
# ```
|
||||
# be_within(expected).of(delta)
|
||||
# ```
|
||||
macro be_close(expected, delta)
|
||||
be_within({{delta}}).of({{expected}})
|
||||
end
|
||||
|
||||
# Indicates that some value should or should not be nil.
|
||||
#
|
||||
# Examples:
|
||||
|
|
Loading…
Reference in a new issue