File tree 2 files changed +32
-0
lines changed
2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,12 @@ def leading_comments
8
8
def trailing_comments
9
9
@trailing_comments ||= [ ]
10
10
end
11
+
12
+ def leading_comments = ( comments )
13
+ @leading_comments = Array ( comments )
14
+ end
15
+
16
+ def trailing_comments = ( comments )
17
+ @trailing_comments = Array ( comments )
18
+ end
11
19
end
Original file line number Diff line number Diff line change 8
8
node = Psych ::Nodes ::Scalar . new ( "foo" )
9
9
expect ( node . leading_comments ) . to eq ( [ ] )
10
10
end
11
+
12
+ it "can be set with an array of comments" do
13
+ node = Psych ::Nodes ::Scalar . new ( "foo" )
14
+ node . leading_comments = [ "# Comment 1" , "# Comment 2" ]
15
+ expect ( node . leading_comments ) . to eq ( [ "# Comment 1" , "# Comment 2" ] )
16
+ end
17
+
18
+ it "wraps non-array values in an array" do
19
+ node = Psych ::Nodes ::Scalar . new ( "foo" )
20
+ node . leading_comments = "# Single comment"
21
+ expect ( node . leading_comments ) . to eq ( [ "# Single comment" ] )
22
+ end
11
23
end
12
24
13
25
describe "#trailing_comments" do
14
26
it "has an array" do
15
27
node = Psych ::Nodes ::Scalar . new ( "foo" )
16
28
expect ( node . trailing_comments ) . to eq ( [ ] )
17
29
end
30
+
31
+ it "can be set with an array of comments" do
32
+ node = Psych ::Nodes ::Scalar . new ( "foo" )
33
+ node . trailing_comments = [ "# Comment 1" , "# Comment 2" ]
34
+ expect ( node . trailing_comments ) . to eq ( [ "# Comment 1" , "# Comment 2" ] )
35
+ end
36
+
37
+ it "wraps non-array values in an array" do
38
+ node = Psych ::Nodes ::Scalar . new ( "foo" )
39
+ node . trailing_comments = "# Single comment"
40
+ expect ( node . trailing_comments ) . to eq ( [ "# Single comment" ] )
41
+ end
18
42
end
19
43
end
You can’t perform that action at this time.
0 commit comments