Merge pull request #360 from tgaff/tmg/rspec_with_capybara_doc

Add documentation for RSpec with Capybara
This commit is contained in:
Ernesto Tagwerker 2015-06-28 15:20:24 -03:00
commit 2b73593fc9

View file

@ -219,6 +219,32 @@ RSpec.configure do |config|
end
```
### RSpec with Capybara Example
If you're using Capybara with RSpec and using an external browser (not using RackTest) you'll almost certainly need to use truncation rather than transactions for tests tagged `:js`.
```ruby
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do |example|
DatabaseCleaner.strategy= example.metadata[:js] ? :truncation : :transaction
DatabaseCleaner.start
end
config.after(:each)
DatabaseCleaner.clean
end
end
```
### Minitest Example
```ruby