Coffee Bite
Coffee Bite

Reputation: 5164

How do I run only specific Rspec tests in rails?

I only know the rake spec command which runs all the tests.

Upvotes: 3

Views: 1690

Answers (1)

jamesshipton
jamesshipton

Reputation: 198

If you want to run all your specs in your spec folder

rspec spec

If you want to run all the specs in your user_spec.rb

rspec spec/models/user_spec.rb

If you want to run one spec from user_spec.rb on line 29

rspec spec/models/user_spec.rb -l 29

If you want to run all specs tagged with mytag

rspec spec --tag mytag

  it "is not valid without a name", :mytag do
    user = Factory.build(:User, :name => nil)
    user.should_not be_valid
  end

If your using bundler you will need to use

bundle exec rspec

Upvotes: 9

Related Questions