Skip to content

Instantly share code, notes, and snippets.

@babie
Last active April 12, 2017 01:36
Show Gist options
  • Save babie/e1be11cb8bd69c99387205df6946b9a1 to your computer and use it in GitHub Desktop.
Save babie/e1be11cb8bd69c99387205df6946b9a1 to your computer and use it in GitHub Desktop.
Use stretchr/testify/assert on onsi/ginkgo without onsi/gomega.
package books_test
import (
. "github.com/onsi/ginkgo"
//. "github.com/onsi/gomega"
ta "github.com/stretchr/testify/assert"
"testing"
)
var assert = ta.New(GinkgoT())
func TestBooks(t *testing.T) {
//RegisterFailHandler(Fail)
RunSpecs(t, "App Suite")
}
package books_test
import (
//. "UNKNOWN_PACKAGE_PATH"
. "github.com/onsi/ginkgo"
//. "github.com/onsi/gomega"
)
type Book struct {
Title string
Author string
Pages int
}
var _ = Describe("Book", func() {
var (
longBook Book
shortBook Book
)
BeforeEach(func() {
longBook = Book{
Title: "Les Miserables",
Author: "Victor Hugo",
Pages: 1488,
}
shortBook = Book{
Title: "Fox In Socks",
Author: "Dr. Seuss",
Pages: 24,
}
})
Describe("Categorizing book length", func() {
Context("With more than 300 pages", func() {
It("should be a novel", func() {
// Success
assert.Equal(longBook.Pages, 1488)
//Expect(longBook.CategoryByLength()).To(Equal("NOVEL"))
})
})
Context("With fewer than 300 pages", func() {
It("should be a short story", func() {
// Fail
assert.Equal(shortBook.Pages, 1488)
//Expect(shortBook.CategoryByLength()).To(Equal("SHORT STORY"))
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment