messaliberty

about hulor and us

Posts Tagged ‘rspec’

[Ruby] How to use RSpec – 01 QuickStart

March 13th, 2009 post by ice

RSpec is one of ruby’s testing frameworks for BDD(Behavior Driven Development).

Install RSpec

% sudo gem install rspec

Quickstart

Directory Structure for sample program below.
put libraries into lib/ directory.
put spec(test) programs into spec/directory.

  • sample_project/
    • lib/sample.rb sample library to test
    • spec/
      • sample_spec.rb test program for sample.rb
      • spec_helper.rb common settings and functions for all tests.

Create directories

Create a project directory, create lib and spec directory in the project directory.

% mkdir sample_project
% cd sample_project
% mkdir lib
% mkdir spec

Create spec_helper.rb (more…)