grumpy_old_man 0.1.1 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/loc +3 -0
- data/bin/standardize +4 -0
- data/lib/grumpy_old_man.rb +27 -15
- data/lib/grumpy_old_man/version.rb +5 -0
- data/spec/grumpy_old_man_spec.rb +9 -7
- metadata +102 -22
- data/Gemfile +0 -9
- data/Gemfile.lock +0 -38
- data/README.md +0 -80
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3dc784fc304a28b294ad90e649b5bcd3d71bed378a0dd8559f21163b0555a2d6
|
4
|
+
data.tar.gz: 44e54ab83d9dd0f3dc92bf8eb45a009d107f5928264ce436a12b8fe5fb6cdbcc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c9dfc1a3c1d10825ce035978773137faa080dea9edbd11ad10f883ed5f9207a61636a4a4adc374e039a7288d20ebf3b9573909536d8ffaa62601808e7fc085c8
|
7
|
+
data.tar.gz: 57a184758e4b5cbe038c98ddb83a76ff5a40e0f9ee6b6e0460c6b0667f47abf61b51281b1a1e802efd25e4565ace91b116e2a2af1c957f2c9aa59c2ebef5d511
|
data/bin/loc
ADDED
data/bin/standardize
ADDED
data/lib/grumpy_old_man.rb
CHANGED
@@ -1,37 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "grumpy_old_man/version"
|
4
|
+
|
1
5
|
# A mixin for RSpec tests that provides old school assert methods.
|
2
6
|
module GrumpyOldMan
|
3
|
-
|
4
7
|
# A simple assert for RSpec.
|
5
8
|
#
|
6
9
|
# @example
|
7
|
-
# assert
|
10
|
+
# assert true
|
8
11
|
#
|
9
12
|
# @example
|
10
13
|
# assert { true.to_s == "true" }
|
11
14
|
#
|
12
15
|
# @param [Object] arg An optional arg to assert as equal to true.
|
13
|
-
def assert(arg=nil)
|
14
|
-
if block_given?
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
def assert(arg = nil)
|
17
|
+
arg = yield if block_given?
|
18
|
+
assert_equal !!arg, true
|
19
|
+
end
|
20
|
+
|
21
|
+
# A simple refute for RSpec.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# refute false
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# refute { false.to_s == "true" }
|
28
|
+
#
|
29
|
+
# @param [Object] arg An optional arg to assert as equal to true.
|
30
|
+
def refute(arg = nil)
|
31
|
+
arg = yield if block_given?
|
32
|
+
assert_equal !!arg, false
|
19
33
|
end
|
20
34
|
|
21
35
|
# A basic assert helper that tests for Object equality.
|
22
36
|
# Tests for object equivalence rather than object identity since this is sufficient for most tests.
|
23
37
|
#
|
24
|
-
# @param [
|
25
|
-
# @param [
|
26
|
-
def assert_equal(
|
27
|
-
|
38
|
+
# @param [Object] actual The Object to compare.
|
39
|
+
# @param [Object] expected The expected value.
|
40
|
+
def assert_equal(actual, expected)
|
41
|
+
expect(actual).to eql(expected)
|
28
42
|
end
|
29
43
|
|
30
44
|
# A basic assert helper that ensures an Error was raised.
|
31
45
|
# @param [Class] ex The expected Exception class.
|
32
46
|
def assert_raise(ex, &block)
|
33
|
-
Proc.new(&block).
|
47
|
+
expect(Proc.new(&block)).to raise_error(ex)
|
34
48
|
end
|
35
|
-
|
36
49
|
end
|
37
|
-
|
data/spec/grumpy_old_man_spec.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("../../lib/grumpy_old_man", __FILE__)
|
2
4
|
|
3
5
|
describe RSpec do
|
4
|
-
# we eat our dog food
|
5
6
|
include GrumpyOldMan
|
6
7
|
|
7
8
|
it "should support assert with GrumpyOldMan" do
|
8
|
-
assert
|
9
|
+
assert true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should support refute with GrumpyOldMan" do
|
13
|
+
refute false
|
9
14
|
end
|
10
15
|
|
11
16
|
it "should support assert_equal with GrumpyOldMan" do
|
12
|
-
assert_equal true,
|
17
|
+
assert_equal true, true
|
13
18
|
end
|
14
19
|
|
15
20
|
it "should support assert_raise with GrumpyOldMan" do
|
16
|
-
assert self.respond_to?(:assert_raise)
|
17
21
|
assert_raise(Exception) { raise }
|
18
22
|
end
|
19
|
-
|
20
23
|
end
|
21
|
-
|
metadata
CHANGED
@@ -1,53 +1,133 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grumpy_old_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Nathan Hopkins
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
date: 2021-05-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: magic_frozen_string_literal
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
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: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: standard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Asserts for RSpec
|
17
98
|
email:
|
18
99
|
- natehop@gmail.com
|
19
100
|
executables: []
|
20
101
|
extensions: []
|
21
102
|
extra_rdoc_files: []
|
22
103
|
files:
|
104
|
+
- bin/loc
|
105
|
+
- bin/standardize
|
23
106
|
- lib/grumpy_old_man.rb
|
24
|
-
-
|
25
|
-
- Gemfile.lock
|
26
|
-
- README.md
|
107
|
+
- lib/grumpy_old_man/version.rb
|
27
108
|
- spec/grumpy_old_man_spec.rb
|
28
|
-
homepage:
|
109
|
+
homepage: https://github.com/hopsoft/grumpy_old_man
|
29
110
|
licenses:
|
30
111
|
- MIT
|
31
|
-
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
32
114
|
rdoc_options: []
|
33
115
|
require_paths:
|
34
116
|
- lib
|
35
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
-
none: false
|
37
118
|
requirements:
|
38
|
-
- -
|
119
|
+
- - ">="
|
39
120
|
- !ruby/object:Gem::Version
|
40
121
|
version: '0'
|
41
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
123
|
requirements:
|
44
|
-
- -
|
124
|
+
- - ">="
|
45
125
|
- !ruby/object:Gem::Version
|
46
126
|
version: '0'
|
47
127
|
requirements: []
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
specification_version: 3
|
128
|
+
rubygems_version: 3.2.15
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
52
131
|
summary: Asserts for RSpec
|
53
|
-
test_files:
|
132
|
+
test_files:
|
133
|
+
- spec/grumpy_old_man_spec.rb
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
albino (1.3.3)
|
5
|
-
posix-spawn (>= 0.3.6)
|
6
|
-
classifier (1.3.3)
|
7
|
-
fast-stemmer (>= 1.0.0)
|
8
|
-
diff-lcs (1.1.3)
|
9
|
-
directory_watcher (1.4.1)
|
10
|
-
fast-stemmer (1.0.1)
|
11
|
-
jekyll (0.11.2)
|
12
|
-
albino (~> 1.3)
|
13
|
-
classifier (~> 1.3)
|
14
|
-
directory_watcher (~> 1.1)
|
15
|
-
kramdown (~> 0.13)
|
16
|
-
liquid (~> 2.3)
|
17
|
-
maruku (~> 0.5)
|
18
|
-
kramdown (0.13.7)
|
19
|
-
liquid (2.4.1)
|
20
|
-
maruku (0.6.0)
|
21
|
-
syntax (>= 1.0.0)
|
22
|
-
posix-spawn (0.3.6)
|
23
|
-
rspec (2.11.0)
|
24
|
-
rspec-core (~> 2.11.0)
|
25
|
-
rspec-expectations (~> 2.11.0)
|
26
|
-
rspec-mocks (~> 2.11.0)
|
27
|
-
rspec-core (2.11.1)
|
28
|
-
rspec-expectations (2.11.2)
|
29
|
-
diff-lcs (~> 1.1.3)
|
30
|
-
rspec-mocks (2.11.2)
|
31
|
-
syntax (1.0.0)
|
32
|
-
|
33
|
-
PLATFORMS
|
34
|
-
ruby
|
35
|
-
|
36
|
-
DEPENDENCIES
|
37
|
-
jekyll
|
38
|
-
rspec
|
data/README.md
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
# Grumpy Old Man
|
2
|
-
|
3
|
-
## Adding old school asserts to RSpec.
|
4
|
-
|
5
|
-
![GrumpyOldMan GEM](http://hopsoft.github.com/grumpy_old_man/images/clint-eastwood.jpg)
|
6
|
-
|
7
|
-
It adds the following methods to RSpec without compromising any of RSpecs awesomeness.
|
8
|
-
|
9
|
-
* `assert`
|
10
|
-
* `assert_equal`
|
11
|
-
* `assert_raise`
|
12
|
-
|
13
|
-
Yes you really can have your cake and eat it too!
|
14
|
-
|
15
|
-
---
|
16
|
-
|
17
|
-
I love several things about RSpec.
|
18
|
-
|
19
|
-
* Its beautiful output from the test runner
|
20
|
-
* Its declarative approach to writing tests... well at least the outer wrapper e.g. `describe Thing; it 'should do stuff'`
|
21
|
-
|
22
|
-
I lament the fact that the rest of RSpec is an over engineered solution to a simple problem:
|
23
|
-
`assert true`
|
24
|
-
|
25
|
-
---
|
26
|
-
|
27
|
-
My contention is that its better to write tests in the same manner you write the app.
|
28
|
-
This approach does away with the context switching between app syntax and a wonky DSL confined to the test suite.
|
29
|
-
|
30
|
-
It also lowers the barrier to entry.
|
31
|
-
|
32
|
-
Consider the following example from the RSpec docs.
|
33
|
-
|
34
|
-
```ruby
|
35
|
-
expect(order.total).to eq(Money.new(5.55, :USD))
|
36
|
-
```
|
37
|
-
|
38
|
-
Rewritten with GrumpyOldMan.
|
39
|
-
```ruby
|
40
|
-
assert order.total == Money.new(5.55, :USD)
|
41
|
-
# or ...
|
42
|
-
assert_equal order.total, Money.new(5.55, :USD)
|
43
|
-
```
|
44
|
-
|
45
|
-
Asserts allow me to write code that more closely resembles the app logic itself... which feels more natural.
|
46
|
-
|
47
|
-
## Usage
|
48
|
-
|
49
|
-
```bash
|
50
|
-
gem install grumpy_old_man
|
51
|
-
```
|
52
|
-
|
53
|
-
Simply include GrumpyOldMan in your spec/test like so.
|
54
|
-
|
55
|
-
```ruby
|
56
|
-
require 'grumpy_old_man'
|
57
|
-
|
58
|
-
describe Thing
|
59
|
-
include GrumpyOldMan
|
60
|
-
|
61
|
-
it "should feel good" do
|
62
|
-
assert true
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should be balanced" do
|
66
|
-
assert_equal true, true
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should be exceptional" do
|
70
|
-
assert_raise(Exception) { raise }
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
```
|
75
|
-
|
76
|
-
You might not agree, but I'm sticking with my old fashioned assert.
|
77
|
-
|
78
|
-
**Now get off my lawn!**
|
79
|
-
|
80
|
-
<a href="https://github.com/hopsoft/grumpy_old_man"><img style="position: fixed; top: 0; right: 0; border: 0; z-index: 9999;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
|