diff --git a/features/bootstrap/godog_test.go b/features/bootstrap/godog_test.go index eb1324c..5f67d5f 100644 --- a/features/bootstrap/godog_test.go +++ b/features/bootstrap/godog_test.go @@ -10,9 +10,10 @@ import ( "testing" "github.com/cucumber/godog" - "github.com/nhatthm/aferodog" "github.com/spf13/afero" "github.com/stretchr/testify/assert" + + "github.com/nhatthm/aferodog" ) // Used by init(). diff --git a/go.mod b/go.mod index fe9391a..0b9ec93 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,13 @@ go 1.16 require ( github.com/cucumber/godog v0.11.0 - github.com/cucumber/messages-go/v10 v10.0.3 github.com/gofrs/uuid v4.0.0+incompatible // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-memdb v1.3.2 // indirect github.com/nhatthm/aferoassert v0.1.5 github.com/nhatthm/aferomock v0.3.0 + github.com/nhatthm/expandog v0.2.0 github.com/spf13/afero v1.6.0 github.com/stretchr/testify v1.7.0 ) diff --git a/go.sum b/go.sum index 85d804d..aa080c8 100644 --- a/go.sum +++ b/go.sum @@ -159,6 +159,8 @@ github.com/nhatthm/aferoassert v0.1.5 h1:5BKwmRUpthkJpEPUPtcMHN37mdpFbYCECCJWhI/ github.com/nhatthm/aferoassert v0.1.5/go.mod h1:l5NAuwTqiLY2vXnNbi61wE9YkEu3L9SaTNmcRyMzn2Y= github.com/nhatthm/aferomock v0.3.0 h1:VaQORa7jawxeTi7yAAayE8ZUo7lYp5yyDn9j3wwKJNA= github.com/nhatthm/aferomock v0.3.0/go.mod h1:/oTcy0NDM+qQJEEOWiuiKuogilXvv/KZcdaXaP/rX3g= +github.com/nhatthm/expandog v0.2.0 h1:GDj8k9WhKhMsviq7GME+TKUc0N1f35Ai2CkWiKIv1xE= +github.com/nhatthm/expandog v0.2.0/go.mod h1:aDOzq5PpWfmfCiC0s0GKfseJWnnD/1ZaR+/3iu90bCA= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= diff --git a/manager.go b/manager.go index 8de078a..fdcd0f2 100644 --- a/manager.go +++ b/manager.go @@ -4,12 +4,11 @@ import ( "fmt" "os" "path/filepath" - "strings" "sync" "github.com/cucumber/godog" - "github.com/cucumber/messages-go/v10" "github.com/nhatthm/aferoassert" + "github.com/nhatthm/expandog" "github.com/spf13/afero" ) @@ -120,21 +119,11 @@ func (m *Manager) expandVariables(st *godog.Step) { cwd, err := os.Getwd() mustNoError(err) - replacer := strings.NewReplacer( - "$TEST_DIR", m.testDir, - "$CWD", cwd, - "$WORKING_DIR", cwd, - ) - - st.Text = replacer.Replace(st.Text) - - if st.Argument == nil { - return - } - - if msg, ok := st.Argument.Message.(*messages.PickleStepArgument_DocString); ok { - msg.DocString.Content = replacer.Replace(msg.DocString.Content) - } + expandog.ExpandStep(st, expandog.Pairs{ + "TEST_DIR": m.testDir, + "CWD": cwd, + "WORKING_DIR": cwd, + }) } func (m *Manager) trackPath(fs afero.Fs, path string) (string, error) {