3 RSpec is a Behaviour Driven Development framework with tools to express User Stories
4 with Executable Scenarios and Executable Examples at the code level.
6 RSpec ships with several modules:
8 Spec::Story provides a framework for expressing User Stories
10 Spec::Example provides a framework for expressing code Examples
12 Spec::Matchers provides Expression Matchers for use with Spec::Expectations
15 Spec::Expectations supports setting expectations on your objects so you
18 result.should equal(expected_result)
20 Spec::Mocks supports creating Mock Objects, Stubs, and adding Mock/Stub
21 behaviour to your existing objects.
25 The simplest approach is to install the gem:
27 gem install -r rspec #mac users must sudo
29 == Building the RSpec gem
30 If you prefer to build the gem locally, check out source from svn://rubyforge.org/var/svn/rspec/trunk. Then
34 gem install pkg/rspec-0.x.x.gem (you may have to sudo)
36 == Running RSpec's specs
37 In order to run RSpec's full suite of specs (rake pre_commit) you must install the following gems:
39 * rake # Runs the build script
40 * rcov # Verifies that the code is 100% covered by specs
41 * webby # Generates the static HTML website
42 * syntax # Required to highlight ruby code
43 * diff-lcs # Required if you use the --diff switch
44 * win32console # Required by the --colour switch if you're on Windows
45 * meta_project # Required in order to make releases at RubyForge
46 * heckle # Required if you use the --heckle switch
47 * hpricot # Used for parsing HTML from the HTML output formatter in RSpec's own specs
49 Once those are all installed, you should be able to run the suite with the following steps:
51 * svn co svn://rubyforge.org/var/svn/rspec/trunk rspec
53 * rake install_dependencies
54 * cd example_rails_app
55 * export RSPEC_RAILS_VERSION=1.2.3
56 * rake rspec:generate_mysql_config
57 * mysql -u root < db/mysql_setup.sql
61 Note that RSpec itself - once built - doesn't have any dependencies outside the Ruby core
62 and stdlib - with a few exceptions:
64 * The spec command line uses diff-lcs when --diff is specified.
65 * The spec command line uses heckle when --heckle is specified.
66 * The Spec::Rake::SpecTask needs RCov if RCov is enabled in the task.
68 See http://rspec.rubyforge.org for further documentation.