Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby Rspec. Get list of all Test

Tags:

ruby

rspec

I have some test on Rspec, which looks like this:

describe "description" do

before :each do
  do_before()
end

it "something_1" do
  ...
end

it "something_2" do
  ...
end

end

I know that I can get name of current test ("something_1") by using

example.description

Is there any way to get array of all descriptions in before :each area?

like image 989
ShockwaveNN Avatar asked Apr 05 '12 13:04

ShockwaveNN


2 Answers

There used to be a way to do this using the tag --dry-run, but that has been removed and no longer works.

You can use the -fd which is for format = documentation. This will show you a long list of all the specs that you've done and what they look like. It does, however, still run the test and show you any errors you have in the process. That said it's still a great way to list of all of your tests.

like image 104
Eric C Avatar answered Nov 16 '22 01:11

Eric C


rspec -f d --color --dry-run filename

Works for me in rspec 3.5.2, lists all tests without running them

like image 32
Paul Odeon Avatar answered Nov 16 '22 02:11

Paul Odeon