Skip to content

Commit

Permalink
Merge branch 'master' of github.com:emailable/emailable-ruby
Browse files Browse the repository at this point in the history
* 'master' of github.com:emailable/emailable-ruby:
  Added `mailbox_full?` and `no_reply?` support.
  Stop tracking Gemfile.lock
  • Loading branch information
jclusso committed Mar 27, 2023
2 parents c9cf073 + 45b7458 commit 999beb2
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 83 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/pkg/
/spec/reports/
/tmp/
Gemfile.lock
55 changes: 0 additions & 55 deletions Gemfile.lock

This file was deleted.

8 changes: 4 additions & 4 deletions lib/emailable/resources/verification.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module Emailable
class Verification < APIResource
attr_accessor :accept_all, :did_you_mean, :disposable, :domain, :duration,
:email, :free, :mx_record, :reason, :role, :score,
:smtp_provider, :state, :tag, :user, :first_name, :last_name,
:full_name, :gender
:email, :free, :mailbox_full, :mx_record, :no_reply, :reason,
:role, :score, :smtp_provider, :state, :tag, :user,
:first_name, :last_name, :full_name, :gender

%w(accept_all disposable free role).each do |method|
%w(accept_all disposable free role mailbox_full no_reply).each do |method|
define_method("#{method}?") do
instance_variable_get "@#{method}"
end
Expand Down
64 changes: 40 additions & 24 deletions test/emailable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,22 @@ class EmailableTest < Minitest::Test

def setup
Emailable.api_key = 'test_7aff7fc0142c65f86a00'
@result ||= Emailable.verify('jarrett@emailable.com')
sleep(0.25)
end

def test_verification
refute_nil @result.domain
refute_nil @result.email
refute_nil @result.reason
refute_nil @result.score
refute_nil @result.state
refute_nil @result.user
refute_nil @result.duration
result = Emailable.verify('jarrett@emailable.com')
refute_nil result.domain
refute_nil result.email
refute_nil result.reason
refute_nil result.score
refute_nil result.state
refute_nil result.user
refute_nil result.duration
end

def test_verification_state
assert %w(deliverable undeliverable risky unknown).include?(@result.state)
end

def test_verification_role
result = Emailable.verify('support@emailable.com')
assert result.role?
refute @result.role?
end

def test_verification_did_you_mean
result1 = Emailable.verify('jarrett@gmali.com')
result2 = Emailable.verify('jarrett@gmail.com')
assert result1.did_you_mean, 'jarrett@gmail.com'
assert_nil result2.did_you_mean
result = Emailable.verify('jarrett@emailable.com')
assert %w(deliverable undeliverable risky unknown).include?(result.state)
end

def test_verification_tag
Expand All @@ -42,7 +29,6 @@ def test_verification_tag

def test_account
account = Emailable.account

refute_nil account.owner_email
refute_nil account.available_credits
end
Expand All @@ -62,6 +48,36 @@ def test_name_and_gender
end
end

def test_accept_all?
result = Emailable.verify('accept-all@example.com')
assert result.accept_all?
end

def test_disposable?
result = Emailable.verify('disposable@example.com')
assert result.disposable?
end

def test_free?
result = Emailable.verify('free@example.com')
assert result.free?
end

def test_role?
result = Emailable.verify('role@example.com')
assert result.role?
end

def test_mailbox_full?
result = Emailable.verify('mailbox-full@example.com')
assert result.mailbox_full?
end

def test_no_reply?
result = Emailable.verify('no-reply@example.com')
assert result.no_reply?
end

def test_slow_verification
assert_raises(Emailable::TimeoutError) do
Emailable.verify('slow@example.com')
Expand Down

0 comments on commit 999beb2

Please sign in to comment.