Sha256: 4a4d9246809f1873d3db525fd2b800fc22af759289c6db34172adaf728b97aaf

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

= Before and After in a Quarry Specification

Quarry supports before and after clauses in specifications through
the use of *BEFORE:* and *AFTER:* indicators. Before and after
clauses are executed at the beginning and at the end of each test
step.

BEFORE: We use a before clause if we want to setup some code at the
start of each step.
 
  #puts "Starting step..."

AFTER: And an after clause to teardown objects after a step.

  #puts "Finished!"

There can only be one before or after clause at a time. So if
we define a new BEFORE: or AFTER: section later in the specification,
it will replace the current clause in use.

Only use before and after claues when necessary --specifications
are typically more readible without them. In fact, some developers
make a policy of avoiding them altogether. YMMV.

Macros, and any other non-testable code, can be designated using the
*MACRO:* indicator. Because the context in which a specification
is run is a self-extended module, macros are just method definitions.

MACRO: Macro's contain code to execute but not tested.

  def assert_integer(x)
    x.assert.is_a? Integer
  end

Okay. Now lets try out some code.

  (2 + 2).assert == 4

  assert_integer(4)

Now something that will fail:

  (2 + 2).assert == 5

And some that will raise an error:

  nobody_knows_method

QED.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quarry-0.4.0 spec/complex.rd