Sha256: 56916e103c3c51d9e2ecb203d1a0d14b076cd22b7fb46960c09adfe5ea6f9ac0
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
= Demonstrations == Standard Sections QED demos are light-weight specification documents, highly suitable to interface-driven design. The documents are divided up into clauses separated by blank lines. Clauses that are flush to the left margin are always explanation or comment clauses. Indented clauses are always executable code. Each code section is executed in order of appearance, within a rescue wrapper that captures any failures or errors. If neither a failure or error occur then the code gets a "pass". For example, the following passes: (2 + 2).assert == 4 While the following would "fail", as indicated by the raising of an Assertion error: expect Assertion do (2 + 2).assert == 5 end And this would have raised a NameError: expect NameError do nobody_knows_method end == Neutral Code Blocks There is no means of specifying that a code clause is neutral code, i.e. that it should be executed but not tested. Thus far, such a feature has proven to be a YAGNI. == Defining Custom Assertions The context in which the QED code is run is a self-extended module, thus reusable macros can be created simply by defining a method. def assert_integer(x) x.assert.is_a? Integer end Now lets try out our new macro definition. assert_integer(4) Let's prove that it can also fail: expect Assertion do assert_integer("IV") end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
qed-2.2.2 | demo/01_demos.rdoc |
qed-2.2.1 | demo/01_demos.rdoc |
qed-2.2.0 | demo/01_demos.rdoc |