mirror of
https://gitea.invidious.io/iv-org/shard-kilt.git
synced 2024-08-15 00:43:15 +00:00
Initial commit
This commit is contained in:
commit
f31dad17d7
12 changed files with 176 additions and 0 deletions
1
spec/fixtures/test.ecr
vendored
Normal file
1
spec/fixtures/test.ecr
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<span><%= Process.pid %></span>
|
1
spec/fixtures/test.slang
vendored
Normal file
1
spec/fixtures/test.slang
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
span = Process.pid
|
27
spec/kilt_spec.cr
Normal file
27
spec/kilt_spec.cr
Normal file
|
@ -0,0 +1,27 @@
|
|||
require "./spec_helper"
|
||||
|
||||
class View
|
||||
Kilt.file "spec/fixtures/test.ecr"
|
||||
end
|
||||
|
||||
describe Kilt do
|
||||
|
||||
it "renders ecr" do
|
||||
render_file("spec/fixtures/test.ecr").should eq("<span>#{Process.pid}</span>")
|
||||
end
|
||||
|
||||
it "renders slang" do
|
||||
render_file("spec/fixtures/test.slang").should eq("<span>#{Process.pid}</span>")
|
||||
end
|
||||
|
||||
it "works with classes" do
|
||||
View.new.to_s.should eq("<span>#{Process.pid}</span>")
|
||||
end
|
||||
|
||||
it "raises with unsupported filetype" do
|
||||
expect_raises(Kilt::Exception, "Unsupported template type \"abc\"") {
|
||||
render_file("test.abc")
|
||||
}
|
||||
end
|
||||
|
||||
end
|
9
spec/spec_helper.cr
Normal file
9
spec/spec_helper.cr
Normal file
|
@ -0,0 +1,9 @@
|
|||
require "spec"
|
||||
require "slang"
|
||||
require "../src/kilt"
|
||||
|
||||
macro render_file(filename)
|
||||
String.build do |__io__|
|
||||
Kilt.embed({{filename}}, "__io__")
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue