Skip to content

Instantly share code, notes, and snippets.

@ashb
Last active November 18, 2015 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashb/49b52245b863881f5822 to your computer and use it in GitHub Desktop.
Save ashb/49b52245b863881f5822 to your computer and use it in GitHub Desktop.
Trying out ginkgo -- what do other's think of the syntax?
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"))
})
})
})
})
@ashb
Copy link
Author

ashb commented Nov 18, 2015

The output looks like this:

(themisto ashb/jq-repl :+)% ginkgo -r -v
Running Suite: Jq Suite
=======================
Random Seed: 1447886104
Will run 5 of 5 specs

Jv KindName() function should return the right type
  for a null value
  /Users/ash/code/go/src/github.com/onsi/ginkgo/extensions/table/table_entry.go:37
•
------------------------------
Jv KindName() function should return the right type
  for a string value
  /Users/ash/code/go/src/github.com/onsi/ginkgo/extensions/table/table_entry.go:37
•
------------------------------
Jv of a nil value
  gives and error when String() is called
  /Users/ash/code/go/src/github.com/ashb/jq-repl/jq/jv_test.go:40
•
------------------------------
Jv String() for a non-string value
  should return an error
  /Users/ash/code/go/src/github.com/ashb/jq-repl/jq/jv_test.go:57
•
------------------------------
Jv String() for a string value
  should return the value
  /Users/ash/code/go/src/github.com/ashb/jq-repl/jq/jv_test.go:68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment