spec/rest/ips/warmup_spec.rb in sendgrid4r-0.5.0 vs spec/rest/ips/warmup_spec.rb in sendgrid4r-1.0.0
- old
+ new
@@ -3,26 +3,24 @@
describe SendGrid4r::REST::Ips::Warmup do
describe 'integration test', :it do
before do
Dotenv.load
- @client = SendGrid4r::Client.new(
- username: ENV['SILVER_SENDGRID_USERNAME'],
- password: ENV['SILVER_SENDGRID_PASSWORD'])
+ @client = SendGrid4r::Client.new(api_key: ENV['SILVER_API_KEY'])
end
context 'account is silver' do
before do
begin
# celan up test env
warmup_ips = @client.get_warmup_ips
if warmup_ips.length > 0
warmup_ips.each do |warmup_ip|
- @client.delete_warmup_ip(warmup_ip.ip)
+ @client.delete_warmup_ip(ip: warmup_ip.ip)
end
end
- rescue => e
+ rescue RestClient::ExceptionWithResponse => e
puts e.inspect
raise e
end
end
@@ -33,70 +31,25 @@
warmup_ips = @client.get_warmup_ips
expect(warmup_ips.length).to eq(0)
# post warmup ip
ips = @client.get_ips
expect(ips.length).to be > 0
- warmup_ip = @client.post_warmup_ip(ips[0].ip)
+ warmup_ip = @client.post_warmup_ip(ip: ips[0].ip)
expect(warmup_ip.ip).to eq(ips[0].ip)
- warmup_ip = @client.get_warmup_ip(warmup_ip.ip)
+ warmup_ip = @client.get_warmup_ip(ip: warmup_ip.ip)
expect(warmup_ip.ip).to eq(ips[0].ip)
# delete the warmup ip
- @client.delete_warmup_ip(warmup_ip.ip)
+ @client.delete_warmup_ip(ip: warmup_ip.ip)
expect do
- @client.get_warmup_ip(warmup_ip.ip)
+ @client.get_warmup_ip(ip: warmup_ip.ip)
end.to raise_error(RestClient::ResourceNotFound)
- rescue => ex
+ rescue RestClient::ExceptionWithResponse => ex
puts ex.inspect
raise ex
end
end
end
-
- context 'with block call' do
- it 'warmup_ip spec' do
- # get warmup ips
- @client.get_warmup_ips do |resp, req, res|
- resp =
- SendGrid4r::REST::Ips::Warmup.create_warmup_ips(
- JSON.parse(resp)
- )
- expect(resp).to be_a(Array)
- expect(req).to be_a(RestClient::Request)
- expect(res).to be_a(Net::HTTPOK)
- end
- # post warmup ip
- warmup_ip = nil
- ips = @client.get_ips
- expect(ips.length).to be > 0
- @client.post_warmup_ip(ips[0].ip) do |resp, req, res|
- resp =
- SendGrid4r::REST::Ips::Warmup.create_warmup_ip(
- JSON.parse(resp)
- )
- warmup_ip = resp
- expect(resp).to be_a(SendGrid4r::REST::Ips::Warmup::WarmupIp)
- expect(req).to be_a(RestClient::Request)
- expect(res).to be_a(Net::HTTPCreated)
- end
- # get warmup ip
- @client.get_warmup_ip(warmup_ip.ip) do |resp, req, res|
- resp =
- SendGrid4r::REST::Ips::Warmup.create_warmup_ip(
- JSON.parse(resp)
- )
- expect(resp).to be_a(SendGrid4r::REST::Ips::Warmup::WarmupIp)
- expect(req).to be_a(RestClient::Request)
- expect(res).to be_a(Net::HTTPOK)
- end
- # delete the warmup ip
- @client.delete_warmup_ip(warmup_ip.ip) do |resp, req, res|
- expect(resp).to eq('')
- expect(req).to be_a(RestClient::Request)
- expect(res).to be_a(Net::HTTPNoContent)
- end
- end
- end
end
end
describe 'unit test', :ut do
let(:client) do
@@ -132,22 +85,22 @@
end
end
it '#get_warmup_ip' do
allow(client).to receive(:execute).and_return(warmup_ip)
- actual = client.get_warmup_ip('')
+ actual = client.get_warmup_ip(ip: '')
expect(actual).to be_a(SendGrid4r::REST::Ips::Warmup::WarmupIp)
end
it '#post_warmup_ip' do
allow(client).to receive(:execute).and_return(warmup_ip)
- actual = client.post_warmup_ip('')
+ actual = client.post_warmup_ip(ip: '')
expect(actual).to be_a(SendGrid4r::REST::Ips::Warmup::WarmupIp)
end
it '#delete_warmup_ip' do
allow(client).to receive(:execute).and_return('')
- actual = client.delete_warmup_ip('')
+ actual = client.delete_warmup_ip(ip: '')
expect(actual).to eq('')
end
it 'creates warmup_ips instance' do
actual = SendGrid4r::REST::Ips::Warmup.create_warmup_ips(warmup_ips)