Пример #1
0
	})

	Context("Matching Accounts", func() {
		It("returns true for the first account name that matches", func() {
			filter, err := filters.NewRegexp(`Expenses\:\w+\:FastFood`, false)
			Expect(err).ToNot(HaveOccurred())
			Expect(filter.Filter(t)).To(HaveLen(1))
		})

		It("returns true for the second account name that matches", func() {
			filter, err := filters.NewRegexp(`Visa`, false)
			Expect(err).ToNot(HaveOccurred())
			Expect(filter.Filter(t)).To(HaveLen(1))
		})

		It("returns false for non-matching account names", func() {
			filter, err := filters.NewRegexp(`xxyyzz`, false)
			Expect(err).ToNot(HaveOccurred())
			Expect(filter.Filter(t)).To(HaveLen(0))
		})
	})

	It("registers title version with the store", func() {
		Expect(filters.Fetch("regexp-title")).To(HaveLen(1))
	})

	It("registers accounts version with the store", func() {
		Expect(filters.Fetch("regexp-accounts")).To(HaveLen(1))
	})
})
Пример #2
0
		})
	})

	It("has a map of filters", func() {
		filters.AddToStore("some-filter-name", mockFilterFactory)
		Expect(filters.Store()).To(HaveKey("some-filter-name"))
	})

	It("panics if the same name is added twice", func() {
		filters.AddToStore("some-other-name", nil)
		Expect(func() { filters.AddToStore("some-other-name", nil) }).To(Panic())
	})

	Describe("Fetch()", func() {
		It("returns all the matching filters", func() {
			filters.AddToStore("filter-1", mockFilterFactory)
			filters.AddToStore("filter-2", mockFilterFactory)
			filters, err := filters.Fetch("filter-1", "filter-2")

			Expect(err).ToNot(HaveOccurred())
			Expect(filters).To(HaveLen(2))
		})

		It("returns an error for an unknown name", func() {
			_, err := filters.Fetch("filter-3")
			Expect(err).To(HaveOccurred())
		})
	})

})