From 4636ecc53ca6078acb94367a8ec61e9da8376ad0 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Fri, 20 Dec 2024 12:00:49 +0530 Subject: [PATCH] Test expectations against specific items --- spec/jekyll-admin/server/data_spec.rb | 2 +- spec/jekyll-admin/server/theme_spec.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/jekyll-admin/server/data_spec.rb b/spec/jekyll-admin/server/data_spec.rb index 313662d46..43dbf805f 100644 --- a/spec/jekyll-admin/server/data_spec.rb +++ b/spec/jekyll-admin/server/data_spec.rb @@ -31,7 +31,7 @@ def app it "gets the index" do get "/data" expect(last_response).to be_ok - expect(last_response_parsed[2]).to eql(base_response) + expect(last_response_parsed.find { |file| file["slug"] == "data_file" }).to eql(base_response) end it "gets an individual data file" do diff --git a/spec/jekyll-admin/server/theme_spec.rb b/spec/jekyll-admin/server/theme_spec.rb index b0ecba1e2..f1890bcab 100644 --- a/spec/jekyll-admin/server/theme_spec.rb +++ b/spec/jekyll-admin/server/theme_spec.rb @@ -57,7 +57,9 @@ def app get "/theme/_layouts" expect(last_response).to be_ok expect(last_response_parsed["name"]).to eq("_layouts") - expect(last_response_parsed["entries"].first).to eq(expected) + expect( + last_response_parsed["entries"].find { |layout| layout["name"] == "default.html" } + ).to eq(expected) end it "returns subdirectories" do @@ -69,7 +71,9 @@ def app } get "/theme/assets/images" expect(last_response).to be_ok - expect(last_response_parsed["entries"].first).to eq(expected) + expect( + last_response_parsed["entries"].find { |img| img["name"] == "icon-dark.png" } + ).to eq(expected) end end