expresenter 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +57 -22
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f131ba55891e3abc10e518e86df59ab1ed2051f8c8dcdaddfe06ad40f62bde85
|
4
|
+
data.tar.gz: 1e717b60df591416909fa9d4d1772347924dd99904e2d5f85efb6cfbd4ba0bdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eff6bc9cb5101af90834ee70cc856ddcd3796bb848e0c30eda86227293058dec97bcf401cd8807238282dd790fddb3d7c3792b9a304ddf96866a97c156750663
|
7
|
+
data.tar.gz: 2104cc18ff071a607e8e5a932f5c85c537f06f0f41060a849b4d6954b306e6a00dff1bf4f2f55d1e4647dbeb9b13dd5f9893287e5f531d229b189c10ffa0baa3
|
data/README.md
CHANGED
@@ -26,32 +26,67 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
29
|
+
Assuming that an expectation is an assertion that is either `true` or `false`,
|
30
|
+
qualifying it with `MUST`, `SHOULD` and `MAY`, we can draw up several scenarios:
|
31
|
+
|
32
|
+
| Requirement levels | **MUST** | **SHOULD** | **MAY** |
|
33
|
+
| ------------------------- | -------- | ---------- | ------- |
|
34
|
+
| Implemented & Matched | `true` | `true` | `true` |
|
35
|
+
| Implemented & Not matched | `false` | `true` | `false` |
|
36
|
+
| Implemented & Exception | `false` | `false` | `false` |
|
37
|
+
| Not implemented | `false` | `false` | `true` |
|
38
|
+
|
39
|
+
Then,
|
40
|
+
|
41
|
+
* for a `true` assertion, a `Expresenter::Pass` instance can be returned;
|
42
|
+
* for a `false` assertion, a `Expresenter::Fail` exception can be raised.
|
43
|
+
|
44
|
+
Both class share a common interface.
|
45
|
+
|
46
|
+
Passed expectations can be classified as:
|
47
|
+
|
48
|
+
* ✅ success
|
49
|
+
* ⚠️ warning
|
50
|
+
* 💡 info
|
51
|
+
|
52
|
+
Failed expectations can be classified as:
|
53
|
+
|
54
|
+
* ❌ failure
|
55
|
+
* 💥 error
|
56
|
+
|
57
|
+
## Example
|
58
|
+
|
29
59
|
```ruby
|
30
|
-
result = Expresenter.call(true
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
60
|
+
result = Expresenter.call(true).with(actual: "FOO", error: nil, expected: "foo", got: true, negate: true, valid: true, matcher: :eql, level: :MUST)
|
61
|
+
|
62
|
+
result.failed? # => false
|
63
|
+
result.failure? # => false
|
64
|
+
result.info? # => false
|
65
|
+
result.warning? # => false
|
66
|
+
result.to_sym # => :success
|
67
|
+
result.char # => "."
|
68
|
+
result.emoji # => "✅"
|
69
|
+
result.passed? # => true
|
70
|
+
result.negate? # => true
|
71
|
+
result.error? # => false
|
72
|
+
result.success? # => true
|
73
|
+
result.valid? # => true
|
74
|
+
result.inspect # => "Expresenter::Pass(actual: \"FOO\", error: nil, expected: \"foo\", got: true, matcher: :eql, negate: true, level: :MUST, valid: true)"
|
75
|
+
result.definition # => "eql \"foo\""
|
76
|
+
result.maybe_negate # => " not"
|
77
|
+
result.summary # => "expected \"FOO\" not to eql \"foo\""
|
78
|
+
result.colored_char # => "\e[32m.\e[0m"
|
79
|
+
result.colored_string # => "\e[32mSuccess: expected \"FOO\" not to eql \"foo\".\e[0m"
|
50
80
|
result.message # => "Success: expected \"FOO\" not to eql \"foo\"."
|
51
|
-
|
52
|
-
|
81
|
+
result.to_s # => "Success: expected \"FOO\" not to eql \"foo\"."
|
82
|
+
result.titre # => "Success"
|
53
83
|
```
|
54
84
|
|
85
|
+
### More Examples
|
86
|
+
|
87
|
+
A full list of unit tests can be viewed (and executed) here:
|
88
|
+
[./test.rb](https://github.com/fixrb/expresenter/blob/main/test.rb)
|
89
|
+
|
55
90
|
## Contact
|
56
91
|
|
57
92
|
* Home page: https://github.com/fixrb/expresenter
|