armin-joellenbeck-rdbc 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -18
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
=Design by Contract for Ruby
|
1
|
+
=Rdbc -- Design by Contract for Ruby
|
2
2
|
|
3
3
|
This library supports Design by Contract for Ruby.
|
4
4
|
|
@@ -10,20 +10,15 @@ Install the *rdbc* gem itself by the following command:
|
|
10
10
|
|
11
11
|
=Usage
|
12
12
|
|
13
|
-
|
14
|
-
class and its contract StackContract.
|
15
|
-
|
16
|
-
:include:spec/stack_spec.rb
|
17
|
-
|
18
|
-
The mechanics are really simple. There is the class Stack.
|
13
|
+
Given there is a the class Foo.
|
19
14
|
For instances of this class you can define a contract by subclassing
|
20
|
-
<b>
|
21
|
-
|
22
|
-
Then connect the class
|
23
|
-
contract
|
24
|
-
in the class definition of
|
15
|
+
<b>Rdbc::Contract</b>, in the example the contract is named
|
16
|
+
FooContract.
|
17
|
+
Then connect the class Foo to its contract FooContract by using the line
|
18
|
+
contract FooContract
|
19
|
+
in the class definition of Foo.
|
25
20
|
|
26
|
-
Then the following happens when a method of a
|
21
|
+
Then the following happens when a method of a Foo instance is called:
|
27
22
|
|
28
23
|
1. the corresponding pre condition is called with the parameters:
|
29
24
|
* the instance itself
|
@@ -44,11 +39,7 @@ Then the following happens when a method of a Stack instance is called:
|
|
44
39
|
The instance before the execution of *method* in 3. and 4.
|
45
40
|
is in fact a copy of the instance before the execution. So you have to implement
|
46
41
|
the method *initialize_copy* in the class under contract, i.e. the class
|
47
|
-
|
48
|
-
|
49
|
-
In any of these contract methods you can use assertions as in Test::Unit tests.
|
50
|
-
When an assertion fails, the exception Test::Unit::AssertionFailedError
|
51
|
-
is raised.
|
42
|
+
Foo.
|
52
43
|
|
53
44
|
=Support
|
54
45
|
|