Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

json - why does Rspec increment return of called application

I have an RSpec test currently written on an application that 100% works, it current returns exactly what I want.

The application call method returns a Json list and the test I have is then supposed to check if certain elements are equal to an equivalent Json passed in. Simple right?

describe App do
   subject(:jsonlist) do
   final_json = App.call(json)
   JSON.load(final_json)
end

it "checks the json" do
  expect(jsonlist[2]["num"].to eq "10.00")
end 

It works fine for one test. But after that, Rspec calls the application again and again, adding the data on top of the existing json elements (10 becomes 20, 30, 160 whatever).

Anyone got any ideas why this is happening and how I can get Rspec to stop calling the application when I only need it to call the returned data once?

Many thanks in advance. My apologies for any confusion, I'm still new here

question from:https://stackoverflow.com/questions/66056012/why-does-rspec-increment-return-of-called-application

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...