Skip to content

Instantly share code, notes, and snippets.

@kevinswiber
Last active August 29, 2015 13:55
Show Gist options
  • Save kevinswiber/8696975 to your computer and use it in GitHub Desktop.
Save kevinswiber/8696975 to your computer and use it in GitHub Desktop.
Exploring hypermedia aware acceptance testing.
Feature: Root Resource
As an API client
I want to see the root resource
So that I have a starting point to complete my task.
Scenario: Request the root
Given an anonymous client
When I make a GET request to /
Then I should get a 200 status code
And the content type should be JSON
Scenario: Request the hypermedia root
Given an anonymous client
When I make a request to the root URI
Then the request should succeed
And the response media type should be Siren
And the response should include a self link
@kevinswiber
Copy link
Author

The "Request the root" scenario is something you might find in a non-hypermedia test. The "Request the hypermedia root" scenario is my first stab at making it hypermedia-ish.

@zdne
Copy link

zdne commented Jan 29, 2014

Sorry for this bothering theme: but what about "ignore" hypermedia and step away from HTTP like so:

    Scenario: Request the API root
            Given an anonymous client
            When I make a request to the API root
            Then the request should succeed
            And the response media type should be Siren
            And the response should include a self link

@kevinswiber
Copy link
Author

@zdne

Certainly. The only reason I made the distinction of "hypermedia" in the scenario is because I'm actually executing the specifications and needed a way to distinguish between the two. :)

This is still riddled with technical details that are irrelevant to the domain. Of course, I have a lot more experience writing automated acceptance tests for domain logic, not APIs. When the reader happens to be a developer, perhaps this is perfectly acceptable. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment