|
| 1 | +require File.expand_path(File.dirname(__FILE__) + '/spec_helper') |
| 2 | + |
| 3 | +describe "MailboxvalidatorRuby" do |
| 4 | + it "work correctly with invalid api key" do |
| 5 | + mbv = MailboxValidator::MBV.new() |
| 6 | + mbv.apikey = $api_key |
| 7 | + mbv.query_single('[email protected]') |
| 8 | + expect(mbv.result.error_message).to eq 'API key not found.' |
| 9 | + end |
| 10 | + |
| 11 | + it "work correctly with api key exists" do |
| 12 | + if $api_key == 'YOUR_API_KEY' |
| 13 | + print "/* |
| 14 | +* You could enter a MailboxValidator API Key in spec/spec_helper.rb |
| 15 | +* for real web service calling test. |
| 16 | +* |
| 17 | +* You could sign up for a free API key at https://www.mailboxvalidator.com/plans#api |
| 18 | +* if you do not have one. |
| 19 | +*/" |
| 20 | + expect($api_key).to eq 'YOUR_API_KEY' |
| 21 | + else |
| 22 | + expect($api_key).to_not eq 'YOUR_API_KEY' |
| 23 | + end |
| 24 | + end |
| 25 | + |
| 26 | + it "work correctly with validate email" do |
| 27 | + mbv = MailboxValidator::MBV.new() |
| 28 | + mbv.apikey = $api_key |
| 29 | + mbv.query_single('[email protected]') |
| 30 | + if $api_key == 'YOUR_API_KEY' |
| 31 | + expect(mbv.result.error_code).to eq '101' |
| 32 | + else |
| 33 | + expect(mbv.result.status).to eq 'False' |
| 34 | + end |
| 35 | + end |
| 36 | + |
| 37 | + it "work correctly with disposable email" do |
| 38 | + mbv = MailboxValidator::MBV.new() |
| 39 | + mbv.apikey = $api_key |
| 40 | + mbv.disposable_email('[email protected]') |
| 41 | + if $api_key == 'YOUR_API_KEY' |
| 42 | + expect(mbv.result.error_code).to eq '101' |
| 43 | + else |
| 44 | + expect(mbv.result.status).to eq 'True' |
| 45 | + end |
| 46 | + end |
| 47 | + |
| 48 | + it "work correctly with free email" do |
| 49 | + mbv = MailboxValidator::MBV.new() |
| 50 | + mbv.apikey = $api_key |
| 51 | + mbv.free_email('[email protected]') |
| 52 | + if $api_key == 'YOUR_API_KEY' |
| 53 | + expect(mbv.result.error_code).to eq '101' |
| 54 | + else |
| 55 | + expect(mbv.result.status).to eq 'False' |
| 56 | + end |
| 57 | + end |
| 58 | + |
| 59 | +end |
0 commit comments