github.com/jbking/gohan@v0.0.0-20151217002006-b41ccf1c2a96/util/test_util_test.go (about)

     1  // Copyright (C) 2015 NTT Innovation Institute, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //    http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
    12  // implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  
    16  package util
    17  
    18  import (
    19  	. "github.com/onsi/ginkgo"
    20  	. "github.com/onsi/gomega"
    21  )
    22  
    23  var _ = Describe("Custom matchers", func() {
    24  	Describe("JSON matcher", func() {
    25  		var (
    26  			boot   map[string]interface{}
    27  			sandal map[string]interface{}
    28  		)
    29  
    30  		BeforeEach(func() {
    31  			boot = map[string]interface{}{
    32  				"upper":   "long",
    33  				"sole":    "thick",
    34  				"comfort": 7,
    35  			}
    36  			sandal = map[string]interface{}{
    37  				"upper":   "none",
    38  				"sole":    "flexible",
    39  				"comfort": 11,
    40  			}
    41  		})
    42  
    43  		Context("When actual and expected match", func() {
    44  			It("should match them", func() {
    45  				Expect(boot).To(MatchAsJSON(boot))
    46  			})
    47  		})
    48  
    49  		Context("When actual and expected don't match", func() {
    50  			It("should match them", func() {
    51  				Expect(boot).ToNot(MatchAsJSON(sandal))
    52  			})
    53  		})
    54  	})
    55  })