solid_assert 0.8.0 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 092c3b76b199657802d4b86d6116824fa2af9d3f
4
- data.tar.gz: 95d740d95ec68db0322b2bdc7d527b89680059bc
3
+ metadata.gz: 1e4e886c38ff86c869a75fce0ac8da897a043abe
4
+ data.tar.gz: 26f7826d31e506cd3bf45c51a88c42a01463a155
5
5
  SHA512:
6
- metadata.gz: 8c29a0285557dce36c1b6724af7e8db9ea91906e7f2ee3828e491639091c165964f158faeca08d58cd11811ab3d363a787c0f45f41f4591e72be3676efa1afd9
7
- data.tar.gz: bef2daed211dbd168b77f72e84c69a4231deffd29696c38a43864750442ebc604a97a602136baa5093264ff2bcd9772a879602d324f8f4e6188db888d6949b88
6
+ metadata.gz: 3100ef42a3d7b364cc5d063438d670f524191e5db21689bf25737477838978e86bf54f0c42da5bef5536c959ea6abea4e1335a02e6ff4cdd089ea2a2e862ae9c
7
+ data.tar.gz: 03063ace5b4b1ea666538d4bb3323b6134504ac5031046e136c16d11dbf1186751f1d749128a25e6541ef270b9fa5fdaf5dfc89d02c3877f4ce283ba3b49b5a4
data/README.md CHANGED
@@ -33,18 +33,16 @@ SolidAssert.disable_assertions
33
33
 
34
34
  Assertions are disabled by default.
35
35
 
36
- Use `assert` for testing conditions. You can optionally provide an error message,
37
- exception class or exception object.
36
+ Use `assert` for testing conditions. You can optionally provide an error message.
38
37
 
39
38
  ```ruby
40
39
  assert some_string != "some value"
41
40
  assert clients.empty?, "The list must not be empty!"
42
- assert xyz, StandardError.new("This is a custom exception object")
43
- assert abc, CustomErrorClass
44
41
  ```
45
42
 
46
- Use `invariant` for testing blocks of code. This comes handy when testing your assumptions requires several lines of code.
47
- You can provide an optional message (or exception class/object) if you want.
43
+ Use `invariant` for testing blocks of code. This comes handy
44
+ when testing your assumptions requires several lines of code.
45
+ You can provide an optional message too.
48
46
 
49
47
  ```ruby
50
48
  invariant do
@@ -12,20 +12,12 @@ module SolidAssert
12
12
  # Usage:
13
13
  # assert expr # raise SolidAssert::AssertionFailedError if expr is falsy
14
14
  # assert !list.empty?, "The list should not be empty" # optional error message
15
- # assert false, StandardError.new("Not XYZ!") # raise custom exception object
16
- # assert false, CustomError # raise custom exception class
17
15
  #
18
16
  # @param condition A condition to assert
19
- # @param exception An optional error message (or exception)
17
+ # @param message An optional error message
20
18
  # @raise {AssertionFailedError} when the condition is not satisfied
21
- def assert(condition, exception = nil)
22
- if !condition
23
- if exception.kind_of?(Exception) or exception.class.eql?(Class)
24
- raise exception
25
- else
26
- raise SolidAssert::AssertionFailedError.new(exception)
27
- end
28
- end
19
+ def assert(condition, message = nil)
20
+ fail SolidAssert::AssertionFailedError.new(message) if !condition
29
21
  end
30
22
 
31
23
  # Let you {#assert} a block of code.
@@ -45,15 +37,11 @@ module SolidAssert
45
37
  # some_number == other_number
46
38
  # end
47
39
  #
48
- # invariant CustomError do # custom exception class
49
- # ...
50
- # some_number == other_number
51
- # end
52
- #
53
- # @param exception An optional error message (or exception)
40
+ # @param message An optional error message
41
+ # @raise {AssertionFailedError} when the condition is not satisfied
54
42
  # @yield A block of code
55
- def invariant(exception = nil)
56
- assert yield, exception
43
+ def invariant(message = nil)
44
+ assert yield, message
57
45
  end
58
46
  end
59
47
  end
@@ -1,3 +1,3 @@
1
1
  module SolidAssert
2
- VERSION = "0.8.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_assert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jorge Manrubia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-08 00:00:00.000000000 Z
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,7 +68,6 @@ files:
68
68
  - LICENSE.txt
69
69
  - README.md
70
70
  - Rakefile
71
- - bin/console
72
71
  - lib/solid_assert.rb
73
72
  - lib/solid_assert/assert.rb
74
73
  - lib/solid_assert/assertion_failed_error.rb
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "solid_assert"
5
-
6
- require "irb"
7
- IRB.start