@@ -27,13 +27,8 @@ func popGitLedger() {
27
27
func createDummyLedger () {
28
28
r = Record {Path : "/tmp" , Slug : "pony/fill" }
29
29
r .AddToLedger ()
30
- records , _ := GetRecords ()
31
- Expect (len (records ) == 1 )
32
-
33
30
s = Record {Path : "/home" , Slug : "badger/bear" }
34
31
s .AddToLedger ()
35
- records , _ = GetRecords ()
36
- Expect (len (records ) == 2 )
37
32
}
38
33
39
34
var (
@@ -53,25 +48,25 @@ var _ = Describe("GitLedger", func() {
53
48
54
49
Describe ("CLI" , func () {
55
50
Context ("add" , func () {
51
+ // TODO: test about duplicates
56
52
Specify ("should accept fully-initialized records" , func () {
57
- Record {Path : "/tmp " , Slug : "pony/fill " }.AddToLedger ()
53
+ Record {Path : "/proc " , Slug : "tron/man " }.AddToLedger ()
58
54
records , _ := GetRecords ()
59
- Expect (len (records ) == 1 )
60
-
61
- Record {Path : "/home" , Slug : "badger/bear" }.AddToLedger ()
55
+ Expect (len (records )).To (Equal (3 ))
56
+ Record {Path : "/dev" , Slug : "cron/man" }.AddToLedger ()
62
57
records , _ = GetRecords ()
63
- Expect (len (records ) == 2 )
58
+ Expect (len (records )). To ( Equal ( 4 ) )
64
59
})
65
60
})
66
61
67
62
Context ("remove" , func () {
68
63
Specify ("should accept fully-initialized records" , func () {
69
64
s .RemoveFromLedger ()
70
65
records , _ := GetRecords ()
71
- Expect (len (records ) == 1 )
66
+ Expect (len (records )). To ( Equal ( 1 ) )
72
67
r .RemoveFromLedger ()
73
68
records , _ = GetRecords ()
74
- Expect (len (records ) == 0 )
69
+ Expect (len (records )). To ( Equal ( 0 ) )
75
70
})
76
71
})
77
72
@@ -87,16 +82,17 @@ var _ = Describe("GitLedger", func() {
87
82
88
83
Context ("The ledger" , func () {
89
84
Specify ("should reside in the user's home directory" , func () {
90
- Expect (path .Join (os .Getenv ("HOME" ), ".git-ledger" ) == Path ())
85
+ Expect (path .Join (os .Getenv ("HOME" ), ".git-ledger" )). To ( Equal ( Path () ))
91
86
})
92
87
})
93
88
94
89
Describe ("Records" , func () {
95
90
96
91
Context ("When the ledger is empty" , func () {
97
92
It ("should return 0 records" , func () {
93
+ os .Remove (Path ())
98
94
records , _ := GetRecords ()
99
- Expect (len (records ) == 0 )
95
+ Expect (len (records )). To ( Equal ( 0 ) )
100
96
})
101
97
})
102
98
@@ -106,25 +102,25 @@ var _ = Describe("GitLedger", func() {
106
102
slug := "sclopio/peepio"
107
103
record := Record {Path : path , Slug : slug }
108
104
expected := fmt .Sprintf ("[[Record]]\n path = \" %s\" \n slug = \" %s\" \n \n " , record .Path , record .Slug )
109
- Expect (record .String () == expected )
105
+ Expect (record .String ()). To ( Equal ( expected ) )
110
106
})
111
107
112
108
Specify ("should be index-able by slug" , func () {
113
109
rec , _ := GetBySlug ("fill" )
114
- Expect (rec == r )
110
+ Expect (rec ). To ( Equal ( r ) )
115
111
rec , _ = GetBySlug ("pony/fill" )
116
- Expect (rec == r )
112
+ Expect (rec ). To ( Equal ( r ) )
117
113
rec , _ = GetBySlug ("badger" )
118
- Expect (rec == s )
114
+ Expect (rec ). To ( Equal ( s ) )
119
115
})
120
116
121
117
Specify ("should be index-able by path" , func () {
122
- rec , _ := GetBySlug ("/tmp" )
123
- Expect (rec == r )
124
- rec , _ = GetBySlug ("/home" )
125
- Expect (rec == s )
126
- _ , err := GetBySlug ("DNE" )
127
- Expect (err != nil )
118
+ rec , _ := GetByPath ("/tmp" )
119
+ Expect (rec ). To ( Equal ( r ) )
120
+ rec , _ = GetByPath ("/home" )
121
+ Expect (rec ). To ( Equal ( s ) )
122
+ _ , err := GetByPath ("DNE" )
123
+ Expect (err ). ToNot ( BeNil () )
128
124
})
129
125
})
130
126
@@ -146,11 +142,11 @@ var _ = Describe("GitLedger", func() {
146
142
147
143
Specify ("should identify as such" , func () {
148
144
os .MkdirAll (gitdir , os .ModePerm )
149
- Expect (IsGitProject (dir ))
145
+ Ω (IsGitProject (dir )). Should ( BeTrue ( ))
150
146
})
151
147
152
148
Specify ("should be differentiable from non-git repositories" , func () {
153
- Expect ( ! IsGitProject (dir ))
149
+ Ω ( IsGitProject (dir )). Should ( BeFalse ( ))
154
150
})
155
151
})
156
152
})
0 commit comments