Giter VIP home page Giter VIP logo

tests_from_rdoc's Introduction

Tests from RDoc

The idea is to extract test cases from method documentation.

Example

# lib/foo.rb
# See http://tomdoc.org/
module Foo
  # Public: Duplicate some text an arbitrary number of times.
  #
  # text  - The String to be duplicated.
  # count - The Integer number of times to duplicate the text.
  #
  # Examples
  #
  #   Foo.multiplex('Tom', 4) # => 'TomTomTomTom'
  #   Foo.multiplex('apple', 2) # => 'appleapple'
  #
  # Returns the duplicated String.
  def self.multiplex(text, count)
    text * count
  end
end

And the test:

# test/foo_test.rb
require_relative '../lib/foo'

class FooTest < MiniTest::Unit::TestCase
  tests_from_rdoc 'lib/foo.rb'
end

This is basically equal to a following test class:

class FooTest < MiniTest::Unit::TestCase
  def test_multiplex
    assert_equal 'TomTomTomTom', Foo.multiplex('Tom', 4)
    assert_equal 'appleapple', Foo.multiplex('apple', 2)
  end
end

TODO

  • handle TomDoc convention to put an expected result in a new line
  • ...
  • add rspec support

License

Copyright 2012 Wojciech Mach, see LICENSE.

tests_from_rdoc's People

Contributors

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