Rake任务不会在我的sinatra应用程序中运行

时间:2015-12-04 22:40:04

标签: ruby ubuntu sinatra rake require

我有一个带有Rakefile.rake和server.rb文件的sinatra应用程序。在server.rb文件中我有

get '/' do
    rake :test
end

应用程序加载但在我加载localhost时崩溃:4567 /并为sinatra应用程序说未定义的方法'rake'。我尝试使用

来要求该文件
require '/home/user/project/Rakefile' 

我也试过Rakefile.rake,但两个都给我一个错误,上面写着“要求无法加载这样的文件”。我正在使用Ubuntu。

我不确定为什么sinatra无法加载rakefile,但是当我在终端中运行rake test时有效。

任何帮助都会很棒。

1 个答案:

答案 0 :(得分:2)

get '/' do
    system 'rake test'
end