lundi 27 février 2017

Can I use rack-test for deployment tests?

I've built a simple api in Sinatra, with the purpose of setting up a deployment pipeline using Docker. I'm at a stage where I could easily switch Sinatra for something else and there's currently one reason why I might do so.

I once wrote an api using Express and it was trivial to reuse the tests to test a deployment:

# Testing the code
chai.request(app)
  .get('/')

# Testing a deployment
chai.request('http://localhost:8080')
  .get('/')

Examples from: http://ift.tt/2ls7cVe

Now I am wondering if I can accomplish the same with rack-test and Sinatra. Simply sending a URL, instead of the app, crashes. So is there an easy way to accomplish this? I suppose I could write a testing framework on top of rack-test, but I'm not sure it's worth it, even though I do prefer Ruby over Javascript and Sinatra over Express.

Aucun commentaire:

Enregistrer un commentaire