Thank you!, Alexey, this is what I need.
Now I have located in the docs (and I have understood) the "Current
transaction" attribute. Here is the link, just in caso someone else needs
it in the future: http://mojolicio.us/perldoc/Test/Mojo#tx
Regards:
Nacho B.
On Wednesday, March 25, 2015 at 8:02:15 PM UTC+1, Alexey Stavrov wrote:
>
> $t->get_ok($your_url)->status_is(...);
> my $id = $t->tx->res->json->{your_key};
> $t->get_ok("/users/$id")->status_is(...);
>
>
>
> среда, 25 марта 2015 г., 23:30:02 UTC+5 пользователь Nacho B написал:
>>
>> I am trying to make tests for a CRUD app. So after testing if a record
>> has been created, I want to test how it is displayed and then test if it
>> can be deleted succesfully.
>>
>> In the create record function I get the id (using PostgreSql's RETURNING)
>> and a 'OK' through JSON.
>>
>> I can test those values using this test:
>>
>> $t->post_ok('/users' => form => {alias => 'TESTING USER ALIAS'})
>> ->status_is(200)
>> ->header_is('content-type' => 'application/json')
>> ->json_has( 'result' => 'OK' )
>> ->json_like( '*last_id*' => qr/\d/ )
>> ;
>>
>>
>> Now I want to make the tests for the display and the deletion, something
>> like:
>>
>> $t->get_ok('/users/*15*')
>> ->status_is(200)
>> ->content_like(qr /TESTING USER ALIAS/)
>> ;
>>
>>
>> But I need the *last_id* value that returns (*15*, in my example), a
>> variable that I can somehow chain from a test to the next.
>>
>>
>> Any suggestions?
>>
>> Regards:
>> Nacho B
>>
>
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.