Commit 8b83d79
Changed files (2)
spec
spec/spec.go
@@ -1,7 +1,5 @@
package spec
-import "testing"
-
// establish context (e.g. "when creating a new sparkle")
// because of (e.g. "with an empty body")
// it behaves like (e.g. "it returns an error message")
@@ -12,9 +10,9 @@ type Context struct {
}
type ContextFunc func(*Context)
type BecauseFunc func()
-type ItFunc func(*testing.T)
+type ItFunc func()
-func Establish(t *testing.T, x ContextFunc) {
+func Establish(x ContextFunc) {
context := Context{
its: []ItFunc{},
because: func() {},
@@ -23,7 +21,7 @@ func Establish(t *testing.T, x ContextFunc) {
x(&context)
context.because()
for _, it := range context.its {
- it(t)
+ it()
}
}
spec/spec_test.go
@@ -6,10 +6,10 @@ import (
func TestCalculator(t *testing.T) {
t.Run("when adding 1 + 1", func(t *testing.T) {
- Establish(t, func(x *Context) {
+ Establish(func(x *Context) {
x.Because(func() { x.Set("result", 1+1) })
- x.It(func(t *testing.T) {
+ x.It(func() {
result := x.Get("result").(int)
if result != 2 {
t.Errorf("Expected: 2, Got: %d", result)