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

integration with gomega #95

Open
charlierudolph opened this issue Aug 24, 2017 · 2 comments
Open

integration with gomega #95

charlierudolph opened this issue Aug 24, 2017 · 2 comments

Comments

@charlierudolph
Copy link
Member

Would love to have this so can have more expressive steps that don't need to reinvent the error logic.

https://github.com/onsi/gomega

I'm happy to work on this if you can give any pointers on where to start

@l3pp4rd
Copy link
Member

l3pp4rd commented Aug 24, 2017

Hi @charlierudolph nice to see you using go. regarding matchers, I will not add them as a hard dependency in godog it should be simple as it is, even if it is boring to check errors. Others prefer different libraries and godog should not advocate any and be based only on standard go ways.

Every godog step definition func must either return error or multi steps, you may combine any kind of matchers and nest them as long as they return an error. I think with some of the assertion libraries it is the right flow, but that should be simply an extension which you either prefer or not.

Do you have some specific ideas around integration?

@matt-simons
Copy link

if anyone else is looking for a way of integrating godog with gomega today, I've found the following to work quite well:

func shouldBeBar(foo string) (err error) {
    defer func() {
        if r := recover(); r != nil {
            err = fmt.Errorf("%s", r)
        }
    }()

    Expect(foo).Should(Equal("bar"))

    return err
}

where the gomega fail handler is simply registered to panic

gomega.RegisterFailHandler(func(message string, _ ...int) {
	panic(message)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants