Skip to content

Commit

Permalink
chore: add all round-trip specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldtse committed Oct 19, 2024
1 parent d65512a commit b4d7455
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions spec/metaschema_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
fixtures_dir = Pathname.new(__dir__).join("fixtures")

describe "XML round-trip conversion" do
# xml_files = Dir[fixtures_dir.join("xml", "*.xml", "*.gc")]
xml_files = [
"spec/fixtures/metaschema/test-suite/schema-generation/allowed-values/allowed-values-basic_metaschema.xml",
# add more later
]
xml_files = Dir[fixtures_dir.join("metaschema/test-suite/schema-generation", "**", "*_metaschema.xml")] +
Dir[fixtures_dir.join("metaschema/examples", "*.xml")] +
Dir[fixtures_dir.join("metaschema/worked-examples", "**", "*.xml")]

# xml_files = [
# "spec/fixtures/metaschema/test-suite/schema-generation/allowed-values/allowed-values-basic_metaschema.xml",
# # add more later
# ]

def check_parsed_content(parsed, reparsed)
%i(
Expand All @@ -27,8 +30,8 @@ def check_parsed_content(parsed, reparsed)
end

xml_files.each do |file_path|
# context "with file #{Pathname.new(file_path).relative_path_from(fixtures_dir)}" do
context "with file #{file_path}" do
context "with file #{Pathname.new(file_path).relative_path_from(fixtures_dir)}" do
# context "with file #{file_path}" do
let(:xml_string) { File.read(file_path) }

it "provides identical attribute access" do
Expand All @@ -51,12 +54,14 @@ def check_parsed_content(parsed, reparsed)
encoding: "utf-8",
)

cleaned_xml_string = xml_string.gsub(/^<\?xml-model.*\n/, "")
cleaned_xml_string = xml_string.
gsub(/^<\?xml-model.*\n/, "").
gsub(/^<\?xml-stylesheet.*\n/, "")

puts "original---------"
puts cleaned_xml_string
puts "------"
puts generated
# puts "original---------"
# puts cleaned_xml_string
# puts "------"
# puts generated

expect(generated).to be_analogous_with(cleaned_xml_string)
end
Expand Down

0 comments on commit b4d7455

Please sign in to comment.