augmented 0.2.1 → 0.2.2

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
- SHA1:
3
- metadata.gz: a9a3e2008882b819fbc6dc68c9362aeaf6248d19
4
- data.tar.gz: bb67deffad6d08202a575e58c7df7f21319439ae
2
+ SHA256:
3
+ metadata.gz: d8cd8a8566eb16186e26909a2c32597cb2cf8d0e12e2f6785a55fa2cc43992ab
4
+ data.tar.gz: b19a9fd510664c6dc52e99b98ebf0faa5bc70c8c061143b7c4e57addb84f261f
5
5
  SHA512:
6
- metadata.gz: fb0a1f8b46a34bb071478f515a981634f57e4b73791fcf139d51475cebd6cd79c7236f23b1d9b094dd09042cb703c9e78fc58b7dfd2386ab402b88514cb3608c
7
- data.tar.gz: 24f16b6a859d76cab7d6f3befd0f2c665bb568d7a7ed2d50a946d3fc13e22ac2aaa6278ac0e27bf25989c1401af3477e000b0f734069cdd7e3c732640009d1a6
6
+ metadata.gz: de5a4fde6a7325acd6d90008bd4f7895da85a87b71691d4c7cc5cbb81b798576f46b34621cbd9f0857c6ae087ab7e684855d839b97885ad7f127118a00e92f88
7
+ data.tar.gz: f6185c773e2af7676f35e07d0732305bfc7c5882109a0248db835c77ebd41c361ee8946cc66dcdced3b3087fcfc14b8c6953299eea677e8b08019f70983323cd
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  `Augmented` is a library with some core-type utility methods that I frequently find myself copying across projects. It uses refinements instead of class modification for maximum control and an easy sleep at night.
4
4
 
5
- Many of the methods in `Augmented` facilitate a more functional style of programming and cover a few tiny gaps in Ruby's solid functional support. See more thoughts on this [blog post](http://blog.brunze.com/2015/using-ruby-refinements-fun-flow/).
5
+ Many of the methods in `Augmented` facilitate a more functional style of programming and cover a few tiny gaps in Ruby's solid functional support.
6
6
 
7
7
 
8
8
  ## Installation
@@ -18,6 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "bundler", "~> 2.1"
22
+ spec.add_development_dependency "rake", ">= 12.3.3"
23
23
  end
@@ -7,7 +7,7 @@ module Augmented
7
7
  raise ArgumentError, 'you must provide a non-nil tie object or block' if object.nil? && !block_given?
8
8
 
9
9
  tie_function = block_given? ? block : proc{ object }
10
- ties = self.each_cons(2).map &tie_function
10
+ ties = self.each_cons(2).map(&tie_function)
11
11
 
12
12
  self.zip(ties).flatten(1)[0...-1]
13
13
  end
@@ -7,14 +7,14 @@ module Augmented
7
7
  ensure_array = -> thing { thing.kind_of?(Array) ? thing : Array[thing] }
8
8
 
9
9
  if self.respond_to? :each
10
- self.map{ |thing| thing.pick *picks }
10
+ self.map{ |thing| thing.pick(*picks) }
11
11
  else
12
12
  picks.each_with_object({}) do |pick, result|
13
13
 
14
14
  if pick.kind_of? Hash
15
15
 
16
16
  pick.each do |attribute, nested_picks|
17
- result[attribute] = self.__send__(attribute.to_sym).pick *ensure_array[nested_picks]
17
+ result[attribute] = self.__send__(attribute.to_sym).pick(*ensure_array[nested_picks])
18
18
  end
19
19
 
20
20
  else
@@ -1,9 +1,9 @@
1
1
  module Augmented
2
2
  module Procs
3
3
  module Rescuable
4
- refine Proc do
4
+ NOT_PROVIDED = Object.new
5
5
 
6
- NOT_PROVIDED = Object.new
6
+ refine Proc do
7
7
 
8
8
  def rescues exception_class, return_value = NOT_PROVIDED, &block
9
9
  raise ArgumentError, 'must provide a return value or block' if return_value == NOT_PROVIDED && !block_given?
@@ -12,7 +12,7 @@ module Augmented
12
12
 
13
13
  Proc.new do |*args|
14
14
  begin
15
- original.call *args
15
+ original.call(*args)
16
16
  rescue exception_class => exception
17
17
  block ? block.call(exception) : return_value
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module Augmented
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -12,15 +12,15 @@ describe Augmented::Arrays::Tieable do
12
12
  object = Object.new
13
13
  weaved = %w(a b c).tie object
14
14
 
15
- weaved.must_equal ['a', object, 'b', object, 'c']
15
+ assert_equal weaved, ['a', object, 'b', object, 'c']
16
16
  end
17
17
 
18
18
  it 'returns an empty array if the original array is empty' do
19
- [].tie(1).must_equal []
19
+ assert_equal [].tie(1), []
20
20
  end
21
21
 
22
22
  it 'returns the original array if it has only one element' do
23
- [42].tie(1).must_equal [42]
23
+ assert_equal [42].tie(1), [42]
24
24
  end
25
25
 
26
26
  end
@@ -31,34 +31,34 @@ describe Augmented::Arrays::Tieable do
31
31
  values = [10 ,20].each
32
32
  weaved = %w(a b c).tie{ values.next }
33
33
 
34
- weaved.must_equal ['a', 10, 'b', 20, 'c']
34
+ assert_equal weaved, ['a', 10, 'b', 20, 'c']
35
35
  end
36
36
 
37
37
  it 'passes both neighbour values as arguments to the supplied block' do
38
38
  weaved = [1, 5, 12].tie{ |a, b| a + b }
39
39
 
40
- weaved.must_equal [1, 6, 5, 17, 12]
40
+ assert_equal weaved, [1, 6, 5, 17, 12]
41
41
  end
42
42
 
43
43
  it 'will weave nils if the block does not return anything else' do
44
44
  weaved = [1, 2, 3].tie{}
45
45
 
46
- weaved.must_equal [1, nil, 2, nil, 3]
46
+ assert_equal weaved, [1, nil, 2, nil, 3]
47
47
  end
48
48
 
49
49
  it 'returns an empty array if the original arrays is empty' do
50
- [].tie{ 1 }.must_equal []
50
+ assert_equal [].tie{ 1 }, []
51
51
  end
52
52
 
53
53
  it 'returns the original array if it has only one element' do
54
- [42].tie{ 1 }.must_equal [42]
54
+ assert_equal [42].tie{ 1 }, [42]
55
55
  end
56
56
 
57
57
  end
58
58
 
59
59
  it 'raises an ArgumentError if not passed a non-nil object or block' do
60
- proc{ [].tie }.must_raise ArgumentError
61
- proc{ [].tie nil }.must_raise ArgumentError
60
+ assert_raises(ArgumentError){ [].tie }
61
+ assert_raises(ArgumentError){ [].tie nil }
62
62
  end
63
63
 
64
64
  end
@@ -7,7 +7,7 @@ describe Augmented::Enumerators::Indexing do
7
7
  describe '#index_by' do
8
8
 
9
9
  it 'returns a hash keyed by the results of invoking the criterion on every collection element and the values are the last element matching the criterion' do
10
- ['a', 'bbb', 'c', 'dd'].to_enum.index_by(&:length).must_equal({ 1 => 'c', 2 => 'dd', 3 => 'bbb' })
10
+ assert_equal ['a', 'bbb', 'c', 'dd'].to_enum.index_by(&:length), ({ 1 => 'c', 2 => 'dd', 3 => 'bbb' })
11
11
  end
12
12
 
13
13
  end
@@ -7,14 +7,14 @@ describe Augmented::Hashes::Mappable do
7
7
  describe '#map_values' do
8
8
 
9
9
  it 'returns a new hash with the same keys but transformed values' do
10
- { aa: 11, bb: 22 }.map_values{ |i| i * 3 }.must_equal({ aa: 33, bb: 66 })
10
+ assert_equal ({ aa: 11, bb: 22 }.map_values{ |i| i * 3 }), ({ aa: 33, bb: 66 })
11
11
  end
12
12
 
13
13
  it 'also provides the key and hash to the tranformer function as additional arguments' do
14
14
  hash = { aa: 11, bb: 22 }
15
15
  result = hash.map_values{ |i, key, h| [key, h.object_id] }
16
16
 
17
- result.values.must_equal [[:aa, hash.object_id], [:bb, hash.object_id]]
17
+ assert_equal result.values, [[:aa, hash.object_id], [:bb, hash.object_id]]
18
18
  end
19
19
 
20
20
  end
@@ -22,14 +22,14 @@ describe Augmented::Hashes::Mappable do
22
22
  describe '#map_keys' do
23
23
 
24
24
  it 'returns a new hash with the same values but transformed keys' do
25
- { aa: 11, bb: 22 }.map_keys{ |k| k.to_s[0] }.must_equal({ 'a' => 11, 'b' => 22 })
25
+ assert_equal ({ aa: 11, bb: 22 }.map_keys{ |k| k.to_s[0] }), ({ 'a' => 11, 'b' => 22 })
26
26
  end
27
27
 
28
28
  it 'also provides the value and hash to the tranformer function as additional arguments' do
29
29
  hash = { aa: 11, bb: 22 }
30
30
  result = hash.map_keys{ |k, value, h| [value, h.object_id] }
31
31
 
32
- result.keys.must_equal [[11, hash.object_id], [22, hash.object_id]]
32
+ assert_equal result.keys, [[11, hash.object_id], [22, hash.object_id]]
33
33
  end
34
34
 
35
35
  end
@@ -10,34 +10,34 @@ describe Augmented::Hashes::Polymorphable do
10
10
  it 'returns an object of the class specified by the `:type` attribute, initialized with the hash itself' do
11
11
  object = { type: 'OpenStruct', speak: 'meeehh' }.polymorph
12
12
 
13
- object.must_be_instance_of OpenStruct
14
- object.speak.must_equal 'meeehh'
13
+ assert_instance_of OpenStruct, object
14
+ assert_equal object.speak, 'meeehh'
15
15
  end
16
16
 
17
17
  describe 'type attribute' do
18
18
 
19
19
  it 'can also be a string key in the hash' do
20
- { 'type' => 'OpenStruct' }.polymorph.must_be_instance_of OpenStruct
20
+ assert_instance_of OpenStruct, { 'type' => 'OpenStruct' }.polymorph
21
21
  end
22
22
 
23
23
  it 'can be an arbitrary attribute in the hash' do
24
- { lorem_ipsum: 'OpenStruct' }.polymorph(:lorem_ipsum).must_be_instance_of OpenStruct
25
- { 'lorem_ipsum' => 'OpenStruct' }.polymorph(:lorem_ipsum).must_be_instance_of OpenStruct
24
+ assert_instance_of OpenStruct, { lorem_ipsum: 'OpenStruct' }.polymorph(:lorem_ipsum)
25
+ assert_instance_of OpenStruct, { 'lorem_ipsum' => 'OpenStruct' }.polymorph(:lorem_ipsum)
26
26
  end
27
27
 
28
28
  it 'can be a class' do
29
- { type: OpenStruct }.polymorph().must_be_instance_of OpenStruct
29
+ assert_instance_of OpenStruct, { type: OpenStruct }.polymorph()
30
30
  end
31
31
 
32
32
  it 'can be a class passed directly to the method, ignoring the type attribute in the hash' do
33
- { type: 'TotallyIgnoredClass' }.polymorph(OpenStruct).must_be_instance_of OpenStruct
33
+ assert_instance_of OpenStruct, { type: 'TotallyIgnoredClass' }.polymorph(OpenStruct)
34
34
  end
35
35
 
36
36
  end
37
37
 
38
38
  it 'raises an error if it cannot find a type class' do
39
- proc{ {}.polymorph }.must_raise ArgumentError
40
- proc{ { type: nil }.polymorph }.must_raise ArgumentError
39
+ assert_raises(ArgumentError){ {}.polymorph }
40
+ assert_raises(ArgumentError){ { type: nil }.polymorph }
41
41
  end
42
42
 
43
43
  end
@@ -12,8 +12,8 @@ describe Augmented::Hashes::Transformable do
12
12
 
13
13
  new_hash = hash.transform thing1: -> i { i * 3 }, thing2: :random_method_name
14
14
 
15
- new_hash[:thing1].must_equal 300
16
- new_hash[:thing2].must_equal 900
15
+ assert_equal new_hash[:thing1], 300
16
+ assert_equal new_hash[:thing2], 900
17
17
 
18
18
 
19
19
  # mutable version test:
@@ -21,8 +21,8 @@ describe Augmented::Hashes::Transformable do
21
21
 
22
22
  hash.transform! thing1: -> i { i * 3 }, thing2: :random_method_name
23
23
 
24
- hash[:thing1].must_equal 300
25
- hash[:thing2].must_equal 900
24
+ assert_equal hash[:thing1], 300
25
+ assert_equal hash[:thing2], 900
26
26
  end
27
27
 
28
28
  it 'applies procables recursively when given a hash' do
@@ -30,7 +30,7 @@ describe Augmented::Hashes::Transformable do
30
30
 
31
31
  new_hash = hash.transform({ a: { b: { c: -> i { i * 3 } } } })
32
32
 
33
- new_hash[:a][:b][:c].must_equal 300
33
+ assert_equal new_hash[:a][:b][:c], 300
34
34
 
35
35
 
36
36
  # mutable version test:
@@ -38,7 +38,7 @@ describe Augmented::Hashes::Transformable do
38
38
 
39
39
  hash.transform!({ a: { b: { c: -> i { i * 3 } } } })
40
40
 
41
- hash[:a][:b][:c].must_equal 300
41
+ assert_equal hash[:a][:b][:c], 300
42
42
  end
43
43
 
44
44
  it 'applies procables to all elements of a collection if a value is iterable (iterable MUST be a collection of hashes)' do
@@ -46,7 +46,7 @@ describe Augmented::Hashes::Transformable do
46
46
 
47
47
  new_hash = hash.transform(a: { my_value: -> i { i * 3 } })
48
48
 
49
- new_hash[:a].must_equal [ { my_value: 30 }, { my_value: 60 } ]
49
+ assert_equal new_hash[:a], [ { my_value: 30 }, { my_value: 60 } ]
50
50
 
51
51
 
52
52
  # mutable version test:
@@ -54,7 +54,7 @@ describe Augmented::Hashes::Transformable do
54
54
 
55
55
  hash.transform!(a: { my_value: -> i { i * 3 } })
56
56
 
57
- hash[:a].must_equal [ { my_value: 30 }, { my_value: 60 } ]
57
+ assert_equal hash[:a], [ { my_value: 30 }, { my_value: 60 } ]
58
58
  end
59
59
 
60
60
  it 'can apply several procables to a value, supplied in an array, executed from left to right' do
@@ -65,7 +65,7 @@ describe Augmented::Hashes::Transformable do
65
65
 
66
66
  new_hash = hash.transform a: [ :to_i, add_ten, double ]
67
67
 
68
- new_hash[:a].must_equal 24
68
+ assert_equal new_hash[:a], 24
69
69
 
70
70
 
71
71
  # mutable version test:
@@ -73,14 +73,14 @@ describe Augmented::Hashes::Transformable do
73
73
 
74
74
  hash.transform! a: [ :to_i, add_ten, double ]
75
75
 
76
- hash[:a].must_equal 24
76
+ assert_equal hash[:a], 24
77
77
  end
78
78
 
79
79
  it 'returns itself (mutable version only)' do
80
80
  hash = {}
81
81
  same_hash = hash.transform! Hash.new
82
82
 
83
- same_hash.object_id.must_equal hash.object_id
83
+ assert_equal same_hash.object_id, hash.object_id
84
84
  end
85
85
 
86
86
  end
@@ -9,18 +9,20 @@ describe Augmented::Modules::Refined do
9
9
  before do
10
10
  class TesterClass
11
11
  using refined String,
12
- as_phrase: -> { self.capitalize.gsub /\.?\z/, '.' },
12
+ as_phrase: -> { self.capitalize.gsub(/\.?\z/, '.') },
13
13
  fill: -> filler { (filler * self.length)[0..length] }
14
14
 
15
15
  def do_test
16
- 'hello world'.as_phrase.must_equal 'Hello world.'
17
- 'hello world'.fill('!').must_equal '!!!!!!!!!!!'
16
+ [
17
+ 'hello world'.as_phrase == 'Hello world.',
18
+ 'hello world'.fill('!') == '!!!!!!!!!!!',
19
+ ]
18
20
  end
19
21
  end
20
22
  end
21
23
 
22
24
  it 'creates a refinement module on the fly for the given class, with the procs supplied' do
23
- TesterClass.new.do_test
25
+ assert_equal TesterClass.new.do_test, [true, true]
24
26
  end
25
27
 
26
28
  end
@@ -10,18 +10,18 @@ describe Augmented::Objects::Iffy do
10
10
  subject = 'abc'
11
11
  condition = -> subj { subj.length == 3 }
12
12
 
13
- subject.if(true).must_be_same_as subject
14
- subject.if(Object.new).must_be_same_as subject
15
- subject.if(&condition).must_be_same_as subject
13
+ assert_same subject.if(true), subject
14
+ assert_same subject.if(Object.new), subject
15
+ assert_same subject.if(&condition), subject
16
16
  end
17
17
 
18
18
  it 'returns nil if the condition evaluates to falsy' do
19
19
  subject = 'abc'
20
20
  condition = -> subj { subj.length == 0 }
21
21
 
22
- subject.if(false).must_be_same_as nil
23
- subject.if(nil).must_be_same_as nil
24
- subject.if(&condition).must_be_same_as nil
22
+ assert_nil subject.if(false)
23
+ assert_nil subject.if(nil)
24
+ assert_nil subject.if(&condition)
25
25
  end
26
26
 
27
27
  end
@@ -32,18 +32,18 @@ describe Augmented::Objects::Iffy do
32
32
  subject = 'abc'
33
33
  condition = -> subj { subj.length == 0 }
34
34
 
35
- subject.unless(false).must_be_same_as subject
36
- subject.unless(nil).must_be_same_as subject
37
- subject.unless(&condition).must_be_same_as subject
35
+ assert_same subject.unless(false), subject
36
+ assert_same subject.unless(nil), subject
37
+ assert_same subject.unless(&condition), subject
38
38
  end
39
39
 
40
40
  it 'returns nil if the condition evaluates to truish' do
41
41
  subject = 'abc'
42
42
  condition = -> subj { subj.length == 3 }
43
43
 
44
- subject.unless(true).must_be_same_as nil
45
- subject.unless(Object.new).must_be_same_as nil
46
- subject.unless(&condition).must_be_same_as nil
44
+ assert_nil subject.unless(true)
45
+ assert_nil subject.unless(Object.new)
46
+ assert_nil subject.unless(&condition)
47
47
  end
48
48
 
49
49
  end
@@ -53,15 +53,15 @@ describe Augmented::Objects::Iffy do
53
53
  it 'returns the alternative if the object is falsy' do
54
54
  alternative = Object.new
55
55
 
56
- false.else(alternative).must_be_same_as alternative
57
- nil.else(alternative).must_be_same_as alternative
56
+ assert_same false.else(alternative), alternative
57
+ assert_same nil.else(alternative), alternative
58
58
  end
59
59
 
60
60
  it 'returns the object if the object is truish' do
61
61
  subject = Object.new
62
62
 
63
- true.else(123).must_be_same_as true
64
- subject.else(123).must_be_same_as subject
63
+ assert_same true.else(123), true
64
+ assert_same subject.else(123), subject
65
65
  end
66
66
 
67
67
  end
@@ -10,29 +10,29 @@ describe Augmented::Objects::Pickable do
10
10
  it 'returns a hash with the results of invoking the list of picks in the target' do
11
11
  target = OpenStruct.new aaa: 111, bbb: 222, ccc: 333
12
12
 
13
- target.pick(:aaa, :ccc).must_equal({ aaa: 111, ccc: 333 })
13
+ assert_equal target.pick(:aaa, :ccc), { aaa: 111, ccc: 333 }
14
14
  end
15
15
 
16
16
  it 'returns the result of invoking `pick` on every element of an enumerable target' do
17
17
  target = [ OpenStruct.new(val: 11), OpenStruct.new(val: 22), OpenStruct.new(val: 33) ]
18
18
 
19
- target.pick(:val).must_equal [{val: 11}, {val: 22}, {val: 33}]
19
+ assert_equal target.pick(:val), [{val: 11}, {val: 22}, {val: 33}]
20
20
  end
21
21
 
22
22
  it 'applies picks recursively when provided with hashes' do
23
23
  target = OpenStruct.new(aa: (OpenStruct.new bb: (OpenStruct.new cc: 33)))
24
24
 
25
- target.pick(aa: { bb: :cc }).must_equal({ aa: { bb: { cc: 33 } } })
25
+ assert_equal target.pick(aa: { bb: :cc }), { aa: { bb: { cc: 33 } } }
26
26
 
27
27
  target = OpenStruct.new(dd: OpenStruct.new(ee: 55), ff: OpenStruct.new(gg: 77))
28
28
 
29
- target.pick(dd: :ee, ff: :gg).must_equal({ dd: { ee: 55 }, ff: { gg: 77 } })
29
+ assert_equal target.pick(dd: :ee, ff: :gg), { dd: { ee: 55 }, ff: { gg: 77 } }
30
30
  end
31
31
 
32
32
  it 'allows you to specify pick lists with arrays when picking recursively' do
33
33
  target = OpenStruct.new aa: (OpenStruct.new bb: 22, cc: (OpenStruct.new dd: 44, ee: 55))
34
34
 
35
- target.pick(aa: [:bb, cc: [:dd, :ee]]).must_equal({ aa: { bb: 22, cc: { dd: 44, ee: 55 } } })
35
+ assert_equal target.pick(aa: [:bb, cc: [:dd, :ee]]), { aa: { bb: 22, cc: { dd: 44, ee: 55 } } }
36
36
  end
37
37
 
38
38
  end
@@ -11,13 +11,13 @@ describe Augmented::Objects::Tackable do
11
11
 
12
12
  obj.tack lorem: 123, ipsum: -> { self }
13
13
 
14
- obj.lorem.must_equal 123
15
- obj.ipsum.object_id.must_equal obj.object_id
14
+ assert_equal obj.lorem, 123
15
+ assert_equal obj.ipsum.object_id, obj.object_id
16
16
  end
17
17
 
18
18
  it 'returns self' do
19
19
  obj = Object.new
20
- obj.tack.object_id.must_equal obj.object_id
20
+ assert_equal obj.tack.object_id, obj.object_id
21
21
  end
22
22
 
23
23
  end
@@ -12,11 +12,11 @@ describe Augmented::Objects::Tappable do
12
12
 
13
13
  subject.tap_if(true) { |subj| test = subj.upcase }
14
14
 
15
- test.must_equal 'ABC'
15
+ assert_equal test, 'ABC'
16
16
 
17
17
  subject.tap_if(Object.new) { |subj| test = subj.reverse }
18
18
 
19
- test.must_equal 'cba'
19
+ assert_equal test, 'cba'
20
20
  end
21
21
 
22
22
  it 'does not execute block if condition is falsy' do
@@ -25,11 +25,11 @@ describe Augmented::Objects::Tappable do
25
25
 
26
26
  subject.tap_if(false) { |subj| test = subj.upcase }
27
27
 
28
- test.must_equal nil
28
+ assert_nil test
29
29
 
30
30
  subject.tap_if(nil) { |subj| test = subj.upcase }
31
31
 
32
- test.must_equal nil
32
+ assert_nil test
33
33
  end
34
34
 
35
35
  it 'executes block if condition evaluates to truish' do
@@ -40,11 +40,11 @@ describe Augmented::Objects::Tappable do
40
40
 
41
41
  subject.tap_if(condition_1) { |subj| test = subj.upcase }
42
42
 
43
- test.must_equal 'ABC'
43
+ assert_equal test, 'ABC'
44
44
 
45
45
  subject.tap_if(condition_2) { |subj| test = subj.reverse }
46
46
 
47
- test.must_equal 'cba'
47
+ assert_equal test, 'cba'
48
48
  end
49
49
 
50
50
  it 'does not execute block if condition evaluates to falsy' do
@@ -55,18 +55,18 @@ describe Augmented::Objects::Tappable do
55
55
 
56
56
  subject.tap_if(condition_1) { |subj| test = subj.upcase }
57
57
 
58
- test.must_equal nil
58
+ assert_nil test
59
59
 
60
60
  subject.tap_if(condition_2) { |subj| test = subj.upcase }
61
61
 
62
- test.must_equal nil
62
+ assert_nil test
63
63
  end
64
64
 
65
65
  it 'always returns the object' do
66
66
  subject = 'abc'
67
67
 
68
- subject.tap_if(true){}.must_be_same_as subject
69
- subject.tap_if(false){}.must_be_same_as subject
68
+ assert_same subject.tap_if(true){}, subject
69
+ assert_same subject.tap_if(false){}, subject
70
70
  end
71
71
 
72
72
  end
@@ -79,11 +79,11 @@ describe Augmented::Objects::Tappable do
79
79
 
80
80
  subject.tap_unless(false) { |subj| test = subj.upcase }
81
81
 
82
- test.must_equal 'ABC'
82
+ assert_equal test, 'ABC'
83
83
 
84
84
  subject.tap_unless(nil) { |subj| test = subj.reverse }
85
85
 
86
- test.must_equal 'cba'
86
+ assert_equal test, 'cba'
87
87
  end
88
88
 
89
89
  it 'does not execute block if condition is truish' do
@@ -92,11 +92,11 @@ describe Augmented::Objects::Tappable do
92
92
 
93
93
  subject.tap_unless(true) { |subj| test = subj.upcase }
94
94
 
95
- test.must_equal nil
95
+ assert_nil test
96
96
 
97
97
  subject.tap_unless(Object.new) { |subj| test = subj.upcase }
98
98
 
99
- test.must_equal nil
99
+ assert_nil test
100
100
  end
101
101
 
102
102
  it 'executes block if condition evaluates to falsy' do
@@ -107,11 +107,11 @@ describe Augmented::Objects::Tappable do
107
107
 
108
108
  subject.tap_unless(condition_1) { |subj| test = subj.upcase }
109
109
 
110
- test.must_equal 'ABC'
110
+ assert_equal test, 'ABC'
111
111
 
112
112
  subject.tap_unless(condition_2) { |subj| test = subj.reverse }
113
113
 
114
- test.must_equal 'cba'
114
+ assert_equal test, 'cba'
115
115
  end
116
116
 
117
117
  it 'does not execute block if condition evaluates to truish' do
@@ -122,18 +122,18 @@ describe Augmented::Objects::Tappable do
122
122
 
123
123
  subject.tap_unless(condition_1) { |subj| test = subj.upcase }
124
124
 
125
- test.must_equal nil
125
+ assert_nil test
126
126
 
127
127
  subject.tap_unless(condition_2) { |subj| test = subj.upcase }
128
128
 
129
- test.must_equal nil
129
+ assert_nil test
130
130
  end
131
131
 
132
132
  it 'always returns the object' do
133
133
  subject = 'abc'
134
134
 
135
- subject.tap_unless(true){}.must_be_same_as subject
136
- subject.tap_unless(false){}.must_be_same_as subject
135
+ assert_same subject.tap_unless(true){}, subject
136
+ assert_same subject.tap_unless(false){}, subject
137
137
  end
138
138
 
139
139
  end
@@ -9,12 +9,12 @@ describe Augmented::Objects::Thru do
9
9
  it 'returns the result of applying the given function to the object' do
10
10
  plus_10 = -> i { i + 10 }
11
11
 
12
- 5.thru(&plus_10).must_equal 15
12
+ assert_equal 5.thru(&plus_10), 15
13
13
  end
14
14
 
15
15
  it 'returns the object untouched if called without arguments' do
16
16
  obj = Object.new
17
- obj.thru.object_id.must_equal obj.object_id
17
+ assert_equal obj.thru.object_id, obj.object_id
18
18
  end
19
19
 
20
20
  end
@@ -24,8 +24,8 @@ describe Augmented::Objects::Thru do
24
24
  it 'applies the given function to the object if the condition is truish' do
25
25
  plus_10 = -> i { i + 10 }
26
26
 
27
- 5.thru_if(true, &plus_10).must_equal 15
28
- 5.thru_if(Object.new, &plus_10).must_equal 15
27
+ assert_equal 5.thru_if(true, &plus_10), 15
28
+ assert_equal 5.thru_if(Object.new, &plus_10), 15
29
29
  end
30
30
 
31
31
  it 'applies the given function to the object if the condition evaluates to truish' do
@@ -34,15 +34,15 @@ describe Augmented::Objects::Thru do
34
34
  condition_1 = -> i { i == 5 }
35
35
  condition_2 = -> i { i.to_s }
36
36
 
37
- 5.thru_if(condition_1, &plus_10).must_equal 15
38
- 5.thru_if(condition_2, &plus_10).must_equal 15
37
+ assert_equal 5.thru_if(condition_1, &plus_10), 15
38
+ assert_equal 5.thru_if(condition_2, &plus_10), 15
39
39
  end
40
40
 
41
41
  it 'returns the object without applying the function if the condition is falsy' do
42
42
  plus_10 = -> i { i + 10 }
43
43
 
44
- 5.thru_if(false, &plus_10).must_equal 5
45
- 5.thru_if(nil, &plus_10).must_equal 5
44
+ assert_equal 5.thru_if(false, &plus_10), 5
45
+ assert_equal 5.thru_if(nil, &plus_10), 5
46
46
  end
47
47
 
48
48
  it 'returns the object without applying the function if the condition evaluates to falsy' do
@@ -51,8 +51,8 @@ describe Augmented::Objects::Thru do
51
51
  condition_1 = -> i { i == 10 }
52
52
  condition_2 = -> i { nil }
53
53
 
54
- 5.thru_if(condition_1, &plus_10).must_equal 5
55
- 5.thru_if(condition_2, &plus_10).must_equal 5
54
+ assert_equal 5.thru_if(condition_1, &plus_10), 5
55
+ assert_equal 5.thru_if(condition_2, &plus_10), 5
56
56
  end
57
57
 
58
58
  end
@@ -62,8 +62,8 @@ describe Augmented::Objects::Thru do
62
62
  it 'applies the given function to the object if the condition is falsy' do
63
63
  plus_10 = -> i { i + 10 }
64
64
 
65
- 5.thru_unless(false, &plus_10).must_equal 15
66
- 5.thru_unless(nil, &plus_10).must_equal 15
65
+ assert_equal 5.thru_unless(false, &plus_10), 15
66
+ assert_equal 5.thru_unless(nil, &plus_10), 15
67
67
  end
68
68
 
69
69
  it 'applies the given function to the object if the condition evaluates to falsy' do
@@ -72,15 +72,15 @@ describe Augmented::Objects::Thru do
72
72
  condition_1 = -> i { i == 10 }
73
73
  condition_2 = -> i { nil }
74
74
 
75
- 5.thru_unless(condition_1, &plus_10).must_equal 15
76
- 5.thru_unless(condition_2, &plus_10).must_equal 15
75
+ assert_equal 5.thru_unless(condition_1, &plus_10), 15
76
+ assert_equal 5.thru_unless(condition_2, &plus_10), 15
77
77
  end
78
78
 
79
79
  it 'returns the object without applying the function if the condition is truish' do
80
80
  plus_10 = -> i { i + 10 }
81
81
 
82
- 5.thru_unless(true, &plus_10).must_equal 5
83
- 5.thru_unless(Object.new, &plus_10).must_equal 5
82
+ assert_equal 5.thru_unless(true, &plus_10), 5
83
+ assert_equal 5.thru_unless(Object.new, &plus_10), 5
84
84
  end
85
85
 
86
86
  it 'returns the object without applying the function if the condition evaluates to truish' do
@@ -89,8 +89,8 @@ describe Augmented::Objects::Thru do
89
89
  condition_1 = -> i { i == 5 }
90
90
  condition_2 = -> i { i.to_s }
91
91
 
92
- 5.thru_unless(condition_1, &plus_10).must_equal 5
93
- 5.thru_unless(condition_2, &plus_10).must_equal 5
92
+ assert_equal 5.thru_unless(condition_1, &plus_10), 5
93
+ assert_equal 5.thru_unless(condition_2, &plus_10), 5
94
94
  end
95
95
 
96
96
  end
@@ -15,7 +15,7 @@ describe Augmented::Procs::Chainable do
15
15
 
16
16
  chain = add_one | triple | sub_two | add_twenty
17
17
 
18
- chain.call(1).must_equal 24
18
+ assert_equal chain.call(1), 24
19
19
  end
20
20
 
21
21
  end
@@ -12,7 +12,7 @@ describe Augmented::Procs::Rescuable do
12
12
  unsafe_proc = -> { raise specific_exception_class }
13
13
  rescued_proc = unsafe_proc.rescues specific_exception_class, 42
14
14
 
15
- rescued_proc.call.must_equal 42
15
+ assert_equal rescued_proc.call, 42
16
16
  end
17
17
 
18
18
  it 'returns a proc which returns the result of the provided block if the expected exception is raised' do
@@ -21,7 +21,7 @@ describe Augmented::Procs::Rescuable do
21
21
  unsafe_proc = -> { raise specific_exception_class }
22
22
  rescued_proc = unsafe_proc.rescues(specific_exception_class){ |exception| exception }
23
23
 
24
- rescued_proc.call.must_be_instance_of specific_exception_class
24
+ assert_instance_of specific_exception_class, rescued_proc.call
25
25
  end
26
26
 
27
27
  it 'returns a proc which lets exceptions other than the expected one to be raised' do
@@ -30,7 +30,7 @@ describe Augmented::Procs::Rescuable do
30
30
  unsafe_proc = -> { raise RuntimeError }
31
31
  rescued_proc = unsafe_proc.rescues specific_exception_class, 42
32
32
 
33
- rescued_proc.must_raise RuntimeError
33
+ assert_raises(RuntimeError){ rescued_proc.call }
34
34
  end
35
35
 
36
36
  end
@@ -23,17 +23,17 @@ describe Augmented::Symbols::Arguable do
23
23
  end
24
24
 
25
25
  it 'returns a function that calls the method named <symbol> while also passing the arguments supplied' do
26
- :add.with(9).call(@eleven).must_equal 20
27
- :add_many.with(3, 6, 10, 20, 50).call(@eleven).must_equal 100
26
+ assert_equal :add.with(9).call(@eleven), 20
27
+ assert_equal :add_many.with(3, 6, 10, 20, 50).call(@eleven), 100
28
28
  end
29
29
 
30
30
  describe 'the returned function' do
31
31
 
32
32
  it "it preserves Symbol's `to_proc` behavior of passing extra arguments, if supplied" do
33
- :add.to_proc.call(@eleven, 4).must_equal 15
34
- :add.with().call(@eleven, 4).must_equal 15
33
+ assert_equal :add.to_proc.call(@eleven, 4), 15
34
+ assert_equal :add.with().call(@eleven, 4), 15
35
35
 
36
- :add_many.with(10, 20).call(@eleven, 4, 5).must_equal 50
36
+ assert_equal :add_many.with(10, 20).call(@eleven, 4, 5), 50
37
37
  end
38
38
 
39
39
  it 'passes along the block supplied to `with`, if any' do
@@ -42,7 +42,7 @@ describe Augmented::Symbols::Arguable do
42
42
 
43
43
  :do_whatever.with(&set_result).call(@eleven)
44
44
 
45
- result.must_equal 11
45
+ assert_equal result, 11
46
46
  end
47
47
 
48
48
  end
@@ -16,15 +16,15 @@ describe Augmented::Symbols::Comparing do
16
16
  it 'returns a function that sends <symbol> to two objects and compares the results with `==`' do
17
17
  comparator = :lorem_ipsum.eq
18
18
 
19
- comparator.call(thing_A, thing_B).must_equal true
20
- comparator.call(thing_A, thing_C).must_equal false
19
+ assert_equal comparator.call(thing_A, thing_B), true
20
+ assert_equal comparator.call(thing_A, thing_C), false
21
21
  end
22
22
 
23
23
  it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `==`' do
24
24
  comparator = :lorem_ipsum.eq(123)
25
25
 
26
- comparator.call(thing_A).must_equal true
27
- comparator.call(thing_C).must_equal false
26
+ assert_equal comparator.call(thing_A), true
27
+ assert_equal comparator.call(thing_C), false
28
28
  end
29
29
 
30
30
  end
@@ -34,15 +34,15 @@ describe Augmented::Symbols::Comparing do
34
34
  it 'returns a function that sends <symbol> to two objects and compares the results with `!=`' do
35
35
  comparator = :lorem_ipsum.neq
36
36
 
37
- comparator.call(thing_A, thing_B).must_equal false
38
- comparator.call(thing_A, thing_C).must_equal true
37
+ assert_equal comparator.call(thing_A, thing_B), false
38
+ assert_equal comparator.call(thing_A, thing_C), true
39
39
  end
40
40
 
41
41
  it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `!=`' do
42
42
  comparator = :lorem_ipsum.neq(123)
43
43
 
44
- comparator.call(thing_A).must_equal false
45
- comparator.call(thing_C).must_equal true
44
+ assert_equal comparator.call(thing_A), false
45
+ assert_equal comparator.call(thing_C), true
46
46
  end
47
47
 
48
48
  end
@@ -52,17 +52,17 @@ describe Augmented::Symbols::Comparing do
52
52
  it 'returns a function that sends <symbol> to two objects and compares the results with `<`' do
53
53
  comparator = :lorem_ipsum.lt
54
54
 
55
- comparator.call(thing_A, thing_B).must_equal false
56
- comparator.call(thing_A, thing_C).must_equal true
57
- comparator.call(thing_C, thing_B).must_equal false
55
+ assert_equal comparator.call(thing_A, thing_B), false
56
+ assert_equal comparator.call(thing_A, thing_C), true
57
+ assert_equal comparator.call(thing_C, thing_B), false
58
58
  end
59
59
 
60
60
  it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `<`' do
61
61
  comparator = :lorem_ipsum.lt(123)
62
62
 
63
- comparator.call(thing_A).must_equal false
64
- comparator.call(thing_C).must_equal false
65
- comparator.call(thing_D).must_equal true
63
+ assert_equal comparator.call(thing_A), false
64
+ assert_equal comparator.call(thing_C), false
65
+ assert_equal comparator.call(thing_D), true
66
66
  end
67
67
 
68
68
  end
@@ -72,17 +72,17 @@ describe Augmented::Symbols::Comparing do
72
72
  it 'returns a function that sends <symbol> to two objects and compares the results with `<=`' do
73
73
  comparator = :lorem_ipsum.lte
74
74
 
75
- comparator.call(thing_A, thing_B).must_equal true
76
- comparator.call(thing_A, thing_C).must_equal true
77
- comparator.call(thing_C, thing_B).must_equal false
75
+ assert_equal comparator.call(thing_A, thing_B), true
76
+ assert_equal comparator.call(thing_A, thing_C), true
77
+ assert_equal comparator.call(thing_C, thing_B), false
78
78
  end
79
79
 
80
80
  it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `<=`' do
81
81
  comparator = :lorem_ipsum.lte(123)
82
82
 
83
- comparator.call(thing_A).must_equal true
84
- comparator.call(thing_C).must_equal false
85
- comparator.call(thing_D).must_equal true
83
+ assert_equal comparator.call(thing_A), true
84
+ assert_equal comparator.call(thing_C), false
85
+ assert_equal comparator.call(thing_D), true
86
86
  end
87
87
 
88
88
  end
@@ -92,17 +92,17 @@ describe Augmented::Symbols::Comparing do
92
92
  it 'returns a function that sends <symbol> to two objects and compares the results with `>`' do
93
93
  comparator = :lorem_ipsum.gt
94
94
 
95
- comparator.call(thing_A, thing_B).must_equal false
96
- comparator.call(thing_A, thing_C).must_equal false
97
- comparator.call(thing_C, thing_B).must_equal true
95
+ assert_equal comparator.call(thing_A, thing_B), false
96
+ assert_equal comparator.call(thing_A, thing_C), false
97
+ assert_equal comparator.call(thing_C, thing_B), true
98
98
  end
99
99
 
100
100
  it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `>`' do
101
101
  comparator = :lorem_ipsum.gt(123)
102
102
 
103
- comparator.call(thing_A).must_equal false
104
- comparator.call(thing_C).must_equal true
105
- comparator.call(thing_D).must_equal false
103
+ assert_equal comparator.call(thing_A), false
104
+ assert_equal comparator.call(thing_C), true
105
+ assert_equal comparator.call(thing_D), false
106
106
  end
107
107
 
108
108
  end
@@ -112,17 +112,17 @@ describe Augmented::Symbols::Comparing do
112
112
  it 'returns a function that sends <symbol> to two objects and compares the results with `>=`' do
113
113
  comparator = :lorem_ipsum.gte
114
114
 
115
- comparator.call(thing_A, thing_B).must_equal true
116
- comparator.call(thing_A, thing_C).must_equal false
117
- comparator.call(thing_C, thing_B).must_equal true
115
+ assert_equal comparator.call(thing_A, thing_B), true
116
+ assert_equal comparator.call(thing_A, thing_C), false
117
+ assert_equal comparator.call(thing_C, thing_B), true
118
118
  end
119
119
 
120
120
  it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `>=`' do
121
121
  comparator = :lorem_ipsum.gte(123)
122
122
 
123
- comparator.call(thing_A).must_equal true
124
- comparator.call(thing_C).must_equal true
125
- comparator.call(thing_D).must_equal false
123
+ assert_equal comparator.call(thing_A), true
124
+ assert_equal comparator.call(thing_C), true
125
+ assert_equal comparator.call(thing_D), false
126
126
  end
127
127
 
128
128
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: augmented
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - bruno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-21 00:00:00.000000000 Z
11
+ date: 2021-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.7'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  description: Adds a few useful extra methods to some of Ruby's core types, available
42
42
  as refinements.
43
43
  email:
@@ -110,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
- rubyforge_project:
114
- rubygems_version: 2.5.1
113
+ rubygems_version: 3.1.4
115
114
  signing_key:
116
115
  specification_version: 4
117
116
  summary: Useful extra methods for some Ruby core types.