Skip to content

Commit

Permalink
tests: refactor JSON output test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjrice committed Apr 11, 2024
1 parent cd631f7 commit dc38f61
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions spec/atco_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
expect(Atco::VERSION).not_to be nil
end

it "should output file for debugging!" do
result = Atco.parse("spec/fixtures/example.cif")
File.open("test.output", "w+") do |f|
f.flush
f.write(JSON.pretty_generate(result))
end
end

it "should parse header from fixture" do
result = Atco.parse("spec/fixtures/example.cif")
expect(result[:header]).to eq({
Expand Down Expand Up @@ -171,5 +163,19 @@
it "should parse 2 locations" do
expect(@atco[:locations].size).to eq(2)
end

it "should output file as JSON" do
output = File.join(File.dirname(__FILE__), "test.output")
File.open(output, "w+") do |f|
f.flush
f.write(JSON.pretty_generate(@atco))
end

expect(File.exist?(output)).to be true

data = File.read(output)
json = JSON.parse(data)
expect(json).to be_a(Hash)
end
end
end

0 comments on commit dc38f61

Please sign in to comment.