func registerHandler(res http.ResponseWriter, req *http.Request) { user := user.User{ Name: req.FormValue("name"), Email: req.FormValue("email"), Password: req.FormValue("password")} rerr := user.Save() if rerr != nil { ferr := templates.ExecuteTemplate(res, "failure.html", nil) if ferr != nil { sendError(res, ferr.Error()) } } serr := templates.ExecuteTemplate(res, "success.html", nil) if serr != nil { sendError(res, serr.Error()) } }
package user_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "user" ) var _ = Describe("User", func() { var u *user.User BeforeEach(func() { var err error u, err = user.New() Expect(err).NotTo(HaveOccurred()) }) Describe("Full Name", func() { Context("With a first and last name", func() { It("should concatenate the names with a ' '", func() { u.FirstName = "Peyton" u.LastName = "Manning" Expect(u.FullName()).To(Equal("Peyton Manning")) }) }) Context("With only a first name", func() { It("should return the first name", func() { u.FirstName = "Peyton" Expect(u.FullName()).To(Equal("Peyton")) })