samhuri.net/test/site_test.rb
Sami Samhuri 6eec569358
Rename spec suite to test and remove RSpec-era traces
Move Minitest files from spec/ to test/ and update bake tasks

to discover and run tests from test/**/*_test.rb.

Update README and AGENTS guidance to reference test/ and tests,

and drop the obsolete spec/examples.txt ignore entry.
2026-02-07 21:15:29 -08:00

52 lines
1.5 KiB
Ruby

require "test_helper"
require "tmpdir"
class Pressa::SiteTest < Minitest::Test
def test_url_helpers
site = Pressa::Site.new(
author: "Sami Samhuri",
email: "sami@samhuri.net",
title: "samhuri.net",
description: "blog",
url: "https://samhuri.net",
image_url: "https://images.example.net"
)
assert_equal("https://samhuri.net/posts", site.url_for("/posts"))
assert_equal("https://images.example.net/avatar.png", site.image_url_for("/avatar.png"))
end
def test_image_url_for_returns_nil_when_image_url_not_configured
site = Pressa::Site.new(
author: "Sami Samhuri",
email: "sami@samhuri.net",
title: "samhuri.net",
description: "blog",
url: "https://samhuri.net"
)
assert_nil(site.image_url_for("/avatar.png"))
end
def test_create_site_builds_site_using_loader
Dir.mktmpdir do |dir|
File.write(File.join(dir, "site.toml"), <<~TOML)
author = "Sami Samhuri"
email = "sami@samhuri.net"
title = "samhuri.net"
description = "blog"
url = "https://samhuri.net"
TOML
File.write(File.join(dir, "projects.toml"), <<~TOML)
[[projects]]
name = "demo"
title = "demo"
description = "demo project"
url = "https://github.com/samsonjs/demo"
TOML
site = Pressa.create_site(source_path: dir, url_override: "https://beta.samhuri.net")
assert_equal("https://beta.samhuri.net", site.url)
end
end
end