diff --git a/suite_context_test.go b/suite_context_test.go index e4ae8c7d..94c5204d 100644 --- a/suite_context_test.go +++ b/suite_context_test.go @@ -59,6 +59,15 @@ func InitializeScenario(ctx *ScenarioContext) { ctx.Step(`^the following steps? should be (passed|failed|skipped|undefined|pending):`, tc.followingStepsShouldHave) ctx.Step(`^the undefined step snippets should be:$`, tc.theUndefinedStepSnippetsShouldBe) + ctx.Step(`^I return a context from a step$`, tc.iReturnAContextFromAStep) + ctx.Step(`^I should see the context in the next step$`, tc.iShouldSeeTheContextInTheNextStep) + ctx.Step(`^I can see contexts passed in multisteps$`, func() Steps { + return Steps{ + "I return a context from a step", + "I should see the context in the next step", + } + }) + // event stream ctx.Step(`^the following events should be fired:$`, tc.thereShouldBeEventsFired) @@ -339,6 +348,21 @@ func (tc *godogFeaturesScenario) theUndefinedStepSnippetsShouldBe(body *DocStrin return nil } +func (tc *godogFeaturesScenario) iReturnAContextFromAStep(ctx context.Context) (context.Context, error) { + return context.WithValue(ctx, "key", "value"), nil +} + +func (tc *godogFeaturesScenario) iShouldSeeTheContextInTheNextStep(ctx context.Context) error { + value, ok := ctx.Value("key").(string) + if !ok { + return errors.New("context does not contain our key") + } + if value != "value" { + return errors.New("context has the wrong value for our key") + } + return nil +} + func (tc *godogFeaturesScenario) followingStepsShouldHave(status string, steps *DocString) error { var expected = strings.Split(steps.Content, "\n") var actual, unmatched, matched []string