spec/rest/whitelabel/domains_spec.rb in sendgrid4r-1.11.0 vs spec/rest/whitelabel/domains_spec.rb in sendgrid4r-1.12.0
- old
+ new
@@ -239,12 +239,11 @@
expect(domain2.ips).to eq([@ip])
end
it '#remove_ip_from_wl_domain' do
@client.add_ip_to_wl_domain(id: @domain2.id, ip: @ip)
- domain2 = @client.remove_ip_from_wl_domain(id: @domain2.id, ip: @ip)
- expect(domain2.ips).to eq(nil)
+ @client.remove_ip_from_wl_domain(id: @domain2.id, ip: @ip)
end
it '#validate_wl_domain' do
result1 = @client.validate_wl_domain(id: @domain1.id)
expect(result1).to be_a(Domains::Result)
@@ -288,115 +287,109 @@
let(:client) do
SendGrid4r::Client.new(api_key: '')
end
let(:domains) do
- JSON.parse('[]')
+ '[]'
end
let(:domain) do
- JSON.parse(
- '{'\
- '"id": 1,'\
- '"domain": "example.com",'\
- '"subdomain": "mail",'\
- '"username": "john@example.com",'\
- '"user_id": 7,'\
- '"ips": ['\
- '"192.168.1.1",'\
- '"192.168.1.2"'\
- '],'\
- '"custom_spf": true,'\
- '"default": true,'\
- '"legacy": false,'\
- '"automatic_security": true,'\
- '"valid": true,'\
- '"dns": {'\
- '"mail_cname": {'\
- '"host": "mail.example.com",'\
- '"type": "cname",'\
- '"data": "u7.wl.sendgrid.net",'\
- '"valid": true'\
- '},'\
- '"dkim1": {'\
- '"host": "s1._domainkey.example.com",'\
- '"type": "cname",'\
- '"data": "s1._domainkey.u7.wl.sendgrid.net",'\
- '"valid": true'\
- '},'\
- '"dkim2": {'\
- '"host": "s2._domainkey.example.com",'\
- '"type": "cname",'\
- '"data": "s2._domainkey.u7.wl.sendgrid.net",'\
- '"valid": true'\
- '}'\
+ '{'\
+ '"id": 1,'\
+ '"domain": "example.com",'\
+ '"subdomain": "mail",'\
+ '"username": "john@example.com",'\
+ '"user_id": 7,'\
+ '"ips": ['\
+ '"192.168.1.1",'\
+ '"192.168.1.2"'\
+ '],'\
+ '"custom_spf": true,'\
+ '"default": true,'\
+ '"legacy": false,'\
+ '"automatic_security": true,'\
+ '"valid": true,'\
+ '"dns": {'\
+ '"mail_cname": {'\
+ '"host": "mail.example.com",'\
+ '"type": "cname",'\
+ '"data": "u7.wl.sendgrid.net",'\
+ '"valid": true'\
+ '},'\
+ '"dkim1": {'\
+ '"host": "s1._domainkey.example.com",'\
+ '"type": "cname",'\
+ '"data": "s1._domainkey.u7.wl.sendgrid.net",'\
+ '"valid": true'\
+ '},'\
+ '"dkim2": {'\
+ '"host": "s2._domainkey.example.com",'\
+ '"type": "cname",'\
+ '"data": "s2._domainkey.u7.wl.sendgrid.net",'\
+ '"valid": true'\
'}'\
- '}'
- )
+ '}'\
+ '}'
end
let(:domain2) do
- JSON.parse(
- '{'\
- '"id": 2,'\
- '"user_id": 2,'\
- '"subdomain": "mail2",'\
- '"domain": "example.com",'\
- '"username": "john@example.com",'\
- '"ips": [],'\
- '"custom_spf": true,'\
- '"default": false,'\
- '"legacy": false,'\
- '"automatic_security": false,'\
- '"valid": false,'\
- '"dns": {'\
- '"mail_server": {'\
- '"valid": false,'\
- '"type": "mx",'\
- '"host": "mail2.example.com",'\
- '"data": "mx.sendgrid.net."'\
- '},'\
- '"subdomain_spf": {'\
- '"valid": false,'\
- '"type": "txt",'\
- '"host": "mail2.example.com",'\
- '"data": "v=spf1 include:sendgrid.net ~all"'\
- '},'\
- '"dkim": {'\
- '"valid": false,'\
- '"type": "txt",'\
- '"host": "m1._domainkey.example.com",'\
- '"data": "k=rsa; t=s; '\
- 'p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ"'\
- '}'\
+ '{'\
+ '"id": 2,'\
+ '"user_id": 2,'\
+ '"subdomain": "mail2",'\
+ '"domain": "example.com",'\
+ '"username": "john@example.com",'\
+ '"ips": [],'\
+ '"custom_spf": true,'\
+ '"default": false,'\
+ '"legacy": false,'\
+ '"automatic_security": false,'\
+ '"valid": false,'\
+ '"dns": {'\
+ '"mail_server": {'\
+ '"valid": false,'\
+ '"type": "mx",'\
+ '"host": "mail2.example.com",'\
+ '"data": "mx.sendgrid.net."'\
+ '},'\
+ '"subdomain_spf": {'\
+ '"valid": false,'\
+ '"type": "txt",'\
+ '"host": "mail2.example.com",'\
+ '"data": "v=spf1 include:sendgrid.net ~all"'\
+ '},'\
+ '"dkim": {'\
+ '"valid": false,'\
+ '"type": "txt",'\
+ '"host": "m1._domainkey.example.com",'\
+ '"data": "k=rsa; t=s; '\
+ 'p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ"'\
'}'\
- '}'
- )
+ '}'\
+ '}'
end
let(:result) do
- JSON.parse(
- '{'\
- '"id": 1,'\
- '"valid": true,'\
- '"validation_results": {'\
- '"mail_cname": {'\
- '"valid": false,'\
- '"reason": "Expected your MX record to be \"mx.sendgrid.net\" '\
- 'but found \"example.com\"."'\
- '},'\
- '"dkim1": {'\
- '"valid": true,'\
- '"reason": null'\
- '},'\
- '"dkim2": {'\
- '"valid": true,'\
- '"reason": null'\
- '}'\
+ '{'\
+ '"id": 1,'\
+ '"valid": true,'\
+ '"validation_results": {'\
+ '"mail_cname": {'\
+ '"valid": false,'\
+ '"reason": "Expected your MX record to be \"mx.sendgrid.net\" '\
+ 'but found \"example.com\"."'\
+ '},'\
+ '"dkim1": {'\
+ '"valid": true,'\
+ '"reason": null'\
+ '},'\
+ '"dkim2": {'\
+ '"valid": true,'\
+ '"reason": null'\
'}'\
- '}'
- )
+ '}'\
+ '}'
end
it '#get_domains' do
allow(client).to receive(:execute).and_return(domains)
actual = client.get_wl_domains
@@ -440,13 +433,13 @@
actual = client.add_ip_to_wl_domain(id: '', ip: '')
expect(actual).to be_a(Domains::Domain)
end
it '#remove_ip_from_domain' do
- allow(client).to receive(:execute).and_return(domain)
+ allow(client).to receive(:execute).and_return('')
actual = client.remove_ip_from_wl_domain(id: '', ip: '')
- expect(actual).to be_a(Domains::Domain)
+ expect(actual).to eq('')
end
it '#validate_domain' do
allow(client).to receive(:execute).and_return(result)
actual = client.validate_wl_domain(id: '')
@@ -470,11 +463,11 @@
actual = client.associate_wl_domain(id: '', username: '')
expect(actual).to be_a(Domains::Domain)
end
it 'creates domain instance' do
- actual = Domains.create_domain(domain)
+ actual = Domains.create_domain(JSON.parse(domain))
expect(actual).to be_a(Domains::Domain)
expect(actual.id).to eq(1)
expect(actual.domain).to eq('example.com')
expect(actual.subdomain).to eq('mail')
expect(actual.username).to eq('john@example.com')
@@ -504,11 +497,11 @@
expect(actual.dns.dkim2.data).to eq('s2._domainkey.u7.wl.sendgrid.net')
expect(actual.dns.dkim2.valid).to eq(true)
end
it 'creates domain2 instance' do
- actual = Domains.create_domain(domain2)
+ actual = Domains.create_domain(JSON.parse(domain2))
expect(actual).to be_a(Domains::Domain)
expect(actual.id).to eq(2)
expect(actual.domain).to eq('example.com')
expect(actual.subdomain).to eq('mail2')
expect(actual.username).to eq('john@example.com')
@@ -540,10 +533,10 @@
)
expect(actual.dns.dkim.valid).to eq(false)
end
it 'creates result instance' do
- actual = Domains.create_result(result)
+ actual = Domains.create_result(JSON.parse(result))
expect(actual).to be_a(Domains::Result)
expect(actual.id).to eq(1)
expect(actual.valid).to eq(true)
expect(actual.validation_results).to be_a(Domains::ValidationResults)
expect(actual.validation_results.dkim1).to be_a(