7 . "github.com/onsi/ginkgo"
8 . "github.com/onsi/gomega"
9 . "github.com/onsi/gomega/matchers"
12 var _ = Describe("BeAnExistingFileMatcher", func() {
13 Context("when passed a string", func() {
14 It("should do the right thing", func() {
15 Ω("/dne/test").ShouldNot(BeAnExistingFile())
17 tmpFile, err := ioutil.TempFile("", "gomega-test-tempfile")
18 Ω(err).ShouldNot(HaveOccurred())
19 defer os.Remove(tmpFile.Name())
20 Ω(tmpFile.Name()).Should(BeAnExistingFile())
22 tmpDir, err := ioutil.TempDir("", "gomega-test-tempdir")
23 Ω(err).ShouldNot(HaveOccurred())
24 defer os.Remove(tmpDir)
25 Ω(tmpDir).Should(BeAnExistingFile())
29 Context("when passed something else", func() {
30 It("should error", func() {
31 success, err := (&BeAnExistingFileMatcher{}).Match(nil)
32 Ω(success).Should(BeFalse())
33 Ω(err).Should(HaveOccurred())
35 success, err = (&BeAnExistingFileMatcher{}).Match(true)
36 Ω(success).Should(BeFalse())
37 Ω(err).Should(HaveOccurred())