augmented 0.2.2 → 0.2.7

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.
@@ -1,51 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'augmented/symbols/arguable'
3
-
4
- describe Augmented::Symbols::Arguable do
5
- using Augmented::Symbols::Arguable
6
-
7
- describe '#with' do
8
-
9
- before do
10
- @eleven = Class.new do
11
- def add other_number
12
- 11 + other_number
13
- end
14
-
15
- def add_many one_number, another_number, *many_numbers
16
- 11 + one_number + another_number + many_numbers.reduce(0, :+)
17
- end
18
-
19
- def do_whatever
20
- yield 11
21
- end
22
- end.new
23
- end
24
-
25
- it 'returns a function that calls the method named <symbol> while also passing the arguments supplied' do
26
- assert_equal :add.with(9).call(@eleven), 20
27
- assert_equal :add_many.with(3, 6, 10, 20, 50).call(@eleven), 100
28
- end
29
-
30
- describe 'the returned function' do
31
-
32
- it "it preserves Symbol's `to_proc` behavior of passing extra arguments, if supplied" do
33
- assert_equal :add.to_proc.call(@eleven, 4), 15
34
- assert_equal :add.with().call(@eleven, 4), 15
35
-
36
- assert_equal :add_many.with(10, 20).call(@eleven, 4, 5), 50
37
- end
38
-
39
- it 'passes along the block supplied to `with`, if any' do
40
- result = nil
41
- set_result = -> i { result = i }
42
-
43
- :do_whatever.with(&set_result).call(@eleven)
44
-
45
- assert_equal result, 11
46
- end
47
-
48
- end
49
-
50
- end
51
- end
@@ -1,131 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'augmented/symbols/comparing'
3
-
4
- describe Augmented::Symbols::Comparing do
5
- using Augmented::Symbols::Comparing
6
-
7
- let(:dummy) { Struct.new :lorem_ipsum }
8
-
9
- let(:thing_A) { dummy.new 123 }
10
- let(:thing_B) { dummy.new 123 }
11
- let(:thing_C) { dummy.new 987 }
12
- let(:thing_D) { dummy.new 0 }
13
-
14
- describe '#eq' do
15
-
16
- it 'returns a function that sends <symbol> to two objects and compares the results with `==`' do
17
- comparator = :lorem_ipsum.eq
18
-
19
- assert_equal comparator.call(thing_A, thing_B), true
20
- assert_equal comparator.call(thing_A, thing_C), false
21
- end
22
-
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
- comparator = :lorem_ipsum.eq(123)
25
-
26
- assert_equal comparator.call(thing_A), true
27
- assert_equal comparator.call(thing_C), false
28
- end
29
-
30
- end
31
-
32
- describe '#neq' do
33
-
34
- it 'returns a function that sends <symbol> to two objects and compares the results with `!=`' do
35
- comparator = :lorem_ipsum.neq
36
-
37
- assert_equal comparator.call(thing_A, thing_B), false
38
- assert_equal comparator.call(thing_A, thing_C), true
39
- end
40
-
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
- comparator = :lorem_ipsum.neq(123)
43
-
44
- assert_equal comparator.call(thing_A), false
45
- assert_equal comparator.call(thing_C), true
46
- end
47
-
48
- end
49
-
50
- describe '#lt' do
51
-
52
- it 'returns a function that sends <symbol> to two objects and compares the results with `<`' do
53
- comparator = :lorem_ipsum.lt
54
-
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
- end
59
-
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
- comparator = :lorem_ipsum.lt(123)
62
-
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
- end
67
-
68
- end
69
-
70
- describe '#lte' do
71
-
72
- it 'returns a function that sends <symbol> to two objects and compares the results with `<=`' do
73
- comparator = :lorem_ipsum.lte
74
-
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
- end
79
-
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
- comparator = :lorem_ipsum.lte(123)
82
-
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
- end
87
-
88
- end
89
-
90
- describe '#gt' do
91
-
92
- it 'returns a function that sends <symbol> to two objects and compares the results with `>`' do
93
- comparator = :lorem_ipsum.gt
94
-
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
- end
99
-
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
- comparator = :lorem_ipsum.gt(123)
102
-
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
- end
107
-
108
- end
109
-
110
- describe '#gte' do
111
-
112
- it 'returns a function that sends <symbol> to two objects and compares the results with `>=`' do
113
- comparator = :lorem_ipsum.gte
114
-
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
- end
119
-
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
- comparator = :lorem_ipsum.gte(123)
122
-
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
- end
127
-
128
- end
129
-
130
-
131
- end