Gomega Matchers for counterfeiter fakes
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
fixtures
invocations
LICENSE
README.md
argument_verifying.go
does_not_implement_interface_error.go
gcounterfeiter.go
gcounterfeiter_suite_test.go
gcounterfeiter_test.go
have_received.go
have_received_nothing.go
user_done_goofed.go

README.md

Go Report Card

Gomega Matchers for Counterfeiter

This package provides some helpful Gomega matchers that help you write effective assertions against counterfeiter fakes.

HaveReceived()

Verifies that a function was invoked on a counterfeiter fake.

e.g.:

myFake := new(FakeSomething)
myFake.Something("arg1", 0)
Expect(myFake).To(HaveReceived("Something").With(Equal("arg1")).AndWith(BeEquivalentTo(0)))

This actually works with any object that implements an "invocation recording" interface.

type Recorder interface{
  Invocations() map[string][][]interface{}
}

Implemented Features

  • one not need to specify a gomega matcher to check equality
    • e.g.: these are equivalent:
    • Expect(myFake).To(HaveReceived("Something").With(Equal("arg1"), Equal(0)))
    • Expect(myFake).To(HaveReceived("Something").With("arg1", 0))

Planned Features

(These would be good for new contributors)

  • I should be able to specify multiple arguments at once
    • e.g.: Expect(myFake).To(HaveReceived("Something").With(Equal("my-arg", Equal(0)))
  • I should be able to specify a number of times a function was invoked
    • e.g.: Expect(myFake).To(HaveReceived("Something").Times(1))