mirror of
https://github.com/danbee/my-images
synced 2025-03-04 08:49:05 +00:00
18 lines
376 B
Ruby
18 lines
376 B
Ruby
module ClarifaiHelpers
|
|
def stub_clarifai(tags)
|
|
WebMock.
|
|
stub_request(:post, Clarifai::API_URL).
|
|
to_return(status: 200, body: stub_body(tags).to_json)
|
|
end
|
|
|
|
def stub_body(tags)
|
|
{ "outputs": [{ "data": { "concepts": tag_structure(tags) } }] }
|
|
end
|
|
|
|
def tag_structure(tags)
|
|
tags.map do |tag|
|
|
{ "name": tag, "value": 0.95 }
|
|
end
|
|
end
|
|
end
|