public
Description: Rubinius, the Ruby VM
Homepage: http://rubini.us
Clone URL: git://github.com/evanphx/rubinius.git
Search Repo:
benstiglitz (author)
Wed Apr 16 13:31:31 -0700 2008
febuiles (committer)
Fri Apr 18 21:20:37 -0700 2008
commit  6e27619990054e2596c432722b1399ddc76c0c5f
tree    ebc1e11f502c29753663d6cffe973791b2848b05
parent  2b3a44158ae93ab5883da22e5f36df92485f3ad4
rubinius / mspec
name age message
..
folder README Tue Apr 01 14:31:25 -0700 2008 Short overview of matchers in MSpec. [rue]
folder bin/ Fri Apr 18 18:37:09 -0700 2008 Added ProfileFilter to MSpec. [brixen]
folder capture.rb
folder complete.rb Thu Apr 03 21:35:31 -0700 2008 Remove non-functioning simple runner from MSpec... [brixen]
folder expectations.rb Mon Dec 17 15:08:39 -0800 2007 Added OutputMatcher to mspec. [brixen]
folder expectations/ Thu Apr 03 21:35:31 -0700 2008 Added unconditionally failing flunk method to M... [brixen]
folder matchers.rb Sun Mar 23 14:13:15 -0700 2008 Adds a be_empty matcher to MSpec [febuiles]
folder matchers/ Sun Mar 23 14:13:15 -0700 2008 MSpec specs for be_empty [febuiles]
folder mocks.rb
folder mocks/ Mon Feb 18 16:47:19 -0800 2008 Removed all uses of spec_runner from mSpec. [brixen]
folder runner.rb Mon Feb 18 16:47:20 -0800 2008 Combined split MSpec modules. Misc cleanup. [brixen]
folder runner/ Fri Apr 18 18:37:09 -0700 2008 Added ProfileFilter to MSpec. [brixen]
folder scratch.rb Sat Feb 23 00:07:06 -0800 2008 Preliminary changes to use instance_eval in MSpec. [brixen]
folder simple.rb Mon Dec 17 15:08:39 -0800 2007 Fixed require paths and a bit of restructuring. [brixen]
folder spec/ Fri Apr 18 18:37:09 -0700 2008 Added ProfileFilter to MSpec. [brixen]
folder spec_helper.rb Wed Apr 09 21:21:41 -0700 2008 MRI warnings are next to useless. [brixen]
folder version.rb Mon Feb 18 16:47:21 -0800 2008 Misc fixes to get MSpec running specs. [brixen]
README
 mSpec and mMock
=================

mSpec and mMock are simplistic apes of RSpec.

The primary design rationale for mSpec is simplicity to allow nascent Ruby
implementations to run the Ruby specs. So, for example, there is not great
concern given to constant clashes. Namespacing (or module scoping) is not used
because implementing this correctly took a significant amount of work in
Rubinius and it is likely that other implementations would also face
difficulties.

mSpec is not intended as a replacement for RSpec. mSpec attempts to provide a
subset of RSpec syntax. It does not provide all the matchers, for instance.

mSpec also provides several extensions to facilitate writing the Ruby specs in
a manner compatible with multiple Ruby implementations. First, mSpec offers a
set of guards to control execution of the specs. These guards not only enable
or disable execution but also annotate the specs with additional information
about why they are run or not run. Second, mSpec provides a different shared
spec implementation specifically designed to ease writing specs for the
numerous aliased methods in Ruby. The mSpec shared spec implementation should
not conflict with RSpec's own shared behavior facility.

Caveats:
* Use RSpec to run the mSpec specs. There are no plans currently to make
  the mSpec specs runnable by mSpec.
* Don't mock the #hash method as mMock uses Hash internally. This can be
  replaced if necessary, but at this point it's not worth it.


 Overview of Features
======================


 Matchers
----------

Matchers are additional aids for the verification process. The default
is of course to #should or #should_not using the #== operator and its
friends but the matchers add a new set of 'operators' to help in the
task. They reside in `mspec/matchers/`. There are two broad categories,
those that apply to an individual object and those that apply to a
block:

  Object
 --------

- `base` implements the standard #==, #< #<= #>= #> and #=~ with their
  normal semantics for the objects that you invoke them on.

- `be_ancestor_of` is equivalent to checking `obj.ancestors.include?`.

- `be_close` is a "delta" for floating-point math. Due to the very
  nature of it, floating-point comparisons should never be treated as
  exact. By default the tolerance is 0.00003 but it can be altered if
  so desired. So `0.23154.should be_close(0.23157)` would succeed
  (which is usually close enough for floating point unless you are
  doing some scientific computing.)

- `be_empty` checks `obj.empty?`

- `be_kind_of` is equivalent to `obj.kind_of?`

- `include` is `obj.include?`


  Block
 -------

All of these should be applied to a block created with `lambda` or `proc`:

- `complain` is probably clearer stated as `lambda {...}.should complain`;
  it checks that the block issues a warning. The message can be checked
  against either a String or a Regexp.

- `output` checks that the block produces the given output (stdout as well
  as stderr, in that order) matched either to a String or a Regexp. This one
  uses overrides so if that is a problem (for e.g. speccing Readline or
  something) see below.

- `output_to_fd` is a lower-level version and actually verifies that output
  to a certain file descriptor is correct whether from an in-/output stream
  or an actual file. Also can check with either a String or a Regexp.

- `raise_error` verifies the exception type (if any) raised by the block it
  is associated with. The exception class can be given for finer-grained
  control (inheritance works normally so Exception would catch everything.)