Vir*_*ual 3 ruby command-line unit-testing ruby-on-rails
我使用以下两个命令在我的应用程序中运行测试:
ruby -Ilib test/unit/account_test.rb
ruby -Itest test/unit/account_test.rb
Run Code Online (Sandbox Code Playgroud)
两者都工作正常。但是,有什么区别呢。这面旗帜到底-I
意味着什么?
来自 Ruby 手册页 ( man ruby
):
-I directory Used to tell Ruby where to load the library scripts. Direc\xe2\x80\x90\n tory path will be added to the load-path variable ($:).\n
Run Code Online (Sandbox Code Playgroud)\n\n该变量$:
(别名为$LOAD_PATH
)是目录数组,当您调用require
. 在您的情况下,这两个命令都运行良好,因为我猜您不需要测试代码中的任何内容lib
或目录。test