diff --git a/custom_test.go b/custom_test.go index c8bd453..7594b6a 100644 --- a/custom_test.go +++ b/custom_test.go @@ -4,13 +4,14 @@ import ( "regexp" "testing" - "github.com/regen-network/gocuke" "github.com/stretchr/testify/require" + + "github.com/regen-network/gocuke" ) func TestCustomSteps(t *testing.T) { gocuke.NewRunner(t, &customStepsSuite{}). - Path("_examples/simple/simple.feature"). + Path("examples/simple/simple.feature"). Step(`I have (\d+) cukes`, (*customStepsSuite).A). Step(regexp.MustCompile(`I eat (\d+)`), (*customStepsSuite).B). Step(`I have (\d+) left`, (*customStepsSuite).C). diff --git a/_examples/api/api.go b/examples/api/api.go similarity index 100% rename from _examples/api/api.go rename to examples/api/api.go diff --git a/_examples/api/api_test.go b/examples/api/api_test.go similarity index 92% rename from _examples/api/api_test.go rename to examples/api/api_test.go index 2c65fe1..d255081 100644 --- a/_examples/api/api_test.go +++ b/examples/api/api_test.go @@ -6,9 +6,10 @@ import ( "net/http/httptest" "testing" - "github.com/regen-network/gocuke" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/regen-network/gocuke" ) type suite struct { @@ -19,7 +20,12 @@ type suite struct { func TestApi(t *testing.T) { scope := &suite{TestingT: t, resp: httptest.NewRecorder()} - gocuke.NewRunner(t, scope). + run := gocuke.NewRunner(t, scope) + run.Before(func() { + scope.resp = httptest.NewRecorder() + }) + + run. Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, scope.ISendRequestTo). Step(`^the response code should be (\d+)$`, scope.TheResponseCodeShouldBe). Step(`^the response should match json:$`, scope.TheResponseShouldMatchJson). diff --git a/_examples/api/features/version.feature b/examples/api/features/version.feature similarity index 100% rename from _examples/api/features/version.feature rename to examples/api/features/version.feature diff --git a/_examples/api/helpers.go b/examples/api/helpers.go similarity index 100% rename from _examples/api/helpers.go rename to examples/api/helpers.go diff --git a/_examples/datatable/datatable.feature b/examples/datatable/datatable.feature similarity index 100% rename from _examples/datatable/datatable.feature rename to examples/datatable/datatable.feature diff --git a/_examples/datatable/datatable_test.go b/examples/datatable/datatable_test.go similarity index 100% rename from _examples/datatable/datatable_test.go rename to examples/datatable/datatable_test.go diff --git a/_examples/simple/simple.feature b/examples/simple/simple.feature similarity index 100% rename from _examples/simple/simple.feature rename to examples/simple/simple.feature diff --git a/simple_test.go b/simple_test.go index 04ce17e..e504376 100644 --- a/simple_test.go +++ b/simple_test.go @@ -7,7 +7,7 @@ import ( ) func TestSimple(t *testing.T) { - gocuke.NewRunner(t, &simpleSuite{}).Path("_examples/simple/simple.feature").Run() + gocuke.NewRunner(t, &simpleSuite{}).Path("examples/simple/simple.feature").Run() } type simpleSuite struct { @@ -31,7 +31,7 @@ func (s *simpleSuite) IHaveLeft(a int64) { // test if a struct that doesn't use a pointer and a global var func TestSimpleNonPointer(t *testing.T) { - gocuke.NewRunner(t, simpleSuiteNP{}).Path("_examples/simple/simple.feature").Run() + gocuke.NewRunner(t, simpleSuiteNP{}).Path("examples/simple/simple.feature").Run() } var globalCukes int64