github.com/onsi/ginkgo@v1.16.6-0.20211118180735-4e1925ba4c95/example/books/book_test.go (about)

     1  package books_test
     2  
     3  import (
     4  	. "github.com/onsi/ginkgo"
     5  	. "github.com/onsi/ginkgo/example/books"
     6  	. "github.com/onsi/gomega"
     7  )
     8  
     9  var _ = Describe("Book", func() {
    10  	var (
    11  		longBook  Book
    12  		shortBook Book
    13  	)
    14  
    15  	BeforeEach(func() {
    16  		longBook = Book{
    17  			Title:  "Les Miserables",
    18  			Author: "Victor Hugo",
    19  			Pages:  2783,
    20  		}
    21  
    22  		shortBook = Book{
    23  			Title:  "Fox In Socks",
    24  			Author: "Dr. Seuss",
    25  			Pages:  24,
    26  		}
    27  	})
    28  
    29  	Describe("Categorizing book length", func() {
    30  		Context("With more than 300 pages", func() {
    31  			It("should be a novel", func() {
    32  				Expect(longBook.CategoryByLength()).To(Equal("NOVEL"))
    33  			})
    34  		})
    35  
    36  		Context("With fewer than 300 pages", func() {
    37  			It("should be a short story", func() {
    38  				Expect(shortBook.CategoryByLength()).To(Equal("SHORT STORY"))
    39  			})
    40  		})
    41  	})
    42  })