File tree 3 files changed +15
-2
lines changed
3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
22
22
- Rubocop expected syntax downgraded from ruby 2.6 to 2.5
23
23
- ` assertEqual() ` and ` assertNotEqual() ` use actual ` == ` and ` != ` -- they no longer require a type to be totally ordered just to do equality tests
24
24
- Evaluative assertions (is true/false/null/etc) now produce simpler error messages instead of masquerading as an operation (e.g. "== true")
25
+ - ` LibraryProperties.to_h ` now properly uses formatters and symbolic keys, in order to support a ` .to_s `
25
26
26
27
### Deprecated
27
28
Original file line number Diff line number Diff line change @@ -24,7 +24,12 @@ def initialize(path)
24
24
25
25
# @return [Hash] the properties as a hash, all strings
26
26
def to_h
27
- @fields . clone
27
+ Hash [ @fields . map { |k , _ | [ k . to_sym , send ( k ) ] } ]
28
+ end
29
+
30
+ # @return [String] the string representation
31
+ def to_s
32
+ to_h . to_s
28
33
end
29
34
30
35
# Enable a shortcut syntax for library property accessors, in the style of `attr_accessor` metaprogramming.
Original file line number Diff line number Diff line change 46
46
it "doesn't crash on nonexistent fields" do
47
47
expect ( library_properties . dot_a_linkage ) . to be ( nil )
48
48
end
49
+
50
+ it "converts to hash" do
51
+ h = library_properties . to_h
52
+ expect ( h [ :name ] . class ) . to eq ( String )
53
+ expect ( h [ :name ] ) . to eq ( "WebServer" )
54
+ expect ( h [ :architectures ] . class ) . to eq ( Array )
55
+ expect ( h [ :architectures ] ) . to contain_exactly ( "avr" )
56
+ end
49
57
end
50
58
51
59
context "Input handling" do
65
73
end
66
74
end
67
75
68
-
69
76
end
You can’t perform that action at this time.
0 commit comments