Commit 80c70d4

mo khan <mo@mokhan.ca>
2021-10-13 18:37:23
refactor: chain Set
1 parent 8b83d79
Changed files (2)
spec/spec.go
@@ -33,8 +33,9 @@ func (c *Context) It(it ItFunc) {
 	c.its = append(c.its, it)
 }
 
-func (c *Context) Set(key string, value interface{}) {
+func (c *Context) Set(key string, value interface{}) *Context {
 	c.state[key] = value
+	return c
 }
 
 func (c *Context) Get(key string) interface{} {
spec/spec_test.go
@@ -7,7 +7,7 @@ import (
 func TestCalculator(t *testing.T) {
 	t.Run("when adding 1 + 1", func(t *testing.T) {
 		Establish(func(x *Context) {
-			x.Because(func() { x.Set("result", 1+1) })
+			x.Because(func() { x.Set("result", 1+1).Set("2+2", 2+2) })
 
 			x.It(func() {
 				result := x.Get("result").(int)