Use webmock to stub external web requests.

This commit is contained in:
Guo Xiang Tan
2017-05-26 15:19:09 +08:00
parent f8f1548fd4
commit 56f98de7b2
10 changed files with 23 additions and 24 deletions

View File

@ -522,10 +522,8 @@ describe DiscourseNarrativeBot::TrackSelector do
describe 'when a quote is requested' do
it 'should create the right reply' do
Excon.stub({ method: :get, hostname: 'api.forismatic.com' },
status: 200,
body: "{\"quoteText\":\"Be Like Water\",\"quoteAuthor\":\"Bruce Lee\"}"
)
stub_request(:get, "http://api.forismatic.com/api/1.0/?format=json&lang=en&method=getQuote").
to_return(status: 200, body: "{\"quoteText\":\"Be Like Water\",\"quoteAuthor\":\"Bruce Lee\"}")
['@discobot quote', 'hello @discobot quote there'].each do |raw|
post.update!(raw: raw)