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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 579272e22679383c17c8c38fc3d9bc51ae815a7c2b598625fade1c56f2602f48
4
- data.tar.gz: 01f4facd9eb3acbbef1c63271180a557f5e5143de5032d765e2d5b73ba7a77f0
3
+ metadata.gz: fc075272ba943b898b2c652bbc45a3cd6db679dc8dd3bd2f804599828e685208
4
+ data.tar.gz: 77ab99a93514f5a12d79c9f4a56b6c183ee337b82743b97b87befc531e0b7e54
5
5
  SHA512:
6
- metadata.gz: 18e74c2c81a2189ba23bf0a64d853e203dd40804be4f591abc0e0e64a857baaa60cf4406110cac864df8a323e0f777d63dab30aacbd8070638fc752362df416c
7
- data.tar.gz: 403789c4529c404b303db5e5d4bf6b39186dcd9c41afc3c648377456e9f1210f886f57295ce922fa193cf4534a8c61c6072484b36bb29c60aa9fed0078894719
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 'gives a lovely red when it fails' do
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
- /path/to/directory/app/spec/animal_spec.rb:11:in block (2 levels) in <top (required)>'
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 and simple colour coding for test passes and failures. Failures will give you only the spec file path and line number.
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 test cleanup yourself, while keeping your test code dry also yourself. Make sure each test runs in isolation.
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
 
@@ -1,5 +1,7 @@
1
1
  module Mspec
2
2
  class Expect
3
+ attr_reader :value
4
+
3
5
  def initialize(value)
4
6
  @value = value
5
7
  end
@@ -11,7 +13,7 @@ module Mspec
11
13
  data = e
12
14
  end
13
15
 
14
- SpecResult.new(data)
16
+ SpecResult.new(self, matcher, data)
15
17
  end
16
18
  end
17
19
  end
@@ -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.simple_stack_trace.each do |stackline|
17
- puts " \e[#{colour_code}m#{stackline}\e[0m"
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
  module Matchers
3
3
  class Equal
4
+ attr_reader :value
5
+
4
6
  def initialize(value)
5
7
  @value = value
6
8
  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 simple_stack_trace
12
- [@error.backtrace[1]]
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
@@ -1,3 +1,3 @@
1
1
  module Mspec
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: m-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edward Withers