Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Test spy extension to rspec-mocks

Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rdebugrc
Gemfile
README.rdoc
Rakefile
stirlitz.gemspec

README.rdoc

Stirlitz 0.0.1

A Test Spy extension to rspec-mocks.

Installing

gem install stirlitz

or add following in your Gemfile

gem 'stirlitz', :group => :test

Examples

With Stirlitz installed you can verify your mocks post calls

it "lets me know if a call had been made" do
  a_spy = spy(:spy)
  a_spy.a_method
  a_spy.should have_received(:a_method)
  a_spy.should_not have_received(:no_method)
end

It is also possible to verify the arguments passed while method invocation

it "lets me know if certain arguments were used" do
  a_spy = spy(:spy)
  a_spy.a_method(10, 20)
  a_spy.should have_received(:a_method).with(10, 20)
end

Limitations

The following will currently fail, and you have to mandatorily mention .with() if the method is being called with arguments.

it "lets me know if a call had been made with or without arguments" do
  a_spy = spy(:spy)
  a_spy.a_method(10, 20)
  a_spy.should have_received(:a_method) # This assertion will fail
end
Something went wrong with that request. Please try again.