Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

A tiny test double library

Resources

License

Packages

No packages published

Languages