m-spec 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/lib/m-spec/core/expect.rb +3 -1
- data/lib/m-spec/core/helpers/readable.rb +2 -2
- data/lib/m-spec/core/matchers/equal.rb +2 -0
- data/lib/m-spec/core/spec_result.rb +9 -3
- data/lib/m-spec/version.rb +1 -1
- 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: fc075272ba943b898b2c652bbc45a3cd6db679dc8dd3bd2f804599828e685208
|
4
|
+
data.tar.gz: 77ab99a93514f5a12d79c9f4a56b6c183ee337b82743b97b87befc531e0b7e54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0b57b0fe22b468c721a425e481e1cc351615bb49cb403977b06a8272bf6638010b3d60652f42065eb6ebb34f03102d9836ba4615f334e7ec1e212e4ce157475
|
7
|
+
data.tar.gz: d683f6752864c146fc66e8f00922cc026f038fc708b2276c436a7d53b0f1ff556ac21eb65ac44ceb1b847c7782e7785a07f5c564da67266a0f1d3a06f86c26d6
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Mspec
|
2
2
|
|
3
|
-
The lightest-weight spec framework in ruby. Built for learning at [Makers](https://makers.tech).
|
3
|
+
The lightest-weight spec framework in ruby. Built for learning at [Makers](https://makers.tech). You have one matcher, the comparison matcher, and test setup and teardown is your responsibility. For additional features, you must extend the gem.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -37,7 +37,7 @@ describe 'The Animal' do
|
|
37
37
|
expect(animal.roar).to eq "ROAAAARRRR!"
|
38
38
|
end
|
39
39
|
|
40
|
-
it '
|
40
|
+
it 'fails nicely' do
|
41
41
|
animal = Animal.new
|
42
42
|
expect(animal.roar).to eq "little roar!"
|
43
43
|
end
|
@@ -62,14 +62,16 @@ $ m-spec ./spec/animal_spec.rb
|
|
62
62
|
The Animal
|
63
63
|
returns a string
|
64
64
|
fails nicely
|
65
|
-
|
65
|
+
Expected: ROAAAARRRR!
|
66
|
+
Got: little roar!
|
67
|
+
/path/to/directory/spec/animal_spec.rb:11:in `block (2 levels) in <top (required)>'
|
66
68
|
stubbing
|
67
69
|
we can mock too!
|
68
70
|
```
|
69
71
|
|
70
|
-
It's got simple one-level indentation
|
72
|
+
It's got simple one-level indentation, simple colour coding for test passes and failures, and simple failure messages with expected and actual values and the failing spec file path and line number.
|
71
73
|
|
72
|
-
Remember - you'll have to manage test setup and
|
74
|
+
Remember - you'll have to manage test setup and teardown yourself and keeping your test code dry yourself. Make sure each test runs in isolation.
|
73
75
|
|
74
76
|
## Extending
|
75
77
|
|
data/lib/m-spec/core/expect.rb
CHANGED
@@ -13,8 +13,8 @@ def it(str)
|
|
13
13
|
colour_code = COLOUR_CODES[spec_result.success?]
|
14
14
|
puts " \e[#{colour_code}m#{str}\e[0m"
|
15
15
|
unless spec_result.success?
|
16
|
-
spec_result.
|
17
|
-
puts " \e[#{colour_code}m#{
|
16
|
+
spec_result.failure_message.each do |line|
|
17
|
+
puts " \e[#{colour_code}m#{line}\e[0m"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Mspec
|
2
2
|
class SpecResult
|
3
|
-
def initialize(error)
|
3
|
+
def initialize(expectation, matcher, error)
|
4
|
+
@expectation = expectation
|
5
|
+
@matcher = matcher
|
4
6
|
@error = error
|
5
7
|
end
|
6
8
|
|
@@ -8,8 +10,12 @@ module Mspec
|
|
8
10
|
!@error
|
9
11
|
end
|
10
12
|
|
11
|
-
def
|
12
|
-
[
|
13
|
+
def failure_message
|
14
|
+
[
|
15
|
+
" Expected: #{@expectation.value}",
|
16
|
+
" Got: #{@matcher.value}",
|
17
|
+
" #{@error.backtrace[1]}"
|
18
|
+
]
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
data/lib/m-spec/version.rb
CHANGED