Sha256: 5e4a953b656494d7d33319353f5287ad5c25d0a585e1628b30092a7d0fb69289
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
= Kagemusha - a library of testing mock-objects 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 behavior of the class restricted in given blocks, without tainting a global area. For example, if you override Date.today when you write something about dates, then the code will taint global areas to no purpose. If you use Kagemusha, the test code will override behavior of the class restricted in 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 default useful mock-objects set Date, Time, rand, and so on. Example: require "kagemusha/date" musha = Kagemusha::Date.at(2000, 1, 1) musha.swap { p Date.today.to_s #=> "2000-01-01" } == SYNOPSIS: see 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nayutaya-kagemusha-0.0.9 | README |