m-spec 0.2.2 → 0.2.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: 40b2437fce4d14eb4337f07a9d3f9ee43a9f6dc27591c19c4efadf53d05d83f3
4
- data.tar.gz: 973c37628137445b7fbb1d0645bd657bfa6c6da14ee57426307f4bf0f0dfe3ae
3
+ metadata.gz: 4f6acd7d54cf75d89e1c6775a87596f48765d537726dbde5bfb9f7edbf94d8b3
4
+ data.tar.gz: dc0fc6487f6b34ebb5bed6fad56c1eaf9b8fb7a834d302deeafd95095fa5433a
5
5
  SHA512:
6
- metadata.gz: 1b69cdb674edf1cfc47ffb60c50d6fc6996f3ee49a60211f7941bc697f896514e9c3f62ef8fe77a346371fb2d1c61a830c0b8d792c9fd7bbb4716116efa09da7
7
- data.tar.gz: c12a16300c6fcbb25ac84e5ade3d05ba57f2f830899b78ecbdc2e4ea62b62c80be6c99746130f116b15244a5575613b879444cb4050d21b1da8ca6e98583cebc
6
+ metadata.gz: 709cbf7e8ac930b83c63c575dbac520bdf49d56eaf9c479f917504f1400e0f2f382426cab4639c3ceae3a17b1aa99dee31151aceffdaa441ee3f457ad96a0a1a
7
+ data.tar.gz: d64e4dd9cad0bcd54a0c988fa733d53de9a94df8030605d79c01a03632c29bad3ae5977394b736a403dd5ecd727c6fbb0faa01509b249d552013c63e5dd3184b
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). You have two matchers, an equality matcher and an output matcher, and test setup and teardown is your responsibility. For additional features, you must extend the gem.
3
+ The lightest-weight spec framework in ruby. Built for learning at [Makers](https://makers.tech). You have three matchers, an equality matcher, an output matcher and an error matcher. Test setup and teardown is your responsibility. For additional features, you must extend the gem.
4
4
 
5
5
  ## Installation
6
6
 
@@ -9,6 +9,8 @@ require "m-spec/core/spec_example"
9
9
  require "m-spec/core/specs"
10
10
  require "m-spec/core/matchers/equal"
11
11
  require "m-spec/core/matchers/output"
12
+ require "m-spec/core/matchers/raise_error"
13
+
12
14
  require "m-spec/core/helpers/readable"
13
15
 
14
16
  require "m-spec/mocks/allow"
@@ -38,3 +38,7 @@ end
38
38
  def eq(obj)
39
39
  Mspec::Matchers::Equal.new(obj)
40
40
  end
41
+
42
+ def raise_error(error_class)
43
+ Mspec::Matchers::RaiseError.new(error_class)
44
+ end
@@ -3,7 +3,7 @@ require 'stringio'
3
3
  module Mspec
4
4
  module Matchers
5
5
  class Output
6
- attr_reader :value, :test_code_output_string
6
+ attr_reader :value, :actual
7
7
 
8
8
  def initialize(value)
9
9
  @value = value
@@ -13,9 +13,9 @@ module Mspec
13
13
  output = mock_output do
14
14
  block.call
15
15
  end
16
- @test_code_output_string = output.string
16
+ @actual = output.string
17
17
 
18
- @value == @test_code_output_string
18
+ @value == @actual
19
19
  end
20
20
 
21
21
  private
@@ -0,0 +1,31 @@
1
+ require 'stringio'
2
+
3
+ module Mspec
4
+ module Matchers
5
+ class RaiseError
6
+ attr_reader :value, :actual
7
+
8
+ def initialize(value)
9
+ @value = value
10
+ end
11
+
12
+ def check(block)
13
+ @actual = catch_error do
14
+ block.call
15
+ end
16
+
17
+ @value == @actual
18
+ end
19
+
20
+ private
21
+
22
+ def catch_error(&block)
23
+ begin
24
+ block.call
25
+ rescue StandardError => e
26
+ e.class
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -25,7 +25,7 @@ module Mspec
25
25
 
26
26
  def test_code_result
27
27
  if @test_code.value.is_a?(Proc)
28
- @expected_result.test_code_output_string
28
+ @expected_result.actual
29
29
  else
30
30
  @test_code.value
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module Mspec
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: m-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edward Withers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-17 00:00:00.000000000 Z
11
+ date: 2020-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -76,6 +76,7 @@ files:
76
76
  - lib/m-spec/core/helpers/readable.rb
77
77
  - lib/m-spec/core/matchers/equal.rb
78
78
  - lib/m-spec/core/matchers/output.rb
79
+ - lib/m-spec/core/matchers/raise_error.rb
79
80
  - lib/m-spec/core/spec_error.rb
80
81
  - lib/m-spec/core/spec_example.rb
81
82
  - lib/m-spec/core/spec_result.rb