Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Test spy extension to rspec-mocks

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rdebugrc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 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.