2017-05-11 14 views
0

我目前正在嘗試按照Ruby on Rails docs中給出的性能測試教程。但我陷入了第一步本身!「Rails生成performance_test」不可用?

當我嘗試給下面我得到一個錯誤執行命令,

命令:

$ rails generate performance_test homepage 

錯誤,我得到:

Could not find generator 'performance_test'. Maybe you meant 'integration_test', 'resource_route' or 'coffee:assets' 

我跑"rails generator --help"看到可能的文件可以生成,下面是我得到的輸出,

Running via Spring preloader in process 9465 
Expected string default value for '--jbuilder'; got true (boolean) 
Usage: rails generate GENERATOR [args] [options] 

General options: 
    -h, [--help]  # Print generator's options and usage 
    -p, [--pretend] # Run but do not make any changes 
    -f, [--force] # Overwrite files that already exist 
    -s, [--skip]  # Skip files that already exist 
    -q, [--quiet] # Suppress status output 

Please choose a generator below. 

Expected string default value for '--helper'; got true (boolean) 
Expected string default value for '--assets'; got true (boolean) 
Rails: 
    assets 
    channel 
    controller 
    generator 
    helper 
    integration_test 
    jbuilder 
    job 
    mailer 
    migration 
    model 
    resource 
    responders_controller 
    scaffold 
    scaffold_controller 
    task 

Coffee: 
    coffee:assets 

Js: 
    js:assets 

RailsScript: 
    rails_script:class 
    rails_script:controller 
    rails_script:element 
    rails_script:install 
    rails_script:utility 

Responders: 
    responders:install 

Rspec: 
    rspec:controller 
    rspec:feature 
    rspec:helper 
    rspec:install 
    rspec:integration 
    rspec:job 
    rspec:mailer 
    rspec:model 
    rspec:observer 
    rspec:request 
    rspec:scaffold 
    rspec:view 

SimpleCalendar: 
    simple_calendar:views 

TestUnit: 
    test_unit:controller 
    test_unit:generator 
    test_unit:helper 
    test_unit:integration 
    test_unit:job 
    test_unit:mailer 
    test_unit:model 
    test_unit:plugin 
    test_unit:scaffold 

如上所示,性能測試單元沒有在那裏定義。這是RoR 5中的情況嗎,還是我弄亂了項目,從而無法生成performance_test文件?

回答

0

Rails 4將performance_test從默認狀態中移除。你可以在你所提供的Rails的文檔鏈接看到,它是爲Rails 3.2.x中

https://github.com/rails/rails-perftest

由於軌道4個的性能測試是默認的堆棧不再一部分。

在他們的github頁面上有添加回來的說明,這裏是相關的寶石。

gem 'rails-perftest' 
gem 'ruby-prof' 
+0

謝謝!我不能投票你的答案,因爲我是一個新手。 此外,我確實看到該文檔是用於3.2.x,但即使在搜索Rails 5時也獲得了相同的文檔。 – TargetBlank