Domanda

I wonder how should I test rails api with dredd, specially the show and index actions(/post{id} and /post)

  1. Should I fill my database with records before running dredd, I mean creating record post with id: 1 and so on?
  2. Does dredd always trying to get object with id: 1 ( /post/1 )?

I found example project https://github.com/theodorton/dredd-test-rails but there is only one method(post) described in apib file https://github.com/theodorton/dredd-test-rails/blob/master/apiary.apib

È stato utile?

Soluzione

Ad 1: Yes, you pretty much want to fill it with some data prior running Dredd (and clean it later). OR you can rely on the order of operations using the --sorted flag while launching Dredd (so a POST called before GET will create the data).

Ad 2: Your findings are indeed correct. What Dredd uses when calling an URI with parameter in is is the example value as stated in the blueprint. For example it will use 0 in call to /folders/{id} as defined here https://github.com/zdne/todoapi/blob/master/apiary.apib#L41

Edit:

All Dredd does at the moment is really taking your endpoints as specified in blueprint and calling them with examples values as stated in the blueprint.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top