Simplify with extracted helper method

This commit is contained in:
Maikel Linke
2023-06-28 14:08:10 +10:00
parent d21e6f99bb
commit 78d6d129e8
3 changed files with 10 additions and 4 deletions

View File

@@ -103,7 +103,7 @@ describe "CatalogItems", type: :request, swagger_doc: "dfc-v1.7/swagger.yaml",
consumes "application/json"
parameter name: :catalog_item, in: :body, schema: {
example: JSON.parse(DfcProvider::Engine.root.join("spec/support/patch_catalog_item.json").read)
example: ExampleJson.read("patch_catalog_item")
}
before { product }

View File

@@ -103,9 +103,7 @@ describe "SuppliedProducts", type: :request, swagger_doc: "dfc-v1.7/swagger.yaml
parameter name: :supplied_product, in: :body, schema: {}
let(:id) { variant.id }
let(:supplied_product) do
JSON.parse(DfcProvider::Engine.root.join("spec/support/patch_supplied_product.json").read)
end
let(:supplied_product) { ExampleJson.read("patch_supplied_product") }
response "401", "unauthorized" do
before { login_as nil }

View File

@@ -0,0 +1,8 @@
# frozen_string_literal: true
module ExampleJson
def self.read(name)
pathname = DfcProvider::Engine.root.join("spec/support/#{name}.json")
JSON.parse(pathname.read)
end
end