mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:33:05 +08:00
init project
This commit is contained in:
30
spec/helpers.rb
Normal file
30
spec/helpers.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
module Helpers
|
||||
def help
|
||||
:available
|
||||
end
|
||||
|
||||
def debug
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
%w(get post patch put head delete cookies assigns follow_redirect!).each do |method|
|
||||
define_method("ec#{method}") do |url,params={}|
|
||||
__ec(method, url, params)
|
||||
end
|
||||
end
|
||||
|
||||
def __ec(method, url,params={})
|
||||
headers = {
|
||||
"ACCEPT" => "application/json", # This is what Rails 4 accepts
|
||||
"HTTP_ACCEPT" => "application/json" # This is what Rails 3 accepts
|
||||
}
|
||||
__send__(method, url+".json", params: params, headers: headers)
|
||||
|
||||
if debug
|
||||
puts response.body
|
||||
end
|
||||
|
||||
expect(response.content_type).to eq("application/json")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user