Skip to content

Test spy extension to rspec-mocks

Notifications You must be signed in to change notification settings

srushti/stirlitz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Test spy extension to rspec-mocks

Test spy extension to rspec-mocks

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages