目錄ruby
做者:莊廓然bash
在項目目錄下執行rails console test
能夠進入測試模式而且加載測試文件中的yml數據app
$ rails console test Loading test environment (Rails 5.1.7)
rails console 有三種環境,默認是開發環境,還有生產環境和測試環境,如下是參數說明post
Usage:
bin/rails console [environment] [options]測試Options:
-s, [--sandbox], [--no-sandbox] # Rollback database modifications on exit.
-e, [--environment=ENVIRONMENT] # Specifies the environment to run this console under (test/development/production).this
例如在routes中定義瞭如下路由:url
scope '/:club_id' do get '/information', to: 'clubs#information', as: :clubs_information #社團詳細信息 end
經過:code
> app.clubs_information_path(1) => "/clubs/1/information"
app.xxx
用來發送請求orm
get / post / put / delete均可以blog
app.post('url',params:{key:value}) #等價 app.get('clubs/1/information') app.get clubs_information_path(1)
發送請求後能夠用如下語句得到響應
app.response.body #得到響應體 app.response.status #得到響應狀態 app.response.headers.inspect