4 . "github.com/onsi/ginkgo"
5 . "github.com/onsi/gomega"
6 . "github.com/onsi/gomega/matchers"
9 var _ = Describe("MatchRegexp", func() {
10 Context("when actual is a string", func() {
11 It("should match against the string", func() {
12 Ω(" a2!bla").Should(MatchRegexp(`\d!`))
13 Ω(" a2!bla").ShouldNot(MatchRegexp(`[A-Z]`))
17 Context("when actual is a stringer", func() {
18 It("should call the stringer and match agains the returned string", func() {
19 Ω(&myStringer{a: "Abc3"}).Should(MatchRegexp(`[A-Z][a-z]+\d`))
23 Context("when the matcher is called with multiple arguments", func() {
24 It("should pass the string and arguments to sprintf", func() {
25 Ω(" a23!bla").Should(MatchRegexp(`\d%d!`, 3))
29 Context("when actual is neither a string nor a stringer", func() {
30 It("should error", func() {
31 success, err := (&MatchRegexpMatcher{Regexp: `\d`}).Match(2)
32 Ω(success).Should(BeFalse())
33 Ω(err).Should(HaveOccurred())
37 Context("when the passed in regexp fails to compile", func() {
38 It("should error", func() {
39 success, err := (&MatchRegexpMatcher{Regexp: "("}).Match("Foo")
40 Ω(success).Should(BeFalse())
41 Ω(err).Should(HaveOccurred())