Git Product home page Git Product logo

testrocket's Introduction

 _            _                  _         _
| |_  ___ ___| |_ _ __ ___   ___| | __ ___| |_
| __|/ _ | __| __| '__/ _ \ / __| |/ // _ \ __|
| |_|  __|__ \ |_| | | (_) | (__|   <|  __/ |_
 \__|\___|___/\__|_|  \___/ \___|_|\_\\___|\__|

Testrocket is a super simple (as simple as it gets really) testing library for Ruby 2.0 and higher.

It was initially developed for a CodeBrawl contest and it won! People asked me to release it 'for real' so here we are.

To install:

gem install testrocket

.. or add it to your Gemfile in the usual way.

As yet there are no useful bits and pieces for creating test files (look at the example, it's easy!) or Rake tasks. But it's all crazy simple. A few things may be added later on.

Dependencies

  • Ruby 2.1 or higher
  • minitest/spec (part of MRI 1.9+ standard library)

Example

require 'testrocket'
using TestRocket

# BASIC USAGE
# +-> { block that should succeed }
# --> { block that should fail }

+-> { Die.new(2) }
--> { raise }
+-> { 2 + 2 == 4 }

# These two tests will deliberately fail
+-> { raise }
--> { true }

# A 'pending' test
~-> { "this is a pending test" }

# A description
!-> { "use this for descriptive output and to separate your test parts" }

As well as running tests in separate test files in the 'traditional' way, TestRocket can also be used 'inline' with real world code. A trivial example:

class YourClass
  using TestRocket

  def initialize
  end

  def does_something
    # ...
  end

  +->{  # a test for does_something goes here }

  def does_something_else
    # ...
  end

  +->{  # a test for does_something_else goes here }
  -->{  # a test for does_something_else goes here }
end

In this way, your class is tested each time you run the app in development or test modes. Note that if TestRocket detects RACK_ENV is production, RAILS_ENV is production or Rails is running and Rails.env.production? is true, the usual TestRocket methods will simply pass straight through so as to not impede performance on the loading of your app.

Other Features

By default, output is written to STDERR (as well as returned by the test expressions themselves). You can override where test output goes like so:

TestRocket.out = File.new('/dev/null', 'w')

TestRocket.out also supports Logger instances.

Credits

Initial concept and maintenance by Peter Cooper

Extra concepts and code by Christoph Grabo

Thanks to Gary Bernhardt for often praising and shining attention on TestRocket :-)

testrocket's People

Contributors

peterc avatar asaaki avatar smileart avatar alyssais avatar

Watchers

James Cloos 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.