目录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