Skip to content

Commit 37a8c29

Browse files
committed
spec: spec_helpers
1 parent d68a42d commit 37a8c29

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

spec/spec_helpers.cr

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# -----------------------------------------------------------------------
2+
# This file is part of MoonScript
3+
#
4+
# MoonSript is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# MoonSript is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with MoonSript. If not, see <https://www.gnu.org/licenses/>.
16+
#
17+
# Copyright (C) 2025 Krisna Pranav, MoonScript Developers
18+
# -----------------------------------------------------------------------
19+
20+
def expect_diff(a, b)
21+
a.should eq(b)
22+
rescue error
23+
fail diff(a, b)
24+
end
25+
26+
def diff(a, b)
27+
file1 = File.tempfile do |file|
28+
file.puts a.strip
29+
file.flush
30+
end
31+
32+
io = IO::Memory.new
33+
34+
Process.run("git", [
35+
"--no-pages", "diff", "--no-index",
36+
file1.path,
37+
], output: io)
38+
39+
io.to_s
40+
end
41+
42+
def matches_template(template, expected)
43+
expected = expected.uncolarize
44+
45+
parts = template.split(/x*/)
46+
47+
end

0 commit comments

Comments
 (0)