Skip to content

Commit

Permalink
Update ruby.rst
Browse files Browse the repository at this point in the history
Fix compilation error (`do` -> `end`) and missing `require`-statement
  • Loading branch information
Wanno Drijfhout authored and kylef committed Apr 29, 2020
1 parent 4363a7a commit 8a9e84a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion docs/hooks/ruby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Example usage of all methods in

.. code-block:: ruby
require 'dredd_hooks/methods'
include DreddHooks::Methods
before_all do |transactions|
Expand Down Expand Up @@ -97,6 +99,8 @@ Any test step can be skipped by setting ``skip`` property of the ``transaction``

.. code-block:: ruby
require 'dredd_hooks/methods'
include DreddHooks::Methods
before "Machines > Machines collection > Get Machines" do |transaction|
Expand All @@ -110,15 +114,17 @@ If you want to test some API workflow, you may pass data between test steps usin

.. code-block:: ruby
require 'dredd_hooks/methods'
require 'json'
include DreddHooks::Methods
response_stash = {}
after "Machines > Machines collection > Create Machine" do |transaction|
# saving HTTP response to the stash
response_stash[transaction['name']] = transaction['real']
do
end
before "Machines > Machine > Delete a machine" do |transaction|
#reusing data from previous response here
Expand All @@ -136,6 +142,8 @@ You can fail any step by setting ``fail`` property on ``transaction`` object to

.. code-block:: ruby
require 'dredd_hooks/methods'
include DreddHooks::Methods
before "Machines > Machines collection > Get Machines" do |transaction|
Expand All @@ -147,7 +155,9 @@ Modifying Transaction Request Body Prior to Execution

.. code-block:: ruby
require 'dredd_hooks/methods'
require 'json'
include DreddHooks::Methods
before "Machines > Machines collection > Get Machines" do |transaction|
Expand All @@ -166,6 +176,8 @@ Adding or Changing URI Query Parameters to All Requests

.. code-block:: ruby
require 'dredd_hooks/methods'
include DreddHooks::Methods
hooks.before_each do |transaction|
Expand All @@ -185,7 +197,9 @@ Handling sessions

.. code-block:: ruby
require 'dredd_hooks/methods'
require 'json'
include DreddHooks::Methods
stash = {}
Expand All @@ -208,6 +222,8 @@ Remove trailing newline character for in expected plain text bodies

.. code-block:: ruby
require 'dredd_hooks/methods'
include DreddHooks::Methods
before_each do |transaction|
Expand Down

0 comments on commit 8a9e84a

Please sign in to comment.