I want to get json from some url in rake task. how I can achive that?
I used this code
require 'open-uri'
content = open(my_url).read
logger.info content
but it throw WebMock::NetConnectNotAllowedError
it saying stub this request but how I can get responce from stub_request dont know
from controller it works fine
You need to place the webmock
gem in the test group:
# Gemfile
# ...
group :test do
gem 'webmock'
end
Or allow webmock to connect to the net if you are invoking the rake task in a test:
WebMock.allow_net_connect!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.