File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,12 @@ def leading_comments
88 def trailing_comments
99 @trailing_comments ||= [ ]
1010 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
1119end
Original file line number Diff line number Diff line change 88 node = Psych ::Nodes ::Scalar . new ( "foo" )
99 expect ( node . leading_comments ) . to eq ( [ ] )
1010 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
1123 end
1224
1325 describe "#trailing_comments" do
1426 it "has an array" do
1527 node = Psych ::Nodes ::Scalar . new ( "foo" )
1628 expect ( node . trailing_comments ) . to eq ( [ ] )
1729 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
1842 end
1943end
You can’t perform that action at this time.
0 commit comments