From 8139c80321d597dc064fae80d4557df08b887850 Mon Sep 17 00:00:00 2001 From: Tomas Aparicio Date: Wed, 8 Mar 2017 00:47:00 +0000 Subject: [PATCH] feat(docs): add example docs --- README.rst | 9 +++++---- docs/examples.rst | 14 ++++++++++++++ docs/index.rst | 1 + grappa_http/operators/status.py | 3 ++- 4 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 docs/examples.rst diff --git a/README.rst b/README.rst index 5010ba1..564747b 100755 --- a/README.rst +++ b/README.rst @@ -6,12 +6,12 @@ |Build Status| |PyPI| |Coverage Status| |Documentation Status| |Stability| |Quality| |Versions| -grappa-http ------------ +About +----- -`grappa`_ plugin for HTTP assertions. +HTTP assertions plugin for `grappa`_. -To get started, take a look to the `documentation`_ and `tutorial`_. +To get started, take a look to the `documentation`_, `tutorial`_ and `examples`_. Features -------- @@ -48,6 +48,7 @@ Or install the latest sources from Github: .. _`grappa`: https://grappa.readthedocs.io .. _`documentation`: http://grappa-http.readthedocs.io .. _`tutorial`: http://grappa-http.readthedocs.io/en/latest/tutorial.html +.. _`examples`: http://grappa-http.readthedocs.io/en/latest/examples.html .. |Build Status| image:: https://travis-ci.org/grappa-python/grappa-http.svg?branch=master :target: https://travis-ci.org/grappa-python/grappa-http diff --git a/docs/examples.rst b/docs/examples.rst new file mode 100644 index 0000000..bf09768 --- /dev/null +++ b/docs/examples.rst @@ -0,0 +1,14 @@ +Examples +======== + +Basic response assertion +------------------------ + +.. code-block:: python + + + res = requests.get('http://httpbin.org/status/204') + res | should.be.response.status(204) + + # Or alternatively using the string notation + res | should.be.response.status('No Content') diff --git a/docs/index.rst b/docs/index.rst index 52803bf..0654806 100755 --- a/docs/index.rst +++ b/docs/index.rst @@ -6,6 +6,7 @@ Contents intro tutorial + examples operators api contributing diff --git a/grappa_http/operators/status.py b/grappa_http/operators/status.py index 41d9795..784ff64 100644 --- a/grappa_http/operators/status.py +++ b/grappa_http/operators/status.py @@ -47,6 +47,7 @@ def _match(self, res, status): self.subject = res.status_code if isinstance(status, str): - self.subject = res.status + status = status.lower() + self.subject = res.status.lower() return self.subject == status, []