brine-dsl 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/LICENSE +1 -1
- data/README.adoc +29 -0
- data/brine-dsl.gemspec +5 -5
- data/docs/build.gradle +1 -1
- data/docs/cookbook.html +48 -40
- data/docs/guide.html +185 -119
- data/docs/index.html +18 -4
- data/docs/specs.html +227 -1
- data/docs/src/cookbook.adoc +57 -40
- data/docs/src/guide.adoc +227 -133
- data/docs/src/index.adoc +15 -3
- data/docs/src/specs.adoc +11 -0
- data/features/assignment/parameter.feature +20 -0
- data/features/assignment/random.feature +25 -0
- data/features/assignment/response_attribute.feature +33 -0
- data/features/assignment/timestamp.feature +33 -0
- data/lib/brine/cleaner_upper.rb +55 -16
- data/lib/brine/coercer.rb +55 -5
- data/lib/brine/rest_steps.rb +20 -39
- data/lib/brine/step_definitions/assignment.rb +33 -5
- data/lib/brine.rb +13 -8
- metadata +11 -3
- data/README.md +0 -7
data/docs/guide.html
CHANGED
@@ -546,11 +546,12 @@ type.</p>
|
|
546
546
|
</dd>
|
547
547
|
<dt class="hdlist1">Type Coercion</dt>
|
548
548
|
<dd>
|
549
|
-
<p>Related to transforms, a facility to coerce types is also provided. This
|
550
|
-
more intelligent comparison of inputs which have been transformed to a
|
549
|
+
<p>Related to transforms, a facility to coerce types is also provided. This
|
550
|
+
allows more intelligent comparison of inputs which have been transformed to a
|
551
551
|
richer data type with those that have not been transformed (normally strings).
|
552
552
|
As an example comparing a date/time value with a string will attempt to parse
|
553
|
-
the string to a date/time so that the values can be compared using the proper
|
553
|
+
the string to a date/time so that the values can be compared using the proper
|
554
|
+
semantics.</p>
|
554
555
|
</dd>
|
555
556
|
<dt class="hdlist1"><a href="#_resource_cleanup">Resource Cleanup</a></dt>
|
556
557
|
<dd>
|
@@ -616,7 +617,8 @@ requiring any additional ruby code.</p>
|
|
616
617
|
<div class="sectionbody">
|
617
618
|
<div class="paragraph">
|
618
619
|
<p>We’ll write some tests against <a href="http://myjson.com/api" class="bare">http://myjson.com/api</a>
|
619
|
-
(selected fairly arbitrary from the list at
|
620
|
+
(selected fairly arbitrary from the list at
|
621
|
+
<a href="https://github.com/toddmotto/public-apis" class="bare">https://github.com/toddmotto/public-apis</a>).
|
620
622
|
The API is being explored for the sake of this tutorial,
|
621
623
|
which also serves to bolster this library to support the effort.</p>
|
622
624
|
</div>
|
@@ -648,7 +650,8 @@ end</code></pre>
|
|
648
650
|
<p>which could then be called with <code>rake cucumber</code>. The rake approach
|
649
651
|
can be extended for different tasks for each environment, each
|
650
652
|
of which sets the appropriate environment variables allowing the
|
651
|
-
test code itself to follow
|
653
|
+
test code itself to follow
|
654
|
+
<a href="https://12factor.net/config">Twelve-Factor App guidelines</a>
|
652
655
|
where Rake provides sugary convenience.</p>
|
653
656
|
</div>
|
654
657
|
</div>
|
@@ -673,8 +676,8 @@ testing the response status from a GET request.</p>
|
|
673
676
|
<h3 id="_a_write_request">A Write Request</h3>
|
674
677
|
<div class="paragraph">
|
675
678
|
<p>For POST, PATCH and PUT requests you’ll normally want to include a request body.
|
676
|
-
To support this, additional data can be added to the requests before they are
|
677
|
-
(see <a href="#_request_construction">Request Construction</a>).</p>
|
679
|
+
To support this, additional data can be added to the requests before they are
|
680
|
+
sent (see <a href="#_request_construction">Request Construction</a>).</p>
|
678
681
|
</div>
|
679
682
|
<div class="listingblock">
|
680
683
|
<div class="content">
|
@@ -723,14 +726,16 @@ can check that the <code>uri</code> response child matches the expected pattern.
|
|
723
726
|
<h2 id="_environment_variables">Environment Variables</h2>
|
724
727
|
<div class="sectionbody">
|
725
728
|
<div class="paragraph">
|
726
|
-
<p>Some Brine behavior can be tuned by passing it appropriate environment
|
729
|
+
<p>Some Brine behavior can be tuned by passing it appropriate environment
|
730
|
+
variables, listed here.</p>
|
727
731
|
</div>
|
728
732
|
<div class="dlist">
|
729
733
|
<dl>
|
730
734
|
<dt class="hdlist1"><code>BRINE_LOG_HTTP</code></dt>
|
731
735
|
<dd>
|
732
|
-
<p>Output HTTP traffic to stdout. Any truthy value will result in request and
|
733
|
-
metadata being logged, a value of <code>DEBUG</code> (case insensitive) will
|
736
|
+
<p>Output HTTP traffic to stdout. Any truthy value will result in request and
|
737
|
+
response metadata being logged, a value of <code>DEBUG</code> (case insensitive) will
|
738
|
+
also log the bodies.</p>
|
734
739
|
</dd>
|
735
740
|
<dt class="hdlist1"><code>BRINE_LOG_BINDING</code></dt>
|
736
741
|
<dd>
|
@@ -747,15 +752,16 @@ metadata being logged, a value of <code>DEBUG</code> (case insensitive) will als
|
|
747
752
|
<h3 id="_the_use_of_code_code_s">The use of <code>`</code>s</h3>
|
748
753
|
<div class="paragraph">
|
749
754
|
<p>Backticks/grave accents are used as <em>parameter delimiters</em>. It is perhaps
|
750
|
-
most helpful to think of them in those explicit terms rather than thinking of
|
751
|
-
as an alternate <em>quote</em> construct. In particular quoting implies that the
|
752
|
-
value is a string value, while the step transforms allow for
|
755
|
+
most helpful to think of them in those explicit terms rather than thinking of
|
756
|
+
them as an alternate <em>quote</em> construct. In particular quoting implies that the
|
757
|
+
parameter value is a string value, while the step transforms allow for
|
758
|
+
alternative data types.</p>
|
753
759
|
</div>
|
754
760
|
<div class="paragraph">
|
755
|
-
<p><code>`</code>s were chosen as they are less common than
|
756
|
-
|
757
|
-
quoting within paremeter values while hopefully avoiding the need for escape
|
758
|
-
(as used for argument transforms).</p>
|
761
|
+
<p><code>`</code>s were chosen as they are less common than many other syntactical
|
762
|
+
elements and also allow for the use of logically significant
|
763
|
+
quoting within paremeter values while hopefully avoiding the need for escape
|
764
|
+
artistry (as used for argument transforms).</p>
|
759
765
|
</div>
|
760
766
|
</div>
|
761
767
|
</div>
|
@@ -764,16 +770,19 @@ quoting within paremeter values while hopefully avoiding the need for escape art
|
|
764
770
|
<h2 id="_selection_and_assertion">Selection and Assertion</h2>
|
765
771
|
<div class="sectionbody">
|
766
772
|
<div class="paragraph">
|
767
|
-
<p>As tests are generally concerned with performing assertions, a testing DSL
|
768
|
-
able to express the variety of assertions that may be needed. Because
|
769
|
-
to be numerous, it could easily lead to duplicated logic or
|
770
|
-
to the combinations of types of assertions and the
|
773
|
+
<p>As tests are generally concerned with performing assertions, a testing DSL
|
774
|
+
should be able to express the variety of assertions that may be needed. Because
|
775
|
+
these are likely to be numerous, it could easily lead to duplicated logic or
|
776
|
+
geometric growth of code due to the combinations of types of assertions and the
|
777
|
+
means to select the inputs for the assertion.</p>
|
771
778
|
</div>
|
772
779
|
<div class="paragraph">
|
773
|
-
<p>To avoid this issue the concepts of selection and assertion are considered
|
774
|
-
Internally this corresponds to two steps: the
|
775
|
-
|
776
|
-
the
|
780
|
+
<p>To avoid this issue the concepts of selection and assertion are considered
|
781
|
+
separate operations in Brine. Internally this corresponds to two steps: the
|
782
|
+
first assigns a selector;
|
783
|
+
the second passes the assertion to that selector which is responsible for
|
784
|
+
applying the assertion against the selected value(s). In standard step use this
|
785
|
+
will still be expressed as a single step,
|
777
786
|
and dynamic step definitions are used to split the work appropriately.</p>
|
778
787
|
</div>
|
779
788
|
<div class="paragraph">
|
@@ -786,58 +795,67 @@ and dynamic step definitions are used to split the work appropriately.</p>
|
|
786
795
|
</div>
|
787
796
|
<div class="paragraph">
|
788
797
|
<p>Will be split where the subject of the step (<code>the value of the response body</code>)
|
789
|
-
defines the selector and the predicate of the step
|
790
|
-
|
798
|
+
defines the selector and the predicate of the step
|
799
|
+
<code>is equal to `foo`</code> defines the assertion (which is translated to a
|
800
|
+
step such as <code>Then it is equal to `foo`</code>).</p>
|
791
801
|
</div>
|
792
802
|
<div class="paragraph">
|
793
|
-
<p>The result of this is that the assertion steps will always follow a pattern
|
794
|
-
resembles <code>the value of …​</code> and the predicate always
|
795
|
-
|
796
|
-
|
803
|
+
<p>The result of this is that the assertion steps will always follow a pattern
|
804
|
+
where the subject resembles <code>the value of …​</code> and the predicate always
|
805
|
+
resembles <code>is …​</code>. Learning the selection phrases and the assertion phrases
|
806
|
+
and combining them should be a more efficient and flexible way to become
|
807
|
+
familiar with the language instead of focusing on the resulting combined steps.</p>
|
797
808
|
</div>
|
798
809
|
<div class="paragraph">
|
799
810
|
<p>The chosen approach sacrifices eloquence for the sake of consistency.
|
800
|
-
The predicate will always start with <code>is</code> which can lead to awkward language
|
801
|
-
<code>is including</code> rather than simply <code>includes</code>.
|
811
|
+
The predicate will always start with <code>is</code> which can lead to awkward language
|
812
|
+
such as <code>is including</code> rather than simply <code>includes</code>.
|
802
813
|
The consistency provides additional benefits such as consistent modification:
|
803
|
-
for instance <code>is not</code> can always be use for negation rather than working out the
|
804
|
-
phrasing for a more natural sounding step (let alone the logic).</p>
|
814
|
+
for instance <code>is not</code> can always be use for negation rather than working out the
|
815
|
+
appropriate phrasing for a more natural sounding step (let alone the logic).</p>
|
805
816
|
</div>
|
806
817
|
<div class="paragraph">
|
807
|
-
<p>One of the secondary goals of this is that assertion step definitions should
|
808
|
-
write and modifiers (such as negation) should be provided for
|
809
|
-
|
818
|
+
<p>One of the secondary goals of this is that assertion step definitions should
|
819
|
+
be very simple to write and modifiers (such as negation) should be provided for
|
820
|
+
free to those definitions.
|
821
|
+
As assertion definitions are likely to be numerous and potentially customized,
|
822
|
+
this should help optimize code economy.</p>
|
810
823
|
</div>
|
811
824
|
<div class="sect2">
|
812
825
|
<h3 id="_selection_modifiers">Selection Modifiers</h3>
|
813
826
|
<div class="paragraph">
|
814
|
-
<p>To pursue economical flexibility Brine steps attempt to balance step definitions
|
815
|
-
while keeping the step logic and patterns fairly
|
816
|
-
|
817
|
-
|
827
|
+
<p>To pursue economical flexibility Brine steps attempt to balance step definitions
|
828
|
+
which accommodate variations while keeping the step logic and patterns fairly
|
829
|
+
simple. Selection steps in particular generally accept some parameters that
|
830
|
+
affect their behavior. This allows the relatively small number of selection
|
831
|
+
steps to provide the flexibility to empower the more numerous assertion steps.</p>
|
818
832
|
</div>
|
819
833
|
<div class="sect3">
|
820
834
|
<h4 id="_traversal">Traversal</h4>
|
821
835
|
<div class="paragraph">
|
822
|
-
<p>Selection steps can generally target the root of the object specified (such as
|
823
|
-
or some nodes within the object if it is a non-scalar value
|
824
|
-
|
825
|
-
<
|
826
|
-
|
836
|
+
<p>Selection steps can generally target the root of the object specified (such as
|
837
|
+
the response body) or some nodes within the object if it is a non-scalar value
|
838
|
+
(for instance a child of the response body). This is indicated in the
|
839
|
+
<a href="#_selection">step reference selection steps</a> by the <code>[$TRAVERSAL]</code> placeholder.
|
840
|
+
<code>child `$EXPRESSION`</code> or <code>children `$EXPRESSION`</code> can
|
841
|
+
optionally be inserted at the placeholder to select nested nodes as described
|
842
|
+
in <a href="#_traversal_2">Traversal</a>.</p>
|
827
843
|
</div>
|
828
844
|
</div>
|
829
845
|
<div class="sect3">
|
830
846
|
<h4 id="_negation">Negation</h4>
|
831
847
|
<div class="paragraph">
|
832
848
|
<p>The selectors also currently handle negation of the associated assertions.
|
833
|
-
This is potentially counter-intuitive but as previously mentioned the intent is
|
834
|
-
should ease the creation of assertions. If negation is added to a
|
835
|
-
the assertion will <em>fail</em>.</p>
|
849
|
+
This is potentially counter-intuitive but as previously mentioned the intent is
|
850
|
+
that this should ease the creation of assertions. If negation is added to a
|
851
|
+
selector that it is expected that the assertion will <em>fail</em>.</p>
|
836
852
|
</div>
|
837
853
|
<div class="paragraph">
|
838
|
-
<p>Negation will be normally indicated in the
|
839
|
-
|
840
|
-
|
854
|
+
<p>Negation will be normally indicated in the
|
855
|
+
<a href="#_selection">step reference selection steps</a> by the presence
|
856
|
+
of the <code>[not]</code> placeholder. A similar placeholder may be used that is more
|
857
|
+
readable but leads to an equivalent inversion of the semantics of the statement.
|
858
|
+
To negate the step, the text within the <code>[]</code>s should be inserted
|
841
859
|
in the indicated position.</p>
|
842
860
|
</div>
|
843
861
|
<div class="admonitionblock note">
|
@@ -847,10 +865,12 @@ in the indicated position.</p>
|
|
847
865
|
<i class="fa icon-note" title="Future Versions"></i>
|
848
866
|
</td>
|
849
867
|
<td class="content">
|
850
|
-
Handling this in the selectors is (as mentioned) counter-intuitive and
|
851
|
-
to the assertion. It is currently done for
|
852
|
-
|
853
|
-
|
868
|
+
Handling this in the selectors is (as mentioned) counter-intuitive and
|
869
|
+
unnecessarily couples the selector to the assertion. It is currently done for
|
870
|
+
practical reasons but is likely to be replaced in a future version after (or as
|
871
|
+
part of) the initial port of the library to another platform. When it is
|
872
|
+
replaced, all existing steps will remain supported through at least one more
|
873
|
+
major revision and most should (most should remain unchanged).
|
854
874
|
</td>
|
855
875
|
</tr>
|
856
876
|
</table>
|
@@ -872,9 +892,12 @@ Use at your own risk, this feature is <strong>not presently supported</strong>.
|
|
872
892
|
</table>
|
873
893
|
</div>
|
874
894
|
<div class="paragraph">
|
875
|
-
<p>For anyone that likes to live on the (relative) edge or if this gathers notable
|
876
|
-
provides an implicit feature: after a value is
|
877
|
-
|
895
|
+
<p>For anyone that likes to live on the (relative) edge or if this gathers notable
|
896
|
+
interest…​the above also provides an implicit feature: after a value is
|
897
|
+
selected multiple assertions could be performed against it.</p>
|
898
|
+
</div>
|
899
|
+
<div class="paragraph">
|
900
|
+
<p>For instance:</p>
|
878
901
|
</div>
|
879
902
|
<div class="listingblock">
|
880
903
|
<div class="content">
|
@@ -883,9 +906,10 @@ And it is of the type `String`</code></pre>
|
|
883
906
|
</div>
|
884
907
|
</div>
|
885
908
|
<div class="paragraph">
|
886
|
-
<p>Though this may work in simple cases the present design is likely to produce
|
887
|
-
some aspects (such as negation) are handled by the
|
888
|
-
even though it wouldn’t
|
909
|
+
<p>Though this may work in simple cases the present design is likely to produce
|
910
|
+
surprising results since some aspects (such as negation) are handled by the
|
911
|
+
selector so it would be inherited by the conjunctions even though it wouldn’t
|
912
|
+
read that way.</p>
|
889
913
|
</div>
|
890
914
|
</div>
|
891
915
|
</div>
|
@@ -894,13 +918,14 @@ even though it wouldn’t read that way.</p>
|
|
894
918
|
<h2 id="_traversal_2">Traversal</h2>
|
895
919
|
<div class="sectionbody">
|
896
920
|
<div class="paragraph">
|
897
|
-
<p>The language exposed by Brine is flat but the data returned by the server is
|
898
|
-
to include deeper data structures such as objects and collections. To
|
899
|
-
such structures a <code>traversal</code> language is embedded within
|
900
|
-
by the use of the <code>TRAVERSAL</code> placeholder.</p>
|
921
|
+
<p>The language exposed by Brine is flat but the data returned by the server is
|
922
|
+
likely to include deeper data structures such as objects and collections. To
|
923
|
+
allow selection within such structures a <code>traversal</code> language is embedded within
|
924
|
+
some steps which will be indicated by the use of the <code>TRAVERSAL</code> placeholder.</p>
|
901
925
|
</div>
|
902
926
|
<div class="paragraph">
|
903
|
-
<p>The traversal language consists of a selected subset of
|
927
|
+
<p>The traversal language consists of a selected subset of
|
928
|
+
<a href="http://goessner.net/articles/JsonPath/">JsonPath</a>.</p>
|
904
929
|
</div>
|
905
930
|
<div class="admonitionblock note">
|
906
931
|
<table>
|
@@ -909,12 +934,14 @@ by the use of the <code>TRAVERSAL</code> placeholder.</p>
|
|
909
934
|
<i class="fa icon-note" title="The Selected Subset"></i>
|
910
935
|
</td>
|
911
936
|
<td class="content">
|
912
|
-
The subset of JsonPath functionality has been chosen that is believed to support
|
913
|
-
test cases without requiring deep familiarity with JsonPath. This may
|
914
|
-
in place of fewer steps that use unsupported
|
915
|
-
|
916
|
-
|
917
|
-
|
937
|
+
The subset of JsonPath functionality has been chosen that is believed to support
|
938
|
+
all needed test cases without requiring deep familiarity with JsonPath. This may
|
939
|
+
lead to more numerous simple steps in place of fewer steps that use unsupported
|
940
|
+
expressions. Additionally Brine is intended to be ported to a range of platforms
|
941
|
+
and so only those steps outlined here will be supported across those platforms.
|
942
|
+
JsonPath expressions <em>not</em> listed below will not be explicitly disallowed but
|
943
|
+
are not officially supported (will not be tested and will not be ported to
|
944
|
+
another platform if needed).
|
918
945
|
</td>
|
919
946
|
</tr>
|
920
947
|
</table>
|
@@ -922,12 +949,15 @@ JsonPath expressions <em>not</em> listed below will not be explicitly disallowed
|
|
922
949
|
<div class="sect2">
|
923
950
|
<h3 id="_cardinality">Cardinality</h3>
|
924
951
|
<div class="paragraph">
|
925
|
-
<p>Each traversal expression will select <em>all</em> matching nodes which is therefore
|
926
|
-
Often, however, only a single node is expected or
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
952
|
+
<p>Each traversal expression will select <em>all</em> matching nodes which is therefore
|
953
|
+
represented as a collection. Often, however, only a single node is expected or
|
954
|
+
desired. Therefore the traversal expression will also be accompanied by a phrase
|
955
|
+
which defines the expected cardinality, normally <code>child</code> vs. <code>children</code>.
|
956
|
+
<code>children</code> will <em>always</em> return an array while <code>child</code> will return what would be
|
957
|
+
the first element in that array. <code>child</code> should be used when accessing a
|
958
|
+
specific node within the tree, while <code>children</code> should be used for what amounts
|
959
|
+
to a query across multiple nodes (such as testing the value of a field for every
|
960
|
+
element in a collection).</p>
|
931
961
|
</div>
|
932
962
|
</div>
|
933
963
|
<div class="sect2">
|
@@ -936,9 +966,18 @@ across multiple nodes (such as testing the value of a field for every element in
|
|
936
966
|
<dl>
|
937
967
|
<dt class="hdlist1"><code>.$KEY</code></dt>
|
938
968
|
<dd>
|
939
|
-
<p>
|
969
|
+
<p>Access the <code>KEY</code> named child of the starting node. The leading <code>.</code> can be
|
940
970
|
omitted if at the start of an expression.</p>
|
941
971
|
</dd>
|
972
|
+
<dt class="hdlist1"><code>.[$INDEX]</code></dt>
|
973
|
+
<dd>
|
974
|
+
<p>Access the element of the array at index <code>INDEX</code></p>
|
975
|
+
</dd>
|
976
|
+
<dt class="hdlist1"><code>.[$FROM:$TO]</code></dt>
|
977
|
+
<dd>
|
978
|
+
<p>Access a slice of the array containing the elements at index <code>FROM</code> through
|
979
|
+
<code>TO</code> (including both limits).</p>
|
980
|
+
</dd>
|
942
981
|
</dl>
|
943
982
|
</div>
|
944
983
|
</div>
|
@@ -948,26 +987,32 @@ omitted if at the start of an expression.</p>
|
|
948
987
|
<h2 id="_resource_cleanup">Resource Cleanup</h2>
|
949
988
|
<div class="sectionbody">
|
950
989
|
<div class="paragraph">
|
951
|
-
<p>All test suites should clean up after themselves as a matter of hygiene and to
|
952
|
-
and reproducibility. This is particularly
|
953
|
-
|
954
|
-
|
955
|
-
|
990
|
+
<p>All test suites should clean up after themselves as a matter of hygiene and to
|
991
|
+
help enforce test independence and reproducibility. This is particularly
|
992
|
+
important for this library given that it is likely the systems under test
|
993
|
+
are likely to remain running; accumulated uncleaned resources are at best a
|
994
|
+
nuisance to have to weed through and at worst raise some costs or other due to
|
995
|
+
heightened consumption of assorted resources (as opposed to more ephemeral test
|
996
|
+
environments).</p>
|
956
997
|
</div>
|
957
998
|
<div class="paragraph">
|
958
|
-
<p>Brine therefore provides mechanisms to assist in cleaning up those resources
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
999
|
+
<p>Brine therefore provides mechanisms to assist in cleaning up those resources
|
1000
|
+
which are created as part of a test run. A conceptual hurdle for this type of
|
1001
|
+
functionality is that it is very unlikely to be part of the feature that is
|
1002
|
+
being specified, and therefore should ideally not be part of the specification.
|
1003
|
+
Depending on the functionality (and arguably the
|
1004
|
+
<a href="https://www.martinfowler.com/articles/richardsonMaturityModel.html">maturity</a>)
|
1005
|
+
of the API, most or all of the cleanup can be automagically done based on
|
1006
|
+
convention. There are tentative plans to support multiple techniques for
|
1007
|
+
cleaning up resources based on how much can be implicitly
|
1008
|
+
ascertained…​though presently there exists only one.</p>
|
965
1009
|
</div>
|
966
1010
|
<div class="sect2">
|
967
1011
|
<h3 id="_step_indicating_resource_to_delete">Step indicating resource to DELETE</h3>
|
968
1012
|
<div class="paragraph">
|
969
|
-
<p>If the API supports DELETE requests to remove created resources but it is either
|
970
|
-
what those resource PATHS are, a step can be
|
1013
|
+
<p>If the API supports DELETE requests to remove created resources but it is either
|
1014
|
+
desirable or necessary to specify what those resource PATHS are, a step can be
|
1015
|
+
used to indicate which resources should be DELETEd upon test completion.</p>
|
971
1016
|
</div>
|
972
1017
|
<div class="paragraph">
|
973
1018
|
<p><em>see <a href="#_cleanup">Cleanup Step Definitions</a></em></p>
|
@@ -991,27 +1036,34 @@ a <a href="https://en.wikipedia.org/wiki/Builder_pattern">Builder</a>.</p>
|
|
991
1036
|
<dl>
|
992
1037
|
<dt class="hdlist1"><code>When a $METHOD is sent to `$PATH`</code></dt>
|
993
1038
|
<dd>
|
994
|
-
<p>
|
995
|
-
HTTP <code>METHOD</code> and <code>PATH</code>, this step is considered required and is therefore
|
996
|
-
to send the built request. This should therefore be the <strong>last</strong> step for
|
997
|
-
given request that is being built.</p>
|
1039
|
+
<p>As every request to a REST API is likely to have a significant
|
1040
|
+
HTTP <code>METHOD</code> and <code>PATH</code>, this step is considered required and is therefore
|
1041
|
+
used to send the built request. This should therefore be the <strong>last</strong> step for
|
1042
|
+
any given request that is being built.</p>
|
998
1043
|
</dd>
|
999
1044
|
<dt class="hdlist1"><code>When the request body is assigned:</code></dt>
|
1000
1045
|
<dd>
|
1001
|
-
<p>
|
1046
|
+
<p>The multiline content provided will be assigned to the body of the request.
|
1002
1047
|
This will normally likely be the JSON representation of data.</p>
|
1003
1048
|
</dd>
|
1004
|
-
|
1005
|
-
|
1006
|
-
<
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1049
|
+
</dl>
|
1050
|
+
</div>
|
1051
|
+
<div class="paragraph">
|
1052
|
+
<p><code>When the request query parameter `$PARAMETER` is assigned
|
1053
|
+
`$VALUE`</code>::
|
1054
|
+
Assign <code>VALUE</code> to the request query <code>PARAMETER</code>.
|
1055
|
+
The value will be URL encoded and the key/value pair appended to the URL using
|
1056
|
+
the appropriate <code>?</code> or <code>&</code> delimiter.
|
1057
|
+
The order of the parameters in the resulting URL should be considered
|
1058
|
+
undefined.</p>
|
1059
|
+
</div>
|
1060
|
+
<div class="dlist">
|
1061
|
+
<dl>
|
1011
1062
|
<dt class="hdlist1"><code>When the request header `$HEADER` is assigned `$VALUE`</code></dt>
|
1012
1063
|
<dd>
|
1013
|
-
<p>
|
1014
|
-
Will overwrite any earlier value for the specified header, including earlier
|
1064
|
+
<p>Assign <code>VALUE</code> to the request header <code>HEADER</code>.
|
1065
|
+
Will overwrite any earlier value for the specified header, including earlier
|
1066
|
+
steps or defaults.</p>
|
1015
1067
|
</dd>
|
1016
1068
|
</dl>
|
1017
1069
|
</div>
|
@@ -1022,13 +1074,17 @@ Will overwrite any earlier value for the specified header, including earlier ste
|
|
1022
1074
|
<dl>
|
1023
1075
|
<dt class="hdlist1"><code>When a resouce is created at `$PATH`</code></dt>
|
1024
1076
|
<dd>
|
1025
|
-
<p>Mark <code>PATH</code> as a resource to DELETE after the test is run.
|
1077
|
+
<p>Mark <code>PATH</code> as a resource to DELETE after the test is run.
|
1078
|
+
See <a href="#_resource_cleanup">Resource Cleanup</a></p>
|
1026
1079
|
</dd>
|
1027
1080
|
</dl>
|
1028
1081
|
</div>
|
1029
1082
|
</div>
|
1030
1083
|
<div class="sect2">
|
1031
1084
|
<h3 id="_assignment">Assignment</h3>
|
1085
|
+
<div class="paragraph">
|
1086
|
+
<p><a href="specs.html#_assignment"><span class="icon"><i class="fa fa-cogs"></i></span> Specification</a></p>
|
1087
|
+
</div>
|
1032
1088
|
<div class="dlist">
|
1033
1089
|
<dl>
|
1034
1090
|
<dt class="hdlist1"><code>When `$IDENTIFIER` is assigned `$VALUE`</code></dt>
|
@@ -1037,14 +1093,19 @@ Will overwrite any earlier value for the specified header, including earlier ste
|
|
1037
1093
|
</dd>
|
1038
1094
|
<dt class="hdlist1"><code>When `$IDENTIFIER` is assigned a random string</code></dt>
|
1039
1095
|
<dd>
|
1040
|
-
<p>
|
1096
|
+
<p>Assigns a random string (UUID) to <code>IDENTIFIER</code>.
|
1041
1097
|
This is particularly useful to assist with test isolation.</p>
|
1042
1098
|
</dd>
|
1043
1099
|
<dt class="hdlist1"><code>When `$IDENTIFIER` is assigned a timestamp</code></dt>
|
1044
1100
|
<dd>
|
1045
|
-
<p>
|
1101
|
+
<p>Assigns to <code>IDENTIFIER</code> a timestamp value representing the instant at
|
1046
1102
|
which the step was evaluated.</p>
|
1047
1103
|
</dd>
|
1104
|
+
<dt class="hdlist1"><code>When `$IDENTIFIER` is assigned the response (body|status|headers) [$TRAVERSAL]</code></dt>
|
1105
|
+
<dd>
|
1106
|
+
<p>Assigns to <code>IDENTIFIER</code> the value extracted from the specified response
|
1107
|
+
attribtute (at the optional traversal path).</p>
|
1108
|
+
</dd>
|
1048
1109
|
</dl>
|
1049
1110
|
</div>
|
1050
1111
|
</div>
|
@@ -1056,11 +1117,14 @@ which the step was evaluated.</p>
|
|
1056
1117
|
<div class="paragraph">
|
1057
1118
|
<p><em>see <a href="#_selection_and_assertion">Selection and Assertion</a></em></p>
|
1058
1119
|
</div>
|
1120
|
+
<div class="paragraph">
|
1121
|
+
<p><em>TODO: Replace all the explicit attributes.</em></p>
|
1122
|
+
</div>
|
1059
1123
|
<div class="dlist">
|
1060
1124
|
<dl>
|
1061
|
-
<dt class="hdlist1"><code>Then the value of the response status is</code></dt>
|
1125
|
+
<dt class="hdlist1"><code>Then the value of the response (body|status|headers) is</code></dt>
|
1062
1126
|
<dd>
|
1063
|
-
<p>Select the
|
1127
|
+
<p>Select the sepecified attribute of the current HTTP response.</p>
|
1064
1128
|
</dd>
|
1065
1129
|
<dt class="hdlist1"><code>Then the value of the response body [$TRAVERSAL] is [not]</code></dt>
|
1066
1130
|
<dd>
|
@@ -1101,13 +1165,15 @@ which the step was evaluated.</p>
|
|
1101
1165
|
</dd>
|
1102
1166
|
<dt class="hdlist1"><code>Then it is empty</code></dt>
|
1103
1167
|
<dd>
|
1104
|
-
<p>
|
1105
|
-
(such as booleans or numbers) will always return false. Null is
|
1106
|
-
value so that it can be treated as such for endpoints that
|
1168
|
+
<p>Assert that value is empty or null. Any type which is not testable for
|
1169
|
+
emptiness (such as booleans or numbers) will always return false. Null is
|
1170
|
+
treated as an empty value so that it can be treated as such for endpoints that
|
1171
|
+
return null in place of empty collections, and non-null empty values can
|
1172
|
+
easily be tested for using conjunction.</p>
|
1107
1173
|
</dd>
|
1108
1174
|
<dt class="hdlist1"><code>Then it is of length `$VALUE`</code></dt>
|
1109
1175
|
<dd>
|
1110
|
-
<p>
|
1176
|
+
<p>Assert that the value exposes a length attribute and the value of that
|
1111
1177
|
attribute is <code>VALUE</code>.</p>
|
1112
1178
|
</dd>
|
1113
1179
|
<dt class="hdlist1"><code>Then it is a valid `$TYPE`</code></dt>
|
@@ -1147,7 +1213,7 @@ wiring and documentation. The current supported types are:</p>
|
|
1147
1213
|
</div>
|
1148
1214
|
<div id="footer">
|
1149
1215
|
<div id="footer-text">
|
1150
|
-
Last updated 2018-
|
1216
|
+
Last updated 2018-06-17 22:38:06 EDT
|
1151
1217
|
</div>
|
1152
1218
|
</div>
|
1153
1219
|
</body>
|
data/docs/index.html
CHANGED
@@ -426,7 +426,8 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
426
426
|
<div id="toc" class="toc2">
|
427
427
|
<div id="toctitle">Table of Contents</div>
|
428
428
|
<ul class="sectlevel1">
|
429
|
-
<li><a href="#
|
429
|
+
<li><a href="#_overview">Overview</a></li>
|
430
|
+
<li><a href="#_documents">Documents</a></li>
|
430
431
|
</ul>
|
431
432
|
</div>
|
432
433
|
</div>
|
@@ -439,11 +440,21 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
439
440
|
</div>
|
440
441
|
</div>
|
441
442
|
<div class="sect1">
|
442
|
-
<h2 id="
|
443
|
+
<h2 id="_overview">Overview</h2>
|
443
444
|
<div class="sectionbody">
|
444
445
|
<div class="paragraph">
|
445
|
-
<p>The
|
446
|
+
<p>The documentation should provide the background information to
|
447
|
+
get started using Brine and a framework for figuring out specific details.
|
448
|
+
The focus of guides will be on concepts and high level information while
|
449
|
+
more comprehensive and finer grained information will be provided by
|
450
|
+
specifications and source. Recipes will be provided for problems which
|
451
|
+
are common, interesting, or anything anyone wants to contribute :).</p>
|
446
452
|
</div>
|
453
|
+
</div>
|
454
|
+
</div>
|
455
|
+
<div class="sect1">
|
456
|
+
<h2 id="_documents">Documents</h2>
|
457
|
+
<div class="sectionbody">
|
447
458
|
<div class="dlist">
|
448
459
|
<dl>
|
449
460
|
<dt class="hdlist1"><a href="guide.html"><span class="icon"><i class="fa fa-book"></i></span> User Guide</a></dt>
|
@@ -460,12 +471,15 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
460
471
|
</dd>
|
461
472
|
</dl>
|
462
473
|
</div>
|
474
|
+
<div class="paragraph">
|
475
|
+
<p><em>TODO: The current Cookbook name should be qualified to match its scope</em></p>
|
476
|
+
</div>
|
463
477
|
</div>
|
464
478
|
</div>
|
465
479
|
</div>
|
466
480
|
<div id="footer">
|
467
481
|
<div id="footer-text">
|
468
|
-
Last updated 2018-
|
482
|
+
Last updated 2018-06-17 15:55:45 EDT
|
469
483
|
</div>
|
470
484
|
</div>
|
471
485
|
</body>
|