nrser 0.3.0 → 0.3.1
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.
- checksums.yaml +4 -4
- data/lib/nrser/core_ext/hash.rb +11 -4
- data/lib/nrser/functions/enumerable.rb +1 -1
- data/lib/nrser/functions/path.rb +1 -1
- data/lib/nrser/rspex/example_group/describe_spec_file.rb +9 -4
- data/lib/nrser/version.rb +1 -1
- data/spec/lib/nrser/core_ext/hash/short_transform_keys_spec.rb +40 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbe345fdd17d3661a6ab8424078866fca405486c
|
4
|
+
data.tar.gz: 011ea7b181ad4f101ce83a1edc9a44ea5a4728fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cef54bd329af2caee3fb30220f39a57510d4a110836f86dfa7f2af744b24df8592e09f04ca27f27cbe548bb2229532e36afa2c668e2fc431ad564c4fd07b5194
|
7
|
+
data.tar.gz: 3b4f1a99cf7397b170559177ceca023b3e7b22f5bfe632a0c77f26c62c815ef488fea667b781035025ae2283258a57c391185272fbe077ecefd84a51317e02be
|
data/lib/nrser/core_ext/hash.rb
CHANGED
@@ -9,11 +9,18 @@ class Hash
|
|
9
9
|
include NRSER::Ext::Tree
|
10
10
|
|
11
11
|
# Short names
|
12
|
-
|
13
|
-
alias_method
|
12
|
+
#
|
13
|
+
# NOTE If we use `alias_method` here it breaks subclasses that override
|
14
|
+
# `#symbolize_keys`, etc. - like {HashWithIndifferentAccess}
|
15
|
+
#
|
16
|
+
def sym_keys! *args, █ symbolize_keys! *args, █ end
|
17
|
+
def sym_keys *args, █ symbolize_keys *args, █ end
|
18
|
+
|
19
|
+
def str_keys! *args, █ stringify_keys! *args, █ end
|
20
|
+
def str_keys *args, █ stringify_keys *args, █ end
|
14
21
|
|
15
|
-
|
16
|
-
|
22
|
+
def to_options! *args, █ symbolize_keys! *args, █ end
|
23
|
+
def to_options *args, █ symbolize_keys *args, █ end
|
17
24
|
|
18
25
|
|
19
26
|
# See {NRSER.bury!}
|
data/lib/nrser/functions/path.rb
CHANGED
@@ -71,14 +71,19 @@ module NRSER::RSpex::ExampleGroup
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
|
74
|
+
describe_x_body = if chain.empty?
|
75
|
+
body
|
76
|
+
else
|
77
|
+
-> { dive_x *chain, bind_subject: bind_subject, &body }
|
78
|
+
end
|
79
|
+
|
80
|
+
describe_x \
|
75
81
|
NRSER::RSpex.dot_rel_path( spec_path ),
|
76
82
|
*description,
|
77
83
|
type: :spec_file,
|
78
84
|
metadata: metadata,
|
79
|
-
|
80
|
-
|
81
|
-
end
|
85
|
+
&describe_x_body
|
86
|
+
|
82
87
|
end # #describe_spec_file
|
83
88
|
|
84
89
|
end # module NRSER::RSpex::ExampleGroup
|
data/lib/nrser/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'nrser/core_ext/hash'
|
2
|
+
|
3
|
+
describe_spec_file(
|
4
|
+
spec_path: __FILE__,
|
5
|
+
) do
|
6
|
+
|
7
|
+
describe_setup "'short' transform keys methods under inheritance" do
|
8
|
+
|
9
|
+
def self.str_hash; {'x' => 1, 'y' => 2}; end
|
10
|
+
def str_hash; self.class.str_hash; end
|
11
|
+
|
12
|
+
def self.sym_hash; {x: 1, y: 2}; end
|
13
|
+
def sym_hash; self.class.sym_hash; end
|
14
|
+
|
15
|
+
[Hash, HashWithIndifferentAccess].each do |hash_class|
|
16
|
+
describe_class hash_class do
|
17
|
+
[str_hash, sym_hash].each do |source_hash|
|
18
|
+
describe "#{ described_class.name }[#{ str_hash }]" do
|
19
|
+
subject do
|
20
|
+
described_class.send :[], source_hash
|
21
|
+
end
|
22
|
+
|
23
|
+
describe_instance_method :sym_keys do
|
24
|
+
describe_called_with() do
|
25
|
+
it { is_expected.to eq subject.symbolize_keys }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe_instance_method :str_keys do
|
30
|
+
describe_called_with() do
|
31
|
+
it { is_expected.to eq subject.stringify_keys }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end # instance str_hash
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end # spec file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nrser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nrser
|
@@ -399,6 +399,7 @@ files:
|
|
399
399
|
- spec/lib/nrser/collection/map_spec.rb
|
400
400
|
- spec/lib/nrser/core_ext/binding/erb_spec.rb
|
401
401
|
- spec/lib/nrser/core_ext/enumerable/find_map_spec.rb
|
402
|
+
- spec/lib/nrser/core_ext/hash/short_transform_keys_spec.rb
|
402
403
|
- spec/lib/nrser/core_ext/hash_spec.rb
|
403
404
|
- spec/lib/nrser/errors/abstract_method_error_spec.rb
|
404
405
|
- spec/lib/nrser/functions/enumerable/associate_spec.rb
|
@@ -488,6 +489,7 @@ test_files:
|
|
488
489
|
- spec/lib/nrser/collection/map_spec.rb
|
489
490
|
- spec/lib/nrser/core_ext/binding/erb_spec.rb
|
490
491
|
- spec/lib/nrser/core_ext/enumerable/find_map_spec.rb
|
492
|
+
- spec/lib/nrser/core_ext/hash/short_transform_keys_spec.rb
|
491
493
|
- spec/lib/nrser/core_ext/hash_spec.rb
|
492
494
|
- spec/lib/nrser/errors/abstract_method_error_spec.rb
|
493
495
|
- spec/lib/nrser/functions/enumerable/associate_spec.rb
|