Coder Social home page Coder Social logo

pseudo's Introduction

Pseudo

Circle CI Code Climate Test Coverage

Pseudo is very simple test double library that supports only the features which support good mocking practices:

  • Stubbing
  • Spy-style mocking

Stubs

Stub a method.

double = Pseudo.new
double.stub(:stubbed_method)
double.stubbed_method # => nil

Stub a method with a return value.

double = Pseudo.new
double.stub(:stub_with_return).return(123)
double.stub_with_return # => 123

Stub a method to yield a value.

double = Pseudo.new
double.stub(:stub_with_yield).yield(456)
double.stub_with_yield do |value|
  value # => 456
end

Stub a method to raise an exception.

double = Pseudo.new
double.stub(:stub_with_raise).raise(ArgumentError, 'bad argument')
double.stub_with_raise
# ArgumentError: bad argument
#         from ...

Spies

Spies are a form of mock that doesn't break up the four-phase test structure.

def test_setup_exercise_verify_teardown
  double = Pseudo.new
  double.stub(:record_it)
  double.stub(:never_called)

  double.record_it

  assert_equal true, double.received?(:record_it)
  assert_equal false, double.received?(:never_called)
end

Requirements

  • Ruby 2.0.0+
  • Nothing else. No gem dependencies, nothing.

Installation

The best way to install Pseudo is with RubyGems:

$ [sudo] gem install pseudo

Contribute

If you'd like to make some changes to Pseudo, start by forking the repo on GitHub:

http://github.com/nwjsmith/pseudo

The best way to get contributions merged into Pseudo:

  1. Clone down your fork.
  2. Create a well-named topic branch for your change
  3. Make your change.
  4. Add tests and make sure everything passes (see the section on running the tests below).
  5. If you are adding new functionality, document it in the README.
  6. Do not change the version number.
  7. If necessary, rebase your commits into logical chunks, with no failing commits.
  8. Push the branch to GitHub.
  9. Send a pull request to the nwjsmith/pseudo project.

Run the tests

$ bundle install
$ bundle exec rake test

License

Pseudo is released under the MIT License.

pseudo's People

Contributors

nwjsmith avatar

Watchers

 avatar  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.