Start setting up WebMock to stub responses
This commit is contained in:
parent
cc57973103
commit
d99487b19c
1 changed files with 31 additions and 2 deletions
33
spec/helpers/external/mailbluster_helper_spec.rb
vendored
33
spec/helpers/external/mailbluster_helper_spec.rb
vendored
|
|
@ -8,9 +8,38 @@ describe External::MailblusterHelper, type: :helper do
|
||||||
|
|
||||||
describe 'create_lead' do
|
describe 'create_lead' do
|
||||||
it 'makes a post request to Mailbluster\'s API' do
|
it 'makes a post request to Mailbluster\'s API' do
|
||||||
|
stub_request(:post, "http://api.mailbluster.com/api/leads")
|
||||||
|
.to_return(body: '{
|
||||||
|
"message": "Lead created",
|
||||||
|
"lead": {
|
||||||
|
"id": 329395,
|
||||||
|
"firstName": "Richard",
|
||||||
|
"lastName": "Hendricks",
|
||||||
|
"fullName": "Richard Hendricks",
|
||||||
|
"email": "richard@example.com",
|
||||||
|
"timezone": "America/Los_Angeles",
|
||||||
|
"ipAddress": "162.213.1.246",
|
||||||
|
"subscribed": false,
|
||||||
|
"meta": {
|
||||||
|
"company": "Pied Piper",
|
||||||
|
"role": "CEO",
|
||||||
|
"continent": "North America",
|
||||||
|
"country": "United States",
|
||||||
|
"city": "San Jose",
|
||||||
|
"latitude": 37.3008,
|
||||||
|
"longitude": -121.9777,
|
||||||
|
"source": "Lead API"
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"iPhone User",
|
||||||
|
"Startup"
|
||||||
|
],
|
||||||
|
"createdAt": "2016-07-23T08:03:18.954Z",
|
||||||
|
"updatedAt": "2016-07-23T08:03:18.954Z"
|
||||||
|
}
|
||||||
|
}', status: 200)
|
||||||
create_lead(user)
|
create_lead(user)
|
||||||
expect(WebMock).to have_requested(:post, "api.mailbluster.com/api/leads").
|
expect(WebMock).to have_requested(:post, "api.mailbluster.com/api/leads")
|
||||||
with { |req| req.body == "abc" }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue