[rspec-users] Testing REST webservices? (Not Rails)

Erik Terpstra erik at ruby-lang.nl
Wed May 21 16:37:17 EDT 2008


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.


More information about the rspec-users mailing list