build concerns, build matrix
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Api::BuildsController, type: :request do
|
||||
describe "GET /api/builds" do
|
||||
it "returns the global build matrix" do
|
||||
get "/api/builds"
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
json = JSON.parse(response.body)
|
||||
expect(json["platforms"]).to be_a(Hash)
|
||||
expect(json["platforms"]["tic80"]["label"]).to eq("TIC-80")
|
||||
expect(json["platforms"]["tic80"]["kinds"]).to include("cartridge")
|
||||
expect(json["allKinds"]).to be_an(Array)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,29 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Api::SoftwareBuildsController, type: :request do
|
||||
describe "GET /api/softwares/:name/builds" do
|
||||
let!(:software) { create(:software, name: "test-game", platform: "love") }
|
||||
let!(:release) { create(:release, software: software, version: "2.0.0") }
|
||||
|
||||
before do
|
||||
ReleaseAsset.create!(release: release, kind: "html", path: "/test/html")
|
||||
end
|
||||
|
||||
it "returns per-software build info" do
|
||||
get "/api/softwares/test-game/builds"
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
json = JSON.parse(response.body)
|
||||
expect(json["platform"]).to eq("love")
|
||||
expect(json["expected"]).to include("html", "win_x64")
|
||||
expect(json["releases"]["2.0.0"]["actual"]).to include("html")
|
||||
expect(json["releases"]["2.0.0"]["missing"]).to include("win_x64")
|
||||
end
|
||||
|
||||
it "returns 404 for unknown software" do
|
||||
get "/api/softwares/nonexistent/builds"
|
||||
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,50 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe BuildsService do
|
||||
describe "#index" do
|
||||
subject(:result) { described_class.new.index }
|
||||
|
||||
it "returns all supported platforms with expected kinds" do
|
||||
expect(result[:platforms]).to have_key("tic80")
|
||||
expect(result[:platforms]["tic80"][:label]).to eq("TIC-80")
|
||||
expect(result[:platforms]["tic80"][:kinds]).to include("cartridge", "html")
|
||||
end
|
||||
|
||||
it "returns c64 with only cartridge" do
|
||||
expect(result[:platforms]["c64"][:kinds]).to eq(["cartridge"])
|
||||
end
|
||||
|
||||
it "returns allKinds matching ReleaseAsset::KINDS" do
|
||||
expect(result[:allKinds]).to eq(ReleaseAsset::KINDS)
|
||||
end
|
||||
|
||||
it "includes all supported platforms" do
|
||||
UpdateService::SUPPORTED_PLATFORMS.each do |platform|
|
||||
expect(result[:platforms]).to have_key(platform)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#show" do
|
||||
let!(:software) { create(:software, name: "test-game", platform: "love") }
|
||||
let!(:release) { create(:release, software: software, version: "1.0.0") }
|
||||
|
||||
before do
|
||||
ReleaseAsset.create!(release: release, kind: "html", path: "/test/html")
|
||||
ReleaseAsset.create!(release: release, kind: "win_x64", path: "/test/win")
|
||||
end
|
||||
|
||||
it "returns expected and actual kinds per release" do
|
||||
result = described_class.new.show("test-game")
|
||||
|
||||
expect(result[:platform]).to eq("love")
|
||||
expect(result[:expected]).to match_array(%w[html win_x64 linux_x64 mac_universal])
|
||||
expect(result[:releases]["1.0.0"][:actual]).to match_array(%w[html win_x64])
|
||||
expect(result[:releases]["1.0.0"][:missing]).to match_array(%w[linux_x64 mac_universal])
|
||||
end
|
||||
|
||||
it "raises RecordNotFound for unknown software" do
|
||||
expect { described_class.new.show("nonexistent") }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -63,11 +63,17 @@ RSpec.describe SoftwareUpdater::Tic80Service do
|
||||
|
||||
it "registers binary assets when slug zips are present" do
|
||||
write_zip("#{versioned}-win-x64.zip", "game.exe" => "MZ")
|
||||
write_zip("#{versioned}-mac-universal.zip", "game" => "bin")
|
||||
write_zip("#{versioned}-mac-x64.zip", "game" => "bin")
|
||||
|
||||
release = described_class.new.update(name, version)
|
||||
|
||||
expect(asset_kinds(release)).to include("win_x64", "mac_universal")
|
||||
expect(asset_kinds(release)).to include("win_x64", "mac_x64")
|
||||
expect(asset_kinds(release)).not_to include("linux_x64")
|
||||
end
|
||||
|
||||
it "exposes expected_kinds from included Build concerns" do
|
||||
expect(described_class.expected_kinds).to match_array(
|
||||
%w[cartridge source html docs win_x64 linux_x64 mac_x64]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user