我使用grape创建休息api我创建了API并且它的工作正常,现在我必须测试这个api.when我们创建rails api时会自动生成spec_helper.rb文件现在照常生成为测试第一行是如何测试简单的耙子应用程序
需要spec_helper
请告诉我应该是spec_helper.rb文件的代码
和其他的东西测试一个简单的耙application.i我给一个小的代码时,我应该集中例如,我必须测试片段
require 'grape'
require 'sequel'
require 'json'
module Twitter
class API < Grape::API
version 'v1', :using => :header, :vendor => 'twitter'
format :json
helpers do
def current_user
@current_user ||= User.authorize!(env)
end
def authenticate!
error!('401 Unauthorized', 401) unless current_user
end
end
resource :users do
desc "Return a status."
params do
requires :id, :type => Integer, :desc => "Status id."
optional :include , :type => String , :desc =>"parameter to include in "
end
get ':id' do
"Hello World"
end
时,我称这种葡萄应用
本地主机:9292 /用户/ 1234 随后的反应应该是“Hello World”的如何测试这个程序对于testing.i我只使用应该是什么内容spec_helper.rb文件葡萄不使用导轨
在一个目录中我创建了一个api .api工作正常如何测试它 –