Rspec-rails: Rails 5.1 capybara integration

Created on 27 Apr 2017  路  12Comments  路  Source: rspec/rspec-rails

Hi, I've on request/question, but don't know if it make sens ... so, sorry if not.

Rails 5.1, Capybara is integrate to rails http://edgeguides.rubyonrails.org/5_1_release_notes.html#system-tests, with commit https://github.com/rails/rails/pull/26703

This feature should avoid to use DatabaseCleaner for request spec. Example in rails doc is only with rails integrated test. Can we use this integration with rspec ? Rspec-rails should add this features or a possible way exist to do this right now ? Or maybe it's not possible ?

Most helpful comment

Hi Friends

We will be providing a type: :system example group which uses rails' new testing api. It will not use the test/application_system_test_case.rb configuration, but will allow you to use a similar API to specify your system test configuration.

All 12 comments

Rails has introduced something called system tests in 5.1, these use capybara to drive selenium for full stack testing, something we already support as 'feature' tests with capybara, potentially we could support there setup as well but you'd still need database cleaner where appropriate with both Rails own system tests and out setup

Additionally it seems transactional tests now won't require seperate rollback when the server is the same thread as the tests, which might be what your referring to, but has no change required for anything we use see https://github.com/rails/rails/pull/28083

Ok, thanks for your precision

@kaluznyo the only actual change I had to make for Rails 5.1 in terms of specs was removing DatabaseCleaner and changing my spec_helper.rb to have config.use_transactional_fixtures = true

@maschwenk does RSpec also pickup the Capybara configuration found in test/application_system_test_case.rb?

I've never used that, can't say

@tomekr unlikely, most rspec uses won't have a test folder, and we don't require it or look for it

Hi Friends

We will be providing a type: :system example group which uses rails' new testing api. It will not use the test/application_system_test_case.rb configuration, but will allow you to use a similar API to specify your system test configuration.

I've just pushed a WIP pr here: https://github.com/rspec/rspec-rails/pull/1813

Could someone shed some light on the difference between existing feature specs and @samphippen 's upcoming system specs? type: :feature vs type: :system They both use capybara and seem to do the same thing.

@pickerflicker type: :system will follow the blessed Rails approach, which uses puma and it's own stack rather than capybara's like currently.

Closing in favour of #1813

Was this page helpful?
0 / 5 - 0 ratings