gorillib 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/gorillib.gemspec +1 -1
- data/lib/gorillib/hashlike.rb +0 -1
- data/lib/gorillib/receiver/acts_as_hash.rb +1 -24
- data/spec/struct/acts_as_hash_fuzz_spec.rb +37 -33
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/gorillib.gemspec
CHANGED
data/lib/gorillib/hashlike.rb
CHANGED
@@ -119,30 +119,6 @@ module Receiver
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
# # Hashlike#==
|
123
|
-
# #
|
124
|
-
# # Equality -- Two hashes are equal if they contain the same number of keys,
|
125
|
-
# # and the value corresponding to each key in the first hash is equal (using
|
126
|
-
# # <tt>==</tt>) to the value for the same key in the second. If +obj+ is not a
|
127
|
-
# # Hashlike, attempt to convert it using +to_hash+ and return <tt>obj ==
|
128
|
-
# # hsh</tt>.
|
129
|
-
# #
|
130
|
-
# # Does not take a default value comparion into account.
|
131
|
-
# #
|
132
|
-
# # @example
|
133
|
-
# # h1 = { :a => 1, :c => 2 }
|
134
|
-
# # h2 = { 7 => 35, :c => 2, :a => 1 }
|
135
|
-
# # h3 = { :a => 1, :c => 2, 7 => 35 }
|
136
|
-
# # h4 = { :a => 1, :d => 2, :f => 35 }
|
137
|
-
# # h1 == h2 # => false
|
138
|
-
# # h2 == h3 # => true
|
139
|
-
# # h3 == h4 # => false
|
140
|
-
# #
|
141
|
-
# def ==(other_hash)
|
142
|
-
# (length == other_hash.length) &&
|
143
|
-
# all?{|k,v| v == other_hash[k] }
|
144
|
-
# end
|
145
|
-
|
146
122
|
# Hashlike#keys
|
147
123
|
#
|
148
124
|
# Returns a new array populated with the keys from this hashlike.
|
@@ -186,6 +162,7 @@ module Receiver
|
|
186
162
|
|
187
163
|
def self.included base
|
188
164
|
base.extend ClassMethods
|
165
|
+
base.send(:include, Gorillib::Hashlike)
|
189
166
|
end
|
190
167
|
end
|
191
168
|
end
|
@@ -16,51 +16,55 @@ STRUCT_HASHLIKE_METHODS_TO_SKIP = [:each, :flatten, :clear, :values_at] +
|
|
16
16
|
Enumerable.public_instance_methods.map(&:to_sym) +
|
17
17
|
HashlikeHelper::HASH_METHODS_MISSING_FROM_VERSION
|
18
18
|
|
19
|
-
|
19
|
+
describe Gorillib::Struct::ActsAsHash do
|
20
|
+
if ENV['FULL_SPECS']
|
21
|
+
include HashlikeFuzzingHelper
|
20
22
|
|
21
|
-
describe "
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
describe "vs Hash" do
|
24
|
+
before do
|
25
|
+
@total = 0
|
26
|
+
@hsh = HashlikeHelper::HASH_TO_TEST_HASHLIKE_STRUCT.dup
|
27
|
+
@hshlike = StructUsingHashlike.new.merge(HashlikeHelper::HASH_TO_TEST_HASHLIKE_STRUCT)
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
( HashlikeHelper::METHODS_TO_TEST - STRUCT_HASHLIKE_METHODS_TO_SKIP ).each do |method_to_test|
|
31
|
+
describe "##{method_to_test}" do
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
(HashlikeFuzzingHelper::INPUTS_FOR_ALL_HASHLIKES).each do |input|
|
34
|
+
next if HashlikeFuzzingHelper::SPECIAL_CASES_FOR_HASHLIKE_STRUCT[method_to_test].include?(input)
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
+
it "on #{input.inspect}" do
|
37
|
+
behaves_the_same(@hsh, @hshlike, method_to_test, input)
|
38
|
+
end
|
39
|
+
end
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
39
|
-
end
|
40
|
-
end
|
41
43
|
|
42
|
-
describe "
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
describe "vs Gorillib::HashWithIndifferentSymbolKeys" do
|
45
|
+
before do
|
46
|
+
@total = 0
|
47
|
+
@hsh = Gorillib::HashWithIndifferentSymbolKeys.new_from_hash_copying_default(
|
48
|
+
HashlikeHelper::HASH_TO_TEST_HASHLIKE_STRUCT)
|
49
|
+
@hshlike = StructUsingHashlike.new.merge(
|
50
|
+
HashlikeHelper::HASH_TO_TEST_HASHLIKE_STRUCT)
|
51
|
+
end
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
|
53
|
+
( HashlikeHelper::METHODS_TO_TEST - STRUCT_HASHLIKE_METHODS_TO_SKIP
|
54
|
+
).each do |method_to_test|
|
55
|
+
describe "##{method_to_test}" do
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
( HashlikeFuzzingHelper::INPUTS_WHEN_INDIFFERENT_ACCESS +
|
58
|
+
HashlikeFuzzingHelper::INPUTS_FOR_ALL_HASHLIKES
|
59
|
+
).each do |input|
|
60
|
+
next if HashlikeFuzzingHelper::SPECIAL_CASES_FOR_HASHLIKE_STRUCT[method_to_test].include?(input)
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
62
|
+
it "on #{input.inspect}" do
|
63
|
+
behaves_the_same(@hsh, @hshlike, method_to_test, input)
|
64
|
+
end
|
63
65
|
|
66
|
+
end
|
67
|
+
end
|
64
68
|
end
|
65
69
|
end
|
66
70
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gorillib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Infochimps
|
@@ -315,7 +315,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
315
315
|
requirements:
|
316
316
|
- - ">="
|
317
317
|
- !ruby/object:Gem::Version
|
318
|
-
hash:
|
318
|
+
hash: 2181950979362360273
|
319
319
|
segments:
|
320
320
|
- 0
|
321
321
|
version: "0"
|