LinuxCommandLibrary

rspec

TLDR

Run all specs

$ rspec
copy
Run specific file
$ rspec [spec/models/user_spec.rb]
copy
Run specific line
$ rspec [spec/models/user_spec.rb:25]
copy
Run with tag
$ rspec --tag [focus]
copy
Exclude tag
$ rspec --tag ~[slow]
copy
Format output
$ rspec --format documentation
copy
Run failed specs
$ rspec --only-failures
copy
Random order
$ rspec --order random
copy

SYNOPSIS

rspec [--format fmt] [--tag tag] [options] [files]

DESCRIPTION

rspec is Ruby's behavior-driven testing framework. It provides readable test syntax.
Spec files describe expected behavior. Examples verify code meets expectations.
Matchers provide expressive assertions. Should, expect, and various comparison methods.
Tags organize and filter tests. Focus on specific categories or skip slow tests.
Failure tracking enables running only failed tests. Speeds up debugging cycles.
Formatters output results in various styles. Documentation format shows nested describe blocks.

PARAMETERS

--format FORMAT

Output format.
--tag TAG
Run tagged examples.
--only-failures
Run previously failed.
--order ORDER
Execution order.
--fail-fast
Stop on first failure.
--profile N
Show slowest examples.
--dry-run
Show without running.
-e, --example PATTERN
Match example name.

CAVEATS

Requires rspec gem. Rails apps use rspec-rails. Large suites may be slow.

HISTORY

RSpec was created by Steven Baker and David Chelimsky around 2005. It pioneered BDD-style testing in Ruby and influenced testing frameworks in other languages.

SEE ALSO

ruby(1), rake(1), minitest(1), cucumber(1)

Copied to clipboard