Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#459 - tests remove deprecated methods #460

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
### Changed

- Changed underlying cobra command setup to return errors instead of calling `os.Exit` directly to enable simpler testing. ([454](https://github.com/cucumber/godog/pull/454) - [mxygem])
- Remove use of deprecated methods from `_examples`. ([460](https://github.com/cucumber/godog/pull/460) - [ricardogarfe])

## [v0.12.4]

Expand Down
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