mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Merge pull request #360 from tgaff/tmg/rspec_with_capybara_doc
Add documentation for RSpec with Capybara
This commit is contained in:
commit
2b73593fc9
1 changed files with 26 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue