I only know the rake spec command which runs all the tests.
1 Answer
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
2 Comments
ZelluX
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.
Suborx
Take a look at this gem github.com/bmabey/database_cleaner for cleaning database.