-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.fy
36 lines (33 loc) · 1.01 KB
/
client.fy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
FancySpec describe: Redis Client with: {
before_each: {
@r = Redis Client new
}
it: "performs a correct call" with: 'call: when: {
@r call: ['get, 'foo] . is: nil
@r call: ['set, 'foo, "bar"] . is: "OK"
@r call: ['get, 'foo] . is: "bar"
@r call: ['del, 'foo] . is: 1
@r call: ['del, 'foo] . is: 0
}
it: "performs the transaction correctly" with: 'transaction: when: {
@r transaction: @{
call: ['get, 'foo] . is: "QUEUED"
call: ['set, 'foo, "bar"] . is: "QUEUED"
call: ['get, 'foo] . is: "QUEUED"
}
@r call: ['get, 'foo] . is: "bar"
@r call: ['del, 'foo] . is: 1
}
it: "discards a transaction when an Exception is raised" with: 'transaction: when: {
@r call: ['get, 'foo] . is: nil
{
@r transaction: @{
call: ['get, 'foo] . is: "QUEUED"
2 / 0 # raise an error
call: ['set, 'foo, "bar"] . is: "QUEUED"
}
} raises: ZeroDivisionError
# did not save due to Exception:
@r call: ['get, 'foo] . is: nil
}
}