How to prevent RSpec helpers from being loaded


Coding Rabbit

Currently, I'm using Capybara to write integration tests for our Rails 4 application. To make it as lightweight as possible, I wrote a capybara_helper.rbfile that lives in the specfolder I want to use with RSpec .

However, this file is loaded every time an RSpec test is run, breaking the configuration of existing Capybara tests that originally existed in the test suite.

Is there a way to tell/configure RSpec to not load this file when launching "normal" unit tests?

My integration test has the command loaded RAILS_ENV=test bundle exec rspec --tag @type:capybara. Our normal test just usesrake parallel:spec[4]

Larcombe

If you put capybara_helper code in a module, you can only include that module in rails helper for functional testing (i.e. capybara tests):

spec / support / capybara_helper.rb

module CapybaraHelper
  # Your code
end

In rails_helper.rb , include only modules for functional testing:

Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
RSpec.configure do |config|
  config.include CapybaraHelper, type: :feature
end

The above method will also work for example groups with markers . So in your case, I think the following approach should work (for tests marked with metadata type ::capybara).

RSpec.configure do |config|
  config.include CapybaraHelper, type: :capybara
end

Related


How to prevent RSpec helpers from being loaded

Coding Rabbit Currently, I'm using Capybara to write integration tests for our Rails 4 application. To make it as lightweight as possible, I wrote a capybara_helper.rbfile inside the specfolder I want to use with RSpec . However, this file is loaded every time

How to prevent RSpec helpers from being loaded

Coding Rabbit Currently, I'm using Capybara to write integration tests for our Rails 4 application. To make it as lightweight as possible, I wrote a capybara_helper.rbfile that lives in the specfolder I want to use with RSpec . However, this file is loaded eve

How to prevent RSpec helpers from being loaded

Coding Rabbit Currently, I'm using Capybara to write integration tests for our Rails 4 application. To make it as lightweight as possible, I wrote a capybara_helper.rbfile that is inside the folder I want to specuse with RSpec . However, this file is loaded ev

How to prevent RSpec helpers from being loaded

Coding Rabbit Currently, I'm using Capybara to write integration tests for our Rails 4 application. To make it as lightweight as possible, I wrote a capybara_helper.rbfile that is inside the folder I want to specuse with RSpec . However, this file is loaded ev

How to prevent RSpec helpers from being loaded

Coding Rabbit Currently, I'm using Capybara to write integration tests for our Rails 4 application. To make it as lightweight as possible, I wrote a capybara_helper.rbfile that is inside the folder I want to specuse with RSpec . However, this file is loaded ev

Helpers that prevent text from being displayed

User 3924026 This helper should look for hashtags and make them routes/links. Instead, it makes the text invisible. How can I fix this? Here is the code: handlebar.js Handlebars.registerHelper('hashtag', function(posttext) { posttext.html(); posttext =

Helpers that prevent text from being displayed

User 3924026 The helper should look for the hashtag and set it as a route/link. Instead, it keeps the text from being displayed. How can I fix this? Here is the code: handlebar.js Handlebars.registerHelper('hashtag', function(posttext) { posttext.html();

Helpers that prevent text from being displayed

User 3924026 The helper should look for the hashtag and set it as a route/link. Instead, it keeps the text from being displayed. How can I fix this? Here is the code: handlebar.js Handlebars.registerHelper('hashtag', function(posttext) { posttext.html();

How to prevent multiple copies of React from being loaded?

Sylar: In my previous Meteor app, using browserify and React, everything worked until I switched to meteor webpack . I'm using react-select in a Meteor app and it works great, but using browserify prevents multiple copies of react from being loaded, thus avoid

How to prevent multiple copies of React from being loaded?

Sylar: In my previous Meteor app, using browserify and React, everything worked until I switched to meteor webpack . I'm using react-select in a Meteor app and it works great, but using browserify prevents multiple copies of react from being loaded, thus avoid

How to prevent a specific dynamic library from being loaded

Herman I want to use an ancient software (Unreal Tournament "Classic" from 1999, also known as UT99). The dynamic library libtxc_dxtn.sois loaded implicitly in search of optional S3 Texture Compression (S3TC) support. Unfortunately, when loading the library, t

How to prevent data from being loaded in NgRx a second time?

Irina I have a DOM block: <div (click)="toggle(block)"> <div *ngIf="block.opened"> <div *ngFor="let item of block.items"></div> </div> </div> On click I dispatch action to load data from server and display this data in block: toggle(block: Regist

How to prevent a specific dynamic library from being loaded

Herman I want to use an ancient software (Unreal Tournament "Classic" from 1999, also known as UT99). The dynamic library libtxc_dxtn.sois loaded implicitly in search of optional S3 Texture Compression (S3TC) support. Unfortunately, when loading the library, t

How to prevent data from being loaded in NgRx a second time?

Irina I have a DOM block: <div (click)="toggle(block)"> <div *ngIf="block.opened"> <div *ngFor="let item of block.items"></div> </div> </div> On click I dispatch action to load data from server and display this data in block: toggle(block: Regist

How to prevent multiple copies of React from being loaded?

Syrah In my previous Meteor app, using browserify and React, everything worked fine until I switched to meteor webpack . I'm using react-select in a Meteor app and it works great, but using browserify prevents multiple copies of react from being loaded, thus a

How to prevent multiple copies of React from being loaded?

Sylar: In my previous Meteor app, using browserify and React, everything worked until I switched to meteor webpack . I'm using react-select in a Meteor app and it works great, but using browserify prevents multiple copies of react from being loaded, thus avoid

How to prevent a specific dynamic library from being loaded

Herman I want to use an ancient software (Unreal Tournament "Classic" from 1999, also known as UT99). The dynamic library libtxc_dxtn.sois loaded implicitly in search of optional S3 Texture Compression (S3TC) support. Unfortunately, when loading the library, t

How to prevent a specific dynamic library from being loaded

Herman I want to use an ancient software (Unreal Tournament "Classic" from 1999, also known as UT99). The dynamic library libtxc_dxtn.sois loaded implicitly in search of optional S3 Texture Compression (S3TC) support. Unfortunately, when loading the library, t

How to prevent data from being loaded in NgRx a second time?

Irina I have a DOM block: <div (click)="toggle(block)"> <div *ngIf="block.opened"> <div *ngFor="let item of block.items"></div> </div> </div> On click I dispatch action to load data from server and display this data in block: toggle(block: Regist

How to prevent data from being loaded in NgRx a second time?

Irina I have a DOM block: <div (click)="toggle(block)"> <div *ngIf="block.opened"> <div *ngFor="let item of block.items"></div> </div> </div> On click I dispatch action to load data from server and display this data in block: toggle(block: Regist