Skip to content

Commit

Permalink
cucumber#459 - tests remove deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogarfe committed Feb 18, 2022
1 parent c95871f commit c6537d6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
6 changes: 5 additions & 1 deletion _examples/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Now we can implemented steps, since we know what behavior we expect:
package main

import (
"context"
"bytes"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -159,7 +160,10 @@ func (a *apiFeature) theResponseShouldMatchJSON(body *godog.DocString) error {
func InitializeScenario(s *godog.ScenarioContext) {
api := &apiFeature{}

s.BeforeScenario(api.resetResponse)
ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
api.resetResponse(sc)
return ctx, nil
})

s.Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, api.iSendrequestTo)
s.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe)
Expand Down
7 changes: 5 additions & 2 deletions _examples/api/api_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -73,8 +74,10 @@ func (a *apiFeature) theResponseShouldMatchJSON(body *godog.DocString) (err erro
func InitializeScenario(ctx *godog.ScenarioContext) {
api := &apiFeature{}

ctx.BeforeScenario(api.resetResponse)

ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
api.resetResponse(sc)
return ctx, nil
})
ctx.Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, api.iSendrequestTo)
ctx.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe)
ctx.Step(`^the response should match json:$`, api.theResponseShouldMatchJSON)
Expand Down
4 changes: 3 additions & 1 deletion _examples/assert-godogs/godogs_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"
"os"
"testing"
Expand Down Expand Up @@ -63,8 +64,9 @@ func thereShouldBeNoneRemaining() error {
}

func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.BeforeScenario(func(*godog.Scenario) {
ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
Godogs = 0 // clean the state before every scenario
return ctx, nil
})

ctx.Step(`^there are (\d+) godogs$`, thereAreGodogs)
Expand Down
6 changes: 5 additions & 1 deletion _examples/db/api_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"database/sql"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -125,7 +126,10 @@ func (a *apiFeature) thereAreUsers(users *godog.Table) error {
func InitializeScenario(ctx *godog.ScenarioContext) {
api := &apiFeature{}

ctx.BeforeScenario(api.resetResponse)
ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
api.resetResponse(sc)
return ctx, nil
})

ctx.Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, api.iSendrequestTo)
ctx.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe)
Expand Down
4 changes: 3 additions & 1 deletion _examples/godogs/godogs_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"
"os"
"testing"
Expand Down Expand Up @@ -55,8 +56,9 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) {
}

func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.BeforeScenario(func(*godog.Scenario) {
ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
Godogs = 0 // clean the state before every scenario
return ctx, nil
})

ctx.Step(`^there are (\d+) godogs$`, thereAreGodogs)
Expand Down

0 comments on commit c6537d6

Please # to comment.