standard_assert 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 101e45d6e7417a8a39df65b88cb1baac4f0704ea17ead5fc9149a4ff3eba27e9
4
+ data.tar.gz: 654e4c80088a7874aa81b61395c8b2352260462b13786aba023e281bce6b6032
5
+ SHA512:
6
+ metadata.gz: 2141b01aee576fca5f5437aa81ddb139577689d3db32d27dc758b10dfd7849ba0b28990476aac83e19c55fd4e7a83e1d94f8959a54bc210358589ee67599310d
7
+ data.tar.gz: 7706a9916d732931c969ca40921482af94d4172bd2fd3bc0c9b7930810bdc963810413cff129a45e504c17e0cf8d3976d1494fd3c8f02faa5b1d493dbc568aa6
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Yuichi Goto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # standard_assert
2
+
3
+ `standard_assert` is a Standard Library-like library for assertions in Ruby.
4
+ It is aimed at encouraging us to use assertion methods anywhere; Not only testing but also production.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'standard_assert'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ ```
17
+ $ bundle
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Use `Assert` module with `extend` or `include` in classes or modules where you want to use assertion methods:
23
+
24
+ ```ruby
25
+ require 'standard_assert'
26
+
27
+ module MyMath
28
+ extend ::Assert
29
+
30
+ module_function def abs(x)
31
+ assert_kind_of(::Numeric, x)
32
+ x > 0 ? x : -x
33
+ end
34
+ end
35
+
36
+ MyMath.abs('42')
37
+ #=> AssertionError:
38
+ # <"42"> was expected to be kind_of?
39
+ # <Numeric> but was
40
+ # <String>.
41
+ ```
42
+
43
+ ## Contributing
44
+
45
+ You should follow the steps below.
46
+
47
+ 1. [Fork the repository](https://help.github.com/articles/fork-a-repo/)
48
+ 2. Create a feature branch: `git checkout -b add-new-feature`
49
+ 3. Commit your changes: `git commit -am 'Add new feature'`
50
+ 4. Push the branch: `git push origin add-new-feature`
51
+ 5. [Send us a pull request](https://help.github.com/articles/about-pull-requests/)
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,3 @@
1
+ require_relative "standard_assert/core_ext/assert"
2
+ require_relative "standard_assert/core_ext/assertion_error"
3
+ require_relative "standard_assert/version"
@@ -0,0 +1,10 @@
1
+ require "test/unit/assertions"
2
+
3
+ module Assert
4
+ %i[public protected private].each do |visibility|
5
+ ::Test::Unit::Assertions.public_send("#{visibility}_instance_methods").each do |name|
6
+ define_method name, ::Test::Unit::Assertions.instance_method(name)
7
+ __send__(visibility, name)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ require "forwardable"
2
+ require "test/unit/assertion-failed-error"
3
+
4
+ class AssertionError < StandardError
5
+ extend ::Forwardable
6
+
7
+ OriginalError = ::Test::Unit::AssertionFailedError
8
+ private_constant :OriginalError
9
+
10
+ def_delegators(
11
+ :@original_error,
12
+ *(OriginalError.instance_methods - superclass.instance_methods)
13
+ )
14
+
15
+ def initialize(message = nil, options = nil)
16
+ @original_error = OriginalError.new(message, options)
17
+ super(@original_error.message)
18
+ end
19
+ end
20
+
21
+ Test::Unit.class_exec do
22
+ remove_const :AssertionFailedError
23
+ const_set :AssertionFailedError, AssertionError
24
+ end
@@ -0,0 +1,3 @@
1
+ module StandardAssert
2
+ VERSION = "0.2.0".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: standard_assert
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - yasaichi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-12-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: "`standard_assert` is a Standard Library-like library for assertions
84
+ in Ruby. It is aimed at encouraging us to use assertion methods anywhere; Not only
85
+ testing but also production."
86
+ email:
87
+ - yasaichi@users.noreply.github.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/standard_assert.rb
96
+ - lib/standard_assert/core_ext/assert.rb
97
+ - lib/standard_assert/core_ext/assertion_error.rb
98
+ - lib/standard_assert/version.rb
99
+ homepage: https://github.com/yasaichi/standard_assert
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.0.1
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Standard Library-like library for assertions in Ruby
122
+ test_files: []