是否可以在RSpec配置块中包含所有帮助程序模块?

问题描述 投票:1回答:1

我的RSpec配置块在我的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

有没有一种方法可以在一行中的RSpec configure块中简单地添加所有模块?我的助手文件中有很多模块,并且将继续向我的spec_helper中添加任何新模块。

我的RSpec配置块在我的spec_helper RSpec.configure do | config |中看起来像这样。 config.include Capybara :: DSL config.include Helpers config.include Helpers :: CustomFinders ...

ruby rspec capybara
1个回答
2
投票

您可以重构您的Helpers模块以自我包含所有子模块,然后在Rspec中您只需要包含Helpers模块

© www.soinside.com 2019 - 2024. All rights reserved.