我知道有一种方法可以知道哪些规格占用的时间最多,但我对 RSpec 的加载感到怀疑。规格本身并不会花费太多时间,但负载却花费了太多时间。
有办法发现吗?
我正在研究 Rails 的遗留代码,但我不知道哪些 gem 可能会影响它。
在Ruby中(实际上是在Rails上),我具有以下try功能:
[].try(:[], 1) # => nil
[10].try(:[], 1) # => nil
[10, 20].try(:[], 1) # => 20
[10, 20, 30].try(:[], 1) # => 20
{}.try(:foo) # => nil
{ foo: 'bar' }.try(:foo) # => 'bar'
Run Code Online (Sandbox Code Playgroud)
该函数基本上是避免if检查位置是否存在的快捷方式。
Python中有类似的东西吗?
这个问题与此不同:rspec Bisect Runs Indefinitely
\n\n我的测试套件需要 \xc2\xb1 10 分钟才能运行。\n当我运行时bundle exec rspec --bisect=verbose,它卡住了 1 个多小时(这是我等待的最长时间):
bundle exec rspec --bisect=verbose\nAssetSync: using /home/belasis/dev/deploy_webapp/config/initializers/asset_sync.rb\nBisect started using options: "" and bisect runner: :fork\nRunning suite to find failures...\nRun Code Online (Sandbox Code Playgroud)\n\n我点击后Ctrl C,出现此消息:
\n\nBisect aborted!\n\nThe most minimal reproduction command discovered so far is:\n (Not yet enough information to provide any repro command)\nRun Code Online (Sandbox Code Playgroud)\n\n因此,问题在于它没有运行任何内容并且没有给出错误消息。这怎么可能?
\n