attr_extras 6.2.1 → 6.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -4
- data/CHANGELOG.md +5 -0
- data/attr_extras.gemspec +2 -2
- data/lib/attr_extras/explicit.rb +2 -3
- data/lib/attr_extras/version.rb +1 -1
- data/spec/attr_extras/aattr_initialize_spec.rb +6 -6
- data/spec/attr_extras/attr_id_query_spec.rb +1 -1
- data/spec/attr_extras/attr_implement_spec.rb +11 -11
- data/spec/attr_extras/attr_initialize_spec.rb +21 -21
- data/spec/attr_extras/attr_private_spec.rb +3 -3
- data/spec/attr_extras/attr_query_spec.rb +1 -1
- data/spec/attr_extras/attr_value_spec.rb +7 -7
- data/spec/attr_extras/params_builder_spec.rb +20 -20
- data/spec/attr_extras/pattr_initialize_spec.rb +5 -5
- data/spec/attr_extras/rattr_initialize_spec.rb +4 -4
- data/spec/attr_extras/utils_spec.rb +3 -3
- data/spec/attr_extras/vattr_initialize_spec.rb +9 -9
- data/spec/attr_extras_spec.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e27f369dd7727be720fe63c6a7db149bc1e5bcd3693574b6bbbfdf1c7eefe064
|
4
|
+
data.tar.gz: f2fbb6354c8ac8f721b3d30bdf7525ef7f86082d5a8bd79093ee22321438a3fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15a68ad4827938ea50abb75c036656bc39ca542eefbfca243a07d6ec3452d64e6732a99369dc0accc66c7dfb458176a1608b024e1c0206b56eb99e5ab842d06e
|
7
|
+
data.tar.gz: 6e62cca9b82e3fbb6360b6453dcd738165cb5a9d69e530a341dfa2d1c36a8b716f733b1449727753c9faebdc3fea503520a25571356767a8b4492c98744a8235
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
# 6.2.2
|
4
|
+
|
5
|
+
- Fix warnings with Ruby 2.7. Thanks to [Juanito Fatas](https://github.com/barsoom/attr_extras/pull/31)!
|
6
|
+
- Fix deprecation warnings for Minitest 6. Thanks again to [Juanito Fatas](https://github.com/barsoom/attr_extras/pull/30)!
|
7
|
+
|
3
8
|
# 6.2.1
|
4
9
|
|
5
10
|
* Bugfix with keyword argument defaults. Thanks to [Roman Dubrovsky](https://github.com/barsoom/attr_extras/pull/29)!
|
data/attr_extras.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path(
|
2
|
+
require File.expand_path("../lib/attr_extras/version", __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["Henrik Nyh", "Joakim Kolsjö", "Victor Arias", "Ola K"]
|
5
|
+
gem.authors = ["Henrik Nyh", "Joakim Kolsjö", "Tomas Skogberg", "Victor Arias", "Ola K"]
|
6
6
|
gem.email = ["henrik@nyh.se"]
|
7
7
|
gem.summary = %q{Takes some boilerplate out of Ruby with methods like attr_initialize.}
|
8
8
|
gem.homepage = "https://github.com/barsoom/attr_extras"
|
data/lib/attr_extras/explicit.rb
CHANGED
@@ -21,9 +21,8 @@ module AttrExtras
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def attr_private(*names)
|
24
|
-
#
|
25
|
-
|
26
|
-
public
|
24
|
+
# Avoid warnings: https://github.com/barsoom/attr_extras/pull/31
|
25
|
+
return unless names && names.any?
|
27
26
|
|
28
27
|
attr_reader(*names)
|
29
28
|
private(*names)
|
data/lib/attr_extras/version.rb
CHANGED
@@ -8,7 +8,7 @@ describe Object, ".aattr_initialize" do
|
|
8
8
|
|
9
9
|
example = klass.new("Foo", "Bar")
|
10
10
|
|
11
|
-
example.foo.must_equal "Foo"
|
11
|
+
_(example.foo).must_equal "Foo"
|
12
12
|
end
|
13
13
|
|
14
14
|
it "creates public writers" do
|
@@ -19,7 +19,7 @@ describe Object, ".aattr_initialize" do
|
|
19
19
|
example = klass.new("Foo", "Bar")
|
20
20
|
example.foo = "Baz"
|
21
21
|
|
22
|
-
example.foo.must_equal "Baz"
|
22
|
+
_(example.foo).must_equal "Baz"
|
23
23
|
end
|
24
24
|
|
25
25
|
it "works with hash ivars" do
|
@@ -29,7 +29,7 @@ describe Object, ".aattr_initialize" do
|
|
29
29
|
|
30
30
|
example = klass.new("Foo", bar: "Bar", baz: "Baz")
|
31
31
|
|
32
|
-
example.baz.must_equal "Baz"
|
32
|
+
_(example.baz).must_equal "Baz"
|
33
33
|
end
|
34
34
|
|
35
35
|
it "works with hash ivars and default values" do
|
@@ -39,7 +39,7 @@ describe Object, ".aattr_initialize" do
|
|
39
39
|
|
40
40
|
example = klass.new("Foo")
|
41
41
|
|
42
|
-
example.baz.must_equal "Baz"
|
42
|
+
_(example.baz).must_equal "Baz"
|
43
43
|
end
|
44
44
|
|
45
45
|
it "accepts a block for initialization" do
|
@@ -53,7 +53,7 @@ describe Object, ".aattr_initialize" do
|
|
53
53
|
|
54
54
|
example = klass.new("expected")
|
55
55
|
|
56
|
-
example.copy.must_equal "expected"
|
56
|
+
_(example.copy).must_equal "expected"
|
57
57
|
end
|
58
58
|
|
59
59
|
it "accepts the alias attr_accessor_initialize" do
|
@@ -63,6 +63,6 @@ describe Object, ".aattr_initialize" do
|
|
63
63
|
|
64
64
|
example = klass.new("Foo", "Bar")
|
65
65
|
|
66
|
-
example.foo.must_equal "Foo"
|
66
|
+
_(example.foo).must_equal "Foo"
|
67
67
|
end
|
68
68
|
end
|
@@ -7,8 +7,8 @@ describe Object, ".attr_implement" do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
example = klass.new
|
10
|
-
exception = lambda { example.foo }.must_raise AttrExtras::MethodNotImplementedError
|
11
|
-
exception.message.must_equal "Implement a 'foo()' method"
|
10
|
+
exception = _(lambda { example.foo }).must_raise AttrExtras::MethodNotImplementedError
|
11
|
+
_(exception.message).must_equal "Implement a 'foo()' method"
|
12
12
|
end
|
13
13
|
|
14
14
|
it "allows specifying arity and argument names" do
|
@@ -18,10 +18,10 @@ describe Object, ".attr_implement" do
|
|
18
18
|
|
19
19
|
example = klass.new
|
20
20
|
|
21
|
-
exception = lambda { example.foo(1, 2) }.must_raise AttrExtras::MethodNotImplementedError
|
22
|
-
exception.message.must_equal "Implement a 'foo(name, age)' method"
|
21
|
+
exception = _(lambda { example.foo(1, 2) }).must_raise AttrExtras::MethodNotImplementedError
|
22
|
+
_(exception.message).must_equal "Implement a 'foo(name, age)' method"
|
23
23
|
|
24
|
-
lambda { example.foo }.must_raise ArgumentError
|
24
|
+
_(lambda { example.foo }).must_raise ArgumentError
|
25
25
|
end
|
26
26
|
|
27
27
|
it "does not raise if method is implemented in a subclass" do
|
@@ -35,7 +35,7 @@ describe Object, ".attr_implement" do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
subklass.new.foo.must_equal "bar"
|
38
|
+
_(subklass.new.foo).must_equal "bar"
|
39
39
|
end
|
40
40
|
|
41
41
|
# E.g. when Active Record defines column query methods like "admin?"
|
@@ -55,7 +55,7 @@ describe Object, ".attr_implement" do
|
|
55
55
|
include foo_interface
|
56
56
|
end
|
57
57
|
|
58
|
-
klass.new.foo.must_equal "bar"
|
58
|
+
_(klass.new.foo).must_equal "bar"
|
59
59
|
end
|
60
60
|
|
61
61
|
it "does not mess up missing-method handling" do
|
@@ -63,7 +63,7 @@ describe Object, ".attr_implement" do
|
|
63
63
|
attr_implement :foo
|
64
64
|
end
|
65
65
|
|
66
|
-
lambda { klass.new.some_other_method }.must_raise NoMethodError
|
66
|
+
_(lambda { klass.new.some_other_method }).must_raise NoMethodError
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -73,9 +73,9 @@ describe Object, ".cattr_implement" do
|
|
73
73
|
cattr_implement :foo, [:name, :age]
|
74
74
|
end
|
75
75
|
|
76
|
-
exception = lambda { klass.foo(1, 2) }.must_raise AttrExtras::MethodNotImplementedError
|
77
|
-
exception.message.must_equal "Implement a 'foo(name, age)' method"
|
76
|
+
exception = _(lambda { klass.foo(1, 2) }).must_raise AttrExtras::MethodNotImplementedError
|
77
|
+
_(exception.message).must_equal "Implement a 'foo(name, age)' method"
|
78
78
|
|
79
|
-
lambda { klass.foo }.must_raise ArgumentError
|
79
|
+
_(lambda { klass.foo }).must_raise ArgumentError
|
80
80
|
end
|
81
81
|
end
|
@@ -13,13 +13,13 @@ describe Object, ".attr_initialize" do
|
|
13
13
|
|
14
14
|
it "creates an initializer setting those instance variables" do
|
15
15
|
example = klass.new("Foo", "Bar")
|
16
|
-
example.instance_variable_get("@foo").must_equal "Foo"
|
17
|
-
example.instance_variable_get("@bar").must_equal "Bar"
|
16
|
+
_(example.instance_variable_get("@foo")).must_equal "Foo"
|
17
|
+
_(example.instance_variable_get("@bar")).must_equal "Bar"
|
18
18
|
end
|
19
19
|
|
20
20
|
it "requires all arguments" do
|
21
|
-
exception = lambda { klass.new("Foo") }.must_raise ArgumentError
|
22
|
-
exception.message.must_equal "wrong number of arguments (1 for 2) for ExampleClass initializer"
|
21
|
+
exception = _(lambda { klass.new("Foo") }).must_raise ArgumentError
|
22
|
+
_(exception.message).must_equal "wrong number of arguments (1 for 2) for ExampleClass initializer"
|
23
23
|
end
|
24
24
|
|
25
25
|
it "can set ivars from a hash" do
|
@@ -28,9 +28,9 @@ describe Object, ".attr_initialize" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
example = klass.new("Foo", bar: "Bar", baz: "Baz")
|
31
|
-
example.instance_variable_get("@foo").must_equal "Foo"
|
32
|
-
example.instance_variable_get("@bar").must_equal "Bar"
|
33
|
-
example.instance_variable_get("@baz").must_equal "Baz"
|
31
|
+
_(example.instance_variable_get("@foo")).must_equal "Foo"
|
32
|
+
_(example.instance_variable_get("@bar")).must_equal "Bar"
|
33
|
+
_(example.instance_variable_get("@baz")).must_equal "Baz"
|
34
34
|
end
|
35
35
|
|
36
36
|
it "can set default values for keyword arguments" do
|
@@ -39,12 +39,12 @@ describe Object, ".attr_initialize" do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
example = klass.new("Foo", bar: "Bar")
|
42
|
-
example.instance_variable_get("@foo").must_equal "Foo"
|
43
|
-
example.instance_variable_get("@bar").must_equal "Bar"
|
44
|
-
example.instance_variable_get("@baz").must_equal "default baz"
|
42
|
+
_(example.instance_variable_get("@foo")).must_equal "Foo"
|
43
|
+
_(example.instance_variable_get("@bar")).must_equal "Bar"
|
44
|
+
_(example.instance_variable_get("@baz")).must_equal "default baz"
|
45
45
|
|
46
46
|
example = klass.new("Foo", bar: "Bar", baz: "Baz")
|
47
|
-
example.instance_variable_get("@baz").must_equal "Baz"
|
47
|
+
_(example.instance_variable_get("@baz")).must_equal "Baz"
|
48
48
|
end
|
49
49
|
|
50
50
|
it "treats hash values as optional" do
|
@@ -53,10 +53,10 @@ describe Object, ".attr_initialize" do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
example = klass.new("Foo", bar: "Bar")
|
56
|
-
example.instance_variable_defined?("@baz").must_equal false
|
56
|
+
_(example.instance_variable_defined?("@baz")).must_equal false
|
57
57
|
|
58
58
|
example = klass.new("Foo")
|
59
|
-
example.instance_variable_defined?("@bar").must_equal false
|
59
|
+
_(example.instance_variable_defined?("@bar")).must_equal false
|
60
60
|
end
|
61
61
|
|
62
62
|
it "can require hash values" do
|
@@ -65,9 +65,9 @@ describe Object, ".attr_initialize" do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
example = klass.new(required: "X")
|
68
|
-
example.instance_variable_get("@required").must_equal "X"
|
68
|
+
_(example.instance_variable_get("@required")).must_equal "X"
|
69
69
|
|
70
|
-
lambda { klass.new(optional: "X") }.must_raise KeyError
|
70
|
+
_(lambda { klass.new(optional: "X") }).must_raise KeyError
|
71
71
|
end
|
72
72
|
|
73
73
|
it "complains about unknown hash values" do
|
@@ -78,8 +78,8 @@ describe Object, ".attr_initialize" do
|
|
78
78
|
# Should not raise.
|
79
79
|
klass.new("Foo", bar: "Bar", baz: "Baz")
|
80
80
|
|
81
|
-
exception = lambda { klass.new("Foo", bar: "Bar", baz: "Baz", hello: "Hello") }.must_raise ArgumentError
|
82
|
-
exception.message.must_include "[:hello]"
|
81
|
+
exception = _(lambda { klass.new("Foo", bar: "Bar", baz: "Baz", hello: "Hello") }).must_raise ArgumentError
|
82
|
+
_(exception.message).must_include "[:hello]"
|
83
83
|
end
|
84
84
|
|
85
85
|
# Regression.
|
@@ -99,8 +99,8 @@ describe Object, ".attr_initialize" do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
# Provides a hash to "foo" but does not provide "bar".
|
102
|
-
exception = lambda { klass.new({ bar: 123 }) }.must_raise KeyError
|
103
|
-
exception.message.must_include "[:bar]"
|
102
|
+
exception = _(lambda { klass.new({ bar: 123 }) }).must_raise KeyError
|
103
|
+
_(exception.message).must_include "[:bar]"
|
104
104
|
end
|
105
105
|
|
106
106
|
# Regression.
|
@@ -113,7 +113,7 @@ describe Object, ".attr_initialize" do
|
|
113
113
|
# Should not raise.
|
114
114
|
example = klass.new({ "invalid.ivar.name" => 123 })
|
115
115
|
|
116
|
-
example.foo.must_equal({ "invalid.ivar.name" => 123 })
|
116
|
+
_(example.foo).must_equal({ "invalid.ivar.name" => 123 })
|
117
117
|
end
|
118
118
|
|
119
119
|
it "accepts a block for initialization" do
|
@@ -127,6 +127,6 @@ describe Object, ".attr_initialize" do
|
|
127
127
|
|
128
128
|
example = klass.new("expected")
|
129
129
|
|
130
|
-
example.copy.must_equal "expected"
|
130
|
+
_(example.copy).must_equal "expected"
|
131
131
|
end
|
132
132
|
end
|
@@ -11,8 +11,8 @@ describe Object, ".attr_private" do
|
|
11
11
|
example = klass.new
|
12
12
|
example.instance_variable_set("@foo", "Foo")
|
13
13
|
example.instance_variable_set("@bar", "Bar")
|
14
|
-
example.send(:foo).must_equal "Foo"
|
15
|
-
example.send(:bar).must_equal "Bar"
|
16
|
-
lambda { example.foo }.must_raise NoMethodError
|
14
|
+
_(example.send(:foo)).must_equal "Foo"
|
15
|
+
_(example.send(:bar)).must_equal "Bar"
|
16
|
+
_(lambda { example.foo }).must_raise NoMethodError
|
17
17
|
end
|
18
18
|
end
|
@@ -9,7 +9,7 @@ describe Object, ".attr_value" do
|
|
9
9
|
|
10
10
|
example = klass.new
|
11
11
|
example.instance_variable_set("@foo", "Foo")
|
12
|
-
example.foo.must_equal "Foo"
|
12
|
+
_(example.foo).must_equal "Foo"
|
13
13
|
end
|
14
14
|
|
15
15
|
it "does not create writers" do
|
@@ -17,7 +17,7 @@ describe Object, ".attr_value" do
|
|
17
17
|
attr_value :foo
|
18
18
|
end
|
19
19
|
|
20
|
-
lambda { klass.new.foo = "new value" }.must_raise NoMethodError
|
20
|
+
_(lambda { klass.new.foo = "new value" }).must_raise NoMethodError
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "object equality" do
|
@@ -92,21 +92,21 @@ describe Object, ".attr_value" do
|
|
92
92
|
klass1_bar = klass1.new("Bar")
|
93
93
|
klass2_foo = klass2.new("Foo")
|
94
94
|
|
95
|
-
klass1_foo.hash.must_equal klass1_foo2.hash
|
96
|
-
klass1_foo.hash.wont_equal klass1_bar.hash
|
97
|
-
klass1_foo.hash.wont_equal klass2_foo.hash
|
95
|
+
_(klass1_foo.hash).must_equal klass1_foo2.hash
|
96
|
+
_(klass1_foo.hash).wont_equal klass1_bar.hash
|
97
|
+
_(klass1_foo.hash).wont_equal klass2_foo.hash
|
98
98
|
|
99
99
|
assert klass1_foo.eql?(klass1_foo2), "Examples should be 'eql?'"
|
100
100
|
refute klass1_foo.eql?(klass1_bar), "Examples should not be 'eql?'"
|
101
101
|
refute klass1_foo.eql?(klass2_foo), "Examples should not be 'eql?'"
|
102
102
|
|
103
|
-
Set[klass1_foo, klass1_foo2, klass1_bar, klass2_foo].length.must_equal 3
|
103
|
+
_(Set[klass1_foo, klass1_foo2, klass1_bar, klass2_foo].length).must_equal 3
|
104
104
|
|
105
105
|
hash = {}
|
106
106
|
hash[klass1_foo] = :awyeah
|
107
107
|
hash[klass1_bar] = :wat
|
108
108
|
hash[klass2_foo] = :nooooo
|
109
|
-
hash[klass1_foo2].must_equal :awyeah
|
109
|
+
_(hash[klass1_foo2]).must_equal :awyeah
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
@@ -7,11 +7,11 @@ describe AttrExtras::AttrInitialize::ParamsBuilder do
|
|
7
7
|
let(:names) { [ :foo, :bar, [ :baz, :qux!, quux: "Quux" ]] }
|
8
8
|
|
9
9
|
it "properly devides params by the type" do
|
10
|
-
subject.positional_args.must_equal [ :foo, :bar ]
|
11
|
-
subject.hash_args.must_equal [ :baz, :qux!, :quux ]
|
12
|
-
subject.hash_args_names.must_equal [ :baz, :qux, :quux ]
|
13
|
-
subject.hash_args_required.must_equal [ :qux ]
|
14
|
-
subject.default_values.must_equal({ quux: "Quux" })
|
10
|
+
_(subject.positional_args).must_equal [ :foo, :bar ]
|
11
|
+
_(subject.hash_args).must_equal [ :baz, :qux!, :quux ]
|
12
|
+
_(subject.hash_args_names).must_equal [ :baz, :qux, :quux ]
|
13
|
+
_(subject.hash_args_required).must_equal [ :qux ]
|
14
|
+
_(subject.default_values).must_equal({ quux: "Quux" })
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -19,11 +19,11 @@ describe AttrExtras::AttrInitialize::ParamsBuilder do
|
|
19
19
|
let(:names) { [ :foo, :bar] }
|
20
20
|
|
21
21
|
it "properly devides params by the type" do
|
22
|
-
subject.positional_args.must_equal [ :foo, :bar ]
|
23
|
-
subject.hash_args.must_be_empty
|
24
|
-
subject.hash_args_names.must_be_empty
|
25
|
-
subject.hash_args_required.must_be_empty
|
26
|
-
subject.default_values.must_be_empty
|
22
|
+
_(subject.positional_args).must_equal [ :foo, :bar ]
|
23
|
+
_(subject.hash_args).must_be_empty
|
24
|
+
_(subject.hash_args_names).must_be_empty
|
25
|
+
_(subject.hash_args_required).must_be_empty
|
26
|
+
_(subject.default_values).must_be_empty
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -31,11 +31,11 @@ describe AttrExtras::AttrInitialize::ParamsBuilder do
|
|
31
31
|
let(:names) { [[ { baz: "Baz" }, :qux!, { quux: "Quux" } ]] }
|
32
32
|
|
33
33
|
it "properly devides params by the type" do
|
34
|
-
subject.positional_args.must_be_empty
|
35
|
-
subject.hash_args.must_equal [ :baz, :qux!, :quux ]
|
36
|
-
subject.hash_args_names.must_equal [ :baz, :qux, :quux ]
|
37
|
-
subject.hash_args_required.must_equal [ :qux ]
|
38
|
-
subject.default_values.must_equal({ quux: "Quux", baz: "Baz" })
|
34
|
+
_(subject.positional_args).must_be_empty
|
35
|
+
_(subject.hash_args).must_equal [ :baz, :qux!, :quux ]
|
36
|
+
_(subject.hash_args_names).must_equal [ :baz, :qux, :quux ]
|
37
|
+
_(subject.hash_args_required).must_equal [ :qux ]
|
38
|
+
_(subject.default_values).must_equal({ quux: "Quux", baz: "Baz" })
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -43,11 +43,11 @@ describe AttrExtras::AttrInitialize::ParamsBuilder do
|
|
43
43
|
let(:names) { [] }
|
44
44
|
|
45
45
|
it "properly devides params by the type" do
|
46
|
-
subject.positional_args.must_be_empty
|
47
|
-
subject.hash_args.must_be_empty
|
48
|
-
subject.hash_args_names.must_be_empty
|
49
|
-
subject.hash_args_required.must_be_empty
|
50
|
-
subject.default_values.must_be_empty
|
46
|
+
_(subject.positional_args).must_be_empty
|
47
|
+
_(subject.hash_args).must_be_empty
|
48
|
+
_(subject.hash_args_names).must_be_empty
|
49
|
+
_(subject.hash_args_required).must_be_empty
|
50
|
+
_(subject.default_values).must_be_empty
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -7,7 +7,7 @@ describe Object, ".pattr_initialize" do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
example = klass.new("Foo", "Bar")
|
10
|
-
example.send(:foo).must_equal "Foo"
|
10
|
+
_(example.send(:foo)).must_equal "Foo"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "works with hash ivars" do
|
@@ -16,7 +16,7 @@ describe Object, ".pattr_initialize" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
example = klass.new("Foo", bar: "Bar", baz: "Baz")
|
19
|
-
example.send(:baz).must_equal "Baz"
|
19
|
+
_(example.send(:baz)).must_equal "Baz"
|
20
20
|
end
|
21
21
|
|
22
22
|
it "works with hash ivars and default values" do
|
@@ -25,7 +25,7 @@ describe Object, ".pattr_initialize" do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
example = klass.new("Foo")
|
28
|
-
example.send(:baz).must_equal "Baz"
|
28
|
+
_(example.send(:baz)).must_equal "Baz"
|
29
29
|
end
|
30
30
|
|
31
31
|
it "can reference private initializer methods in an initializer block" do
|
@@ -39,7 +39,7 @@ describe Object, ".pattr_initialize" do
|
|
39
39
|
|
40
40
|
example = klass.new("expected")
|
41
41
|
|
42
|
-
example.copy.must_equal "expected"
|
42
|
+
_(example.copy).must_equal "expected"
|
43
43
|
end
|
44
44
|
|
45
45
|
it "accepts the alias attr_private_initialize" do
|
@@ -48,6 +48,6 @@ describe Object, ".pattr_initialize" do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
example = klass.new("Foo", "Bar")
|
51
|
-
example.send(:foo).must_equal "Foo"
|
51
|
+
_(example.send(:foo)).must_equal "Foo"
|
52
52
|
end
|
53
53
|
end
|
@@ -7,7 +7,7 @@ describe Object, ".rattr_initialize" do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
example = klass.new("Foo", "Bar")
|
10
|
-
example.public_send(:foo).must_equal "Foo"
|
10
|
+
_(example.public_send(:foo)).must_equal "Foo"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "works with hash ivars" do
|
@@ -16,7 +16,7 @@ describe Object, ".rattr_initialize" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
example = klass.new("Foo", bar: "Bar", baz: "Baz")
|
19
|
-
example.public_send(:baz).must_equal "Baz"
|
19
|
+
_(example.public_send(:baz)).must_equal "Baz"
|
20
20
|
end
|
21
21
|
|
22
22
|
it "works with hash ivars and default values" do
|
@@ -25,7 +25,7 @@ describe Object, ".rattr_initialize" do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
example = klass.new("Foo")
|
28
|
-
example.send(:baz).must_equal "Baz"
|
28
|
+
_(example.send(:baz)).must_equal "Baz"
|
29
29
|
end
|
30
30
|
|
31
31
|
it "accepts the alias attr_reader_initialize" do
|
@@ -34,6 +34,6 @@ describe Object, ".rattr_initialize" do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
example = klass.new("Foo", "Bar")
|
37
|
-
example.public_send(:foo).must_equal "Foo"
|
37
|
+
_(example.public_send(:foo)).must_equal "Foo"
|
38
38
|
end
|
39
39
|
end
|
@@ -5,15 +5,15 @@ describe AttrExtras::Utils do
|
|
5
5
|
subject { AttrExtras::Utils.flat_names(names) }
|
6
6
|
|
7
7
|
it "strips any bangs from a flat list of arguments" do
|
8
|
-
AttrExtras::Utils.flat_names([ :foo, :bar! ]).must_equal [ "foo", "bar" ]
|
8
|
+
_(AttrExtras::Utils.flat_names([ :foo, :bar! ])).must_equal [ "foo", "bar" ]
|
9
9
|
end
|
10
10
|
|
11
11
|
it "flattens hash arguments and strips any bangs" do
|
12
|
-
AttrExtras::Utils.flat_names([ :foo, [ :bar, :baz! ] ]).must_equal [ "foo", "bar", "baz" ]
|
12
|
+
_(AttrExtras::Utils.flat_names([ :foo, [ :bar, :baz! ] ])).must_equal [ "foo", "bar", "baz" ]
|
13
13
|
end
|
14
14
|
|
15
15
|
it "flattens hash arguments with defaults and strips any bangs" do
|
16
|
-
AttrExtras::Utils.flat_names([ :foo, [ bar: "Bar", baz!: "Baz"] ]).must_equal [ "foo", "bar", "baz" ]
|
16
|
+
_(AttrExtras::Utils.flat_names([ :foo, [ bar: "Bar", baz!: "Baz"] ])).must_equal [ "foo", "bar", "baz" ]
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -9,8 +9,8 @@ describe Object, ".vattr_initialize" do
|
|
9
9
|
example1 = klass.new("Foo", "Bar")
|
10
10
|
example2 = klass.new("Foo", "Bar")
|
11
11
|
|
12
|
-
example1.foo.must_equal "Foo"
|
13
|
-
example1.must_equal example2
|
12
|
+
_(example1.foo).must_equal "Foo"
|
13
|
+
_(example1).must_equal example2
|
14
14
|
end
|
15
15
|
|
16
16
|
it "works with hash ivars" do
|
@@ -20,8 +20,8 @@ describe Object, ".vattr_initialize" do
|
|
20
20
|
|
21
21
|
example1 = klass.new("Foo", bar: "Bar", baz: "Baz")
|
22
22
|
example2 = klass.new("Foo", bar: "Bar", baz: "Baz")
|
23
|
-
example1.baz.must_equal "Baz"
|
24
|
-
example1.must_equal example2
|
23
|
+
_(example1.baz).must_equal "Baz"
|
24
|
+
_(example1).must_equal example2
|
25
25
|
end
|
26
26
|
|
27
27
|
it "works with hash ivars and default values" do
|
@@ -31,8 +31,8 @@ describe Object, ".vattr_initialize" do
|
|
31
31
|
|
32
32
|
example1 = klass.new("Foo")
|
33
33
|
example2 = klass.new("Foo")
|
34
|
-
example1.baz.must_equal "Baz"
|
35
|
-
example1.must_equal example2
|
34
|
+
_(example1.baz).must_equal "Baz"
|
35
|
+
_(example1).must_equal example2
|
36
36
|
end
|
37
37
|
|
38
38
|
it "can accept an initializer block" do
|
@@ -45,7 +45,7 @@ describe Object, ".vattr_initialize" do
|
|
45
45
|
|
46
46
|
klass.new("expected")
|
47
47
|
|
48
|
-
called.must_equal true
|
48
|
+
_(called).must_equal true
|
49
49
|
end
|
50
50
|
|
51
51
|
it "accepts the alias attr_value_initialize" do
|
@@ -56,7 +56,7 @@ describe Object, ".vattr_initialize" do
|
|
56
56
|
example1 = klass.new("Foo", "Bar")
|
57
57
|
example2 = klass.new("Foo", "Bar")
|
58
58
|
|
59
|
-
example1.foo.must_equal "Foo"
|
60
|
-
example1.must_equal example2
|
59
|
+
_(example1.foo).must_equal "Foo"
|
60
|
+
_(example1).must_equal example2
|
61
61
|
end
|
62
62
|
end
|
data/spec/attr_extras_spec.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attr_extras
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.2.
|
4
|
+
version: 6.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik Nyh
|
8
8
|
- Joakim Kolsjö
|
9
|
+
- Tomas Skogberg
|
9
10
|
- Victor Arias
|
10
11
|
- Ola K
|
11
12
|
autorequire:
|
12
13
|
bindir: bin
|
13
14
|
cert_chain: []
|
14
|
-
date:
|
15
|
+
date: 2020-01-07 00:00:00.000000000 Z
|
15
16
|
dependencies:
|
16
17
|
- !ruby/object:Gem::Dependency
|
17
18
|
name: minitest
|
@@ -117,8 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
- !ruby/object:Gem::Version
|
118
119
|
version: '0'
|
119
120
|
requirements: []
|
120
|
-
|
121
|
-
rubygems_version: 2.6.11
|
121
|
+
rubygems_version: 3.0.3
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Takes some boilerplate out of Ruby with methods like attr_initialize.
|