Last active
November 18, 2015 22:35
-
-
Save ashb/49b52245b863881f5822 to your computer and use it in GitHub Desktop.
Trying out ginkgo -- what do other's think of the syntax?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jq_test | |
import ( | |
"github.com/ashb/jq-repl/jq" | |
. "github.com/onsi/ginkgo" | |
. "github.com/onsi/ginkgo/extensions/table" | |
. "github.com/onsi/gomega" | |
) | |
var _ = Describe("Jv", func() { | |
var ( | |
jv *jq.Jv | |
err error | |
) | |
AfterEach(func() { | |
if jv != nil { | |
jv.Free() | |
} | |
}) | |
DescribeTable("KindName() function should return the right type", | |
func(jv *jq.Jv, name string) { | |
Expect(jv.KindName()).To(Equal(name)) | |
jv.Free() | |
}, | |
Entry("for a null value", jq.JvNull(), "null"), | |
Entry("for a string value", jq.JvFromString("a"), "string"), | |
) | |
Context("of a nil value", func() { | |
BeforeEach(func() { | |
jv = jq.JvNull() | |
}) | |
It("gives and error when String() is called", func() { | |
_, err := jv.String() | |
Expect(err).To(HaveOccurred()) | |
}) | |
}) | |
Describe("String()", func() { | |
var str string | |
JustBeforeEach(func() { | |
str, err = jv.String() | |
}) | |
Context("for a non-string value", func() { | |
BeforeEach(func() { | |
jv = jq.JvNull() | |
}) | |
It("should return an error", func() { | |
Expect(err).Should(HaveOccurred()) | |
}) | |
}) | |
Context("for a string value", func() { | |
BeforeEach(func() { | |
jv = jq.JvFromString("test") | |
}) | |
It("should return the value", func() { | |
Expect(err).ShouldNot(HaveOccurred()) | |
Expect(str).To(Equal("test")) | |
}) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The output looks like this: