Sha256: a13fa0158e0878903bc07a8df51ee912a7739fce12b1415eba33b84ab389f204

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

= Kagemusha - A Testing Mock-Objects Library

http://github.com/nayutaya/kagemusha/

== DESCRIPTION:

Kagemusha is a library of helper functions
for testing Ruby scripts.  It helps you generating
scoped mock-objects which overrides the behavior of
a class only in a given blocks, without
tainting a global area.

For example, if you override Date.today when you are writing
something about dates, then the code will taint global
areas involuntarily.

But if you use Kagemusha, the test code will override
the behavior of the class only in the given block.

Example:
  require "kagemusha"

  musha = Kagemusha.new(Time)
  musha.defs(:now) { self.local(2000, 1, 1) }
  musha.def(:to_s) { self.strftime("%Y-%m-%d") } 

  musha.swap {
    p Time.now      #=> Sat Jan 01 00:00:00 +0900 2000
    p Time.now.to_s #=> "2000-01-01"
  }

Also, it has some default useful mock-objects set include
Date, Time and rand.

Example:
  require "kagemusha/date"

  musha = Kagemusha::Date.at(2000, 1, 1)
  musha.swap {
    p Date.today.to_s #=> "2000-01-01"
  }

== SYNOPSIS:

See the example directory.

== INSTALL:

The easiest way to get started with Kagemusha is to
install it via RubyGems. You can do this easily:

  $ gem install nayutaya-kagemusha

== LICENSE:

Ruby's License

== SUPPORT:

Contact me.
    Yuya Kato <yuyakato at gmail.com>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nayutaya-kagemusha-0.1.0 README