3

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

1 Answer 1

9

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
Sign up to request clarification or add additional context in comments.

2 Comments

It seems test database will not get rolled back after using rspec. For example, if a user is created in a spec, it remains there next time rspec is executed.
Take a look at this gem github.com/bmabey/database_cleaner for cleaning database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.