Есть ли способ включить все вспомогательные модули в блок конфигурации RSpe c? - PullRequest
1 голос
/ 08 мая 2020

Мой блок RSpe c configure выглядит примерно так в моем spec_helper

RSpec.configure do |config|
  config.include Capybara::DSL
  config.include Helpers
  config.include Helpers::CustomFinders
  config.include Helpers::SignUp
  ...
end

Мой вспомогательный файл выглядит примерно так:

module Helpers

  module CustomFinders
    # method defs here
  end

  module SignUp
    # method defs here
  end

  # Other modules here

  # Some other method defs here also
  ...
end

Есть ли способ просто добавить ВСЕ модули в блок RSpe c configure в одну строку? В моем вспомогательном файле много модулей, и мне придется добавлять новые в мой spec_helper.

1 Ответ

2 голосов
/ 09 мая 2020

Вы можете выполнить рефакторинг своего Helpers модуля, чтобы включить все подмодули, тогда в Rspe c вам нужно будет только включить Helpers модуль

module Helpers
  def self.included(base)
    base.include CustomFinders
    base.include SignUp
  end

  module CustomFinders
    # method defs here
  end

  module SignUp
    # method defs here
  end

  # Other modules here

  # Some other method defs here also
end

In spec_helper.rb

RSpec.configure do |config|
  config.include Capybara::DSL
  config.include Helpers
end
...