0

我正在使用 Middleman v4,我在控制台和使用 RSpec 对我的库进行单元测试时都遇到了问题。

现在我注释掉我的大部分config.rb文件,像这样。

require 'lib/foo'
require 'lib/bar'

#activate external_pipeline ...

#activate stuff

激活外部管道等功能会导致控制台和单元测试出现问题。我可以使用环境变量和条件来解决问题,但我想知道是否有人不得不解决这个问题。

4

1 回答 1

0

I have solved the problem by wrapping all the configuration I don't want to run in RSpec tests or Middleman Console in a conditional statement.

#config.rb
...
unless ENV['NO_CONFIG']
  ...
end

Then I run my tests with the variable set to avoid the config I don't want.

NO_CONFIG=TRUE bundle exec rspec

I just feel like it's an ugly solution and I wish there were something more elegant in Middleman.

于 2018-02-06T02:36:55.107 回答