github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/models/route_test.go (about)

     1  package models_test
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/cf/models"
     5  
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  )
     9  
    10  var _ = Describe("Route", func() {
    11  	Describe("URL", func() {
    12  		var (
    13  			r    models.Route
    14  			host string
    15  			path string
    16  		)
    17  
    18  		AfterEach(func() {
    19  			host = ""
    20  			path = ""
    21  		})
    22  
    23  		JustBeforeEach(func() {
    24  			r = models.Route{
    25  				Host: host,
    26  				Domain: models.DomainFields{
    27  					Name: "the-domain",
    28  				},
    29  				Path: path,
    30  			}
    31  		})
    32  
    33  		Context("when the host is blank", func() {
    34  			BeforeEach(func() {
    35  				host = ""
    36  			})
    37  
    38  			It("returns the domain", func() {
    39  				Expect(r.URL()).To(Equal("the-domain"))
    40  			})
    41  
    42  			Context("when the path is present", func() {
    43  				BeforeEach(func() {
    44  					path = "the-path"
    45  				})
    46  
    47  				It("returns the domain and path", func() {
    48  					Expect(r.URL()).To(Equal("the-domain/the-path"))
    49  				})
    50  			})
    51  		})
    52  
    53  		Context("when the host is not blank", func() {
    54  			BeforeEach(func() {
    55  				host = "the-host"
    56  			})
    57  
    58  			It("returns the host and domain", func() {
    59  				Expect(r.URL()).To(Equal("the-host.the-domain"))
    60  			})
    61  
    62  			Context("when the path is present", func() {
    63  				BeforeEach(func() {
    64  					path = "the-path"
    65  				})
    66  
    67  				It("returns the host and domain and path", func() {
    68  					Expect(r.URL()).To(Equal("the-host.the-domain/the-path"))
    69  				})
    70  			})
    71  		})
    72  	})
    73  })