GithubHelp home page GithubHelp logo

bourne-1's Introduction

Deprecated

Given the introduction of test spies in rspec-mocks, Bourne is unnecessary in new versions of RSpec (> 2.14).

Bourne Build Status

Bourne extends mocha to allow detailed tracking and querying of stub and mock invocations. It allows test spies using the have_received rspec matcher and assert_received for Test::Unit. Bourne was extracted from jferris-mocha, a fork of mocha that adds test spies.

Test Spies

Test spies are a form of test double that preserves the normal four-phase unit test order and allows separation of stubbing and verification.

Using a test spy is like using a mocked expectation except that there are two steps:

  1. Stub out a method for which you want to verify invocations
  2. Use an assertion or matcher to verify that the stub was invoked correctly

Examples

RSpec:

mock.should have_received(:to_s)
Radio.should have_received(:new).with(1041)
radio.should have_received(:volume).with(11).twice
radio.should have_received(:off).never

You also want to configure RSpec to use mocha for mocking:

RSpec.configure do |config|
  config.mock_with :mocha
end

Test::Unit:

assert_received(mock, :to_s)
assert_received(Radio, :new) {|expect| expect.with(1041) }
assert_received(radio, :volume) {|expect| expect.with(11).twice }
assert_received(radio, :off) {|expect| expect.never }

See Mocha::API for more information.

Install

gem install bourne

More Information

Credits

Bourne was written by Joe Ferris. Mocha was written by James Mead. Several of the test examples and helpers used in the Bourne test suite were copied directly from Mocha.

Thanks to thoughtbot for inspiration, ideas, and funding. Thanks to James for writing mocha.

thoughtbot

Thank you to all the contributors!

The names and logos for thoughtbot are trademarks of thoughtbot, inc.

License

Bourne is Copyright © 2010-2013 Joe Ferris and thoughtbot. It is free software, and may be redistributed under the terms specified in the LICENSE file.

bourne-1's People

Contributors

sikachu avatar joshuaclayton avatar jferris avatar grosser avatar tristandunn avatar sgrif avatar harlow avatar drapergeek avatar ksylvest avatar dyfrgi avatar mike-burns avatar aviflombaum avatar opsb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.