Ruby Forum RSpec > RSpec for testing REST webservices? (Not Rails)

Posted by Erik Terpstra (eterps)
on 21.05.2008 22:51
(Received via mailing list)
Hi,

I am new to RSpec and BDD.
I was wondering if RSpec specifications are a good solution for testing
REST webservices (not implemented in Rails).
If so, what would be a good way to test something like the API described
below?

===========

GET http://localhost/workflow text/xml

Result: 200 OK

    <?xml version="1.0"?>
    <workflows>
        <workflow>flow1</workflow>
        <workflow>flow2</workflow>
        <workflow>flow3</workflow>
    </workflows>


POST http://localhost/workflow?name=flow4 text/xml

Data:

    <?xml version="1.0"?>
    <workflow>
        <monitor type="page" priority="0">
            <provides result="test"/>
        </monitor>
        <process command="test" id="test" weight="100">
            <needs result="test"/>
            <provides result="test_result"/>
            <error result="error"/>
        </process>
    </workflow>

Result: 201 Created


GET http://localhost/workflow text/xml

Result: 200 OK

    <?xml version="1.0"?>
    <workflows>
        <workflow>flow1</workflow>
        <workflow>flow2</workflow>
        <workflow>flow3</workflow>
        <workflow>flow4</workflow>
    </workflows>


GET http://localhost/workflow/flow4 text/xml

Result: 200 OK

    <?xml version="1.0"?>
    <workflow>
        <monitor type="page" priority="0">
            <provides result="test"/>
        </monitor>
        <process command="test" id="test" weight="100">
            <needs result="test"/>
            <provides result="test_result"/>
            <error result="error"/>
        </process>
    </workflow>


DELETE http://localhost/workflow/flow3

Result: 204 No Content


GET http://localhost/workflow text/xml

Result: 200 OK

    <?xml version="1.0"?>
    <workflows>
        <workflow>flow1</workflow>
        <workflow>flow2</workflow>
        <workflow>flow4</workflow>
    </workflows>

=====

TIA,

Erik.
Posted by Pol Llovet (pol)
on 06.06.2008 18:20
I am interested in this also, anyone out there have some best practices?
Posted by Yi Wen (hayafirst)
on 06.06.2008 19:17
(Received via mailing list)
I use http-access2 (http://dev.ctor.org/http-access2) for make requests.
I also have a custom WebServiceExampleGroup to do setup work there.