2017-05-07 08:04:49 -04:00
|
|
|
[![Build Status](https://travis-ci.org/ruby/mspec.svg?branch=master)](https://travis-ci.org/ruby/mspec)
|
|
|
|
|
|
|
|
## Overview
|
|
|
|
|
2019-01-20 15:38:27 -05:00
|
|
|
MSpec is a specialized framework that is syntax-compatible with RSpec 2 for
|
|
|
|
basic things like `describe`, `it` blocks and `before`, `after` actions.
|
|
|
|
MSpec contains additional features that assist in writing specs for
|
|
|
|
Ruby implementations in [ruby/spec](https://github.com/ruby/spec).
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
MSpec attempts to use the simplest Ruby language features so that beginning
|
2019-01-20 15:38:27 -05:00
|
|
|
Ruby implementations can run the Ruby specs. For example, no file from the
|
|
|
|
standard library or RubyGems is necessary to run MSpec.
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
MSpec is not intended as a replacement for RSpec. MSpec attempts to provide a
|
|
|
|
subset of RSpec's features in some cases and a superset in others. It does not
|
|
|
|
provide all the matchers, for instance.
|
|
|
|
|
|
|
|
However, MSpec provides several extensions to facilitate writing the Ruby
|
|
|
|
specs in a manner compatible with multiple Ruby implementations.
|
|
|
|
|
|
|
|
1. 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.
|
|
|
|
|
|
|
|
2. MSpec provides a different shared spec implementation specifically
|
|
|
|
designed to ease writing specs for the numerous aliased methods in Ruby.
|
|
|
|
|
|
|
|
3. MSpec provides various helper methods to simplify some specs, for
|
|
|
|
example, creating temporary file names.
|
|
|
|
|
|
|
|
4. MSpec has several specialized runner scripts that includes a
|
|
|
|
configuration facility with a default project file and user-specific
|
|
|
|
overrides.
|
|
|
|
|
2019-01-20 15:38:27 -05:00
|
|
|
5. MSpec support "tagging", that is excluding specs known as failing on
|
|
|
|
a particular Ruby implementation, and automatically adding and removing tags
|
|
|
|
while running the specs.
|
|
|
|
|
2017-09-14 11:56:09 -04:00
|
|
|
## Requirements
|
|
|
|
|
2019-06-27 15:02:33 -04:00
|
|
|
MSpec requires Ruby 2.4 or more recent.
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
## Bundler
|
|
|
|
|
|
|
|
A Gemfile is provided. Use Bundler to install gem dependencies. To install
|
|
|
|
Bundler, run the following:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
gem install bundler
|
|
|
|
```
|
|
|
|
|
|
|
|
To install the gem dependencies with Bundler, run the following:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
ruby -S bundle install
|
|
|
|
```
|
|
|
|
|
|
|
|
## Running Specs
|
|
|
|
|
|
|
|
Use RSpec to run the MSpec specs. There are no plans currently to make the
|
2019-09-29 10:03:47 -04:00
|
|
|
MSpec specs runnable by MSpec: https://github.com/ruby/mspec/issues/19.
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
After installing the gem dependencies, the specs can be run as follows:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
ruby -S bundle exec rspec
|
|
|
|
```
|
|
|
|
|
|
|
|
To run an individual spec file, use the following example:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
ruby -S bundle exec rspec spec/helpers/ruby_exe_spec.rb
|
|
|
|
```
|
|
|
|
|
|
|
|
## Documentation
|
|
|
|
|
2019-01-20 15:38:27 -05:00
|
|
|
See [CONTRIBUTING.md](https://github.com/ruby/spec/blob/master/CONTRIBUTING.md) in ruby/spec
|
|
|
|
for a list of matchers and how to use `mspec`.
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
## Source Code
|
|
|
|
|
|
|
|
See https://github.com/ruby/mspec
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
See the LICENSE in the source code.
|