brysgo / gomock_ginkgo

Workaround for using Gomock with Ginkgo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DON'T USE THIS

There is now a Gomock test reporter included in the thirdparty subpackage of Ginkgo!

See how here: http://onsi.github.io/ginkgo/#integrating-with-gomock

Gomock-Ginkgo

For historic purposes only

Gomock needs a reference to testing.T

This is a workaround adopted from this thread.

import (
  gomock "code.google.com/p/gomock/gomock"
  gomock_ginkgo "github.com/brysgo/gomock_ginkgo"
)

var _ = Describe("Handler", func() {
    var (
        t GinkgoTestReporter
        mockCtrl *gomock.Controller
        mockDatabase *models.MockDatabase
        handler *Handler
    )

    BeforeEach(func() {
        mockCtrl = gomock_ginkgo.NewController() // This line gives you a mock controller without `testing.T`
        mockDatabaseModel = models.NewMockDatabase(mockCtrl)
        handler = NewHandler(mockDatabase)
    })

    AfterEach(func() {
        mockCtrl.Finish()
    })

    // It() calls here
})

About

Workaround for using Gomock with Ginkgo


Languages

Language:Go 100.0%