-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from emailable/setup_gh_actions
Setup GitHub actions
- Loading branch information
Showing
15 changed files
with
135 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: bundler | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 10 | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Ruby ${{ matrix.ruby-version }} | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby-version }} | ||
bundler-cache: true | ||
|
||
- name: Run tests | ||
run: bundle exec rake | ||
|
||
linters: | ||
name: Linters | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
|
||
- name: RuboCop | ||
run: bundle exec rubocop --parallel | ||
if: always() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
inherit_from: .rubocop_todo.yml | ||
|
||
inherit_gem: | ||
rubocop-cache-ventures: rubocop.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config --exclude-limit 10000` | ||
# on 2024-03-18 16:04:55 UTC using RuboCop version 1.62.1. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.7.4 | ||
3.3.0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,96 +3,91 @@ | |
|
||
class EmailValidatorTest < Minitest::Test | ||
|
||
def user_class( | ||
smtp: true, states: %i[deliverable risky unknown], free: true, role: true, | ||
accept_all: true, disposable: true, timeout: 3, **options | ||
) | ||
Class.new do | ||
include ActiveModel::Model | ||
attr_accessor :email, :email_verification_result | ||
|
||
validates :email, presence: true, email: { | ||
smtp: smtp, states: states, | ||
free: free, role: role, disposable: disposable, accept_all: accept_all, | ||
timeout: timeout | ||
}.merge(options) | ||
|
||
def self.name | ||
'TestClass' | ||
end | ||
|
||
# stub changes to always be true | ||
def changes | ||
{ email: true } | ||
end | ||
end | ||
end | ||
|
||
def setup | ||
Emailable.api_key = 'test_7aff7fc0142c65f86a00' | ||
sleep(0.25) | ||
end | ||
|
||
def test_valid | ||
@user = user_class.new(email: '[email protected]') | ||
valid_user = user_class.new(email: '[email protected]') | ||
|
||
assert @user.valid? | ||
assert @user.errors.empty? | ||
assert valid_user.valid? | ||
assert valid_user.errors.empty? | ||
end | ||
|
||
def test_invalid | ||
@user = user_class.new(email: '[email protected]') | ||
invalid_user = user_class.new(email: '[email protected]') | ||
|
||
assert !@user.valid? | ||
assert @user.errors[:email].present? | ||
refute invalid_user.valid? | ||
assert invalid_user.errors[:email].present? | ||
end | ||
|
||
def test_verification_result | ||
@user = user_class.new(email: '[email protected]') | ||
@user.valid? | ||
invalid_user = user_class.new(email: '[email protected]') | ||
invalid_user.valid? | ||
|
||
refute_nil @user.email_verification_result | ||
assert @user.email_verification_result.state, :undeliverable | ||
refute_nil invalid_user.email_verification_result | ||
assert_equal 'undeliverable', invalid_user.email_verification_result.state | ||
end | ||
|
||
def test_boolean_options | ||
def test_boolean_options_with_invalid_value | ||
%i[smtp free role disposable accept_all].each do |option| | ||
invalid_user = user_class(option => 'string').new | ||
valid_user = user_class.new | ||
invalid_options = user_class(option => 'string').new | ||
|
||
assert !valid_user.valid? | ||
assert_raises(ArgumentError) { invalid_user.valid? } | ||
assert_raises(ArgumentError) { invalid_options.valid? } | ||
end | ||
end | ||
|
||
def test_states_option | ||
invalid_user = user_class(states: %i[invalid_state]).new | ||
valid_user = user_class.new | ||
def test_states_option_with_invalid_value | ||
invalid_options = user_class(states: %i[invalid_state]).new | ||
|
||
assert !valid_user.valid? | ||
assert_raises(ArgumentError) { invalid_user.valid? } | ||
assert_raises(ArgumentError) { invalid_options.valid? } | ||
end | ||
|
||
def test_timeout_option | ||
invalid_user1 = user_class(timeout: 'string').new | ||
invalid_user2 = user_class(timeout: 1).new | ||
valid_user = user_class.new | ||
def test_timeout_option_with_invalid_value | ||
invalid_options1 = user_class(timeout: 'string').new | ||
invalid_options2 = user_class(timeout: 1).new | ||
|
||
assert !valid_user.valid? | ||
assert_raises(ArgumentError) { invalid_user1.valid? } | ||
assert_raises(ArgumentError) { invalid_user2.valid? } | ||
assert_raises(ArgumentError) { invalid_options1.valid? } | ||
assert_raises(ArgumentError) { invalid_options2.valid? } | ||
end | ||
|
||
def test_custom_option | ||
message = 'invalid message' | ||
invalid_user = user_class(message: message, reportable: true).new( | ||
valid_options = user_class(message: message, reportable: true).new( | ||
email: '[email protected]' | ||
) | ||
|
||
refute invalid_user.valid? | ||
assert invalid_user.errors[:email].present? | ||
assert_equal message, invalid_user.errors[:email].first | ||
assert invalid_user.errors.where(:email, reportable: true).present? | ||
refute valid_options.valid? | ||
assert valid_options.errors[:email].present? | ||
assert_equal message, valid_options.errors[:email].first | ||
assert valid_options.errors.where(:email, reportable: true).present? | ||
end | ||
|
||
private | ||
|
||
def user_class( | ||
smtp: true, states: %i[deliverable risky unknown], free: true, role: true, | ||
accept_all: true, disposable: true, timeout: 3, **options | ||
) | ||
Class.new do | ||
include ActiveModel::Model | ||
attr_accessor :email, :email_verification_result | ||
|
||
validates :email, presence: true, email: { | ||
smtp: smtp, states: states, | ||
free: free, role: role, disposable: disposable, accept_all: accept_all, | ||
timeout: timeout | ||
}.merge(options) | ||
|
||
def self.name | ||
'TestClass' | ||
end | ||
|
||
# stub changes to always be true | ||
def changes | ||
{ email: true } | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,10 @@ module Emailable | |
class BatchTest < Minitest::Test | ||
|
||
def setup | ||
sleep(1) | ||
Emailable.api_key = 'test_7aff7fc0142c65f86a00' | ||
@emails = ['[email protected]', '[email protected]'] | ||
@batch = Emailable::Batch.new(@emails) | ||
@batch_id ||= @batch.verify | ||
sleep(1) | ||
end | ||
|
||
def test_start_batch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ def test_verification_state | |
|
||
def test_verification_tag | ||
result = Emailable.verify('[email protected]') | ||
assert result.tag == 'marketing' | ||
assert_equal 'marketing', result.tag | ||
end | ||
|
||
def test_account | ||
|
@@ -49,33 +49,27 @@ def test_name_and_gender | |
end | ||
|
||
def test_accept_all? | ||
result = Emailable.verify('[email protected]') | ||
assert result.accept_all? | ||
assert Emailable.verify('[email protected]').accept_all? | ||
end | ||
|
||
def test_disposable? | ||
result = Emailable.verify('[email protected]') | ||
assert result.disposable? | ||
assert Emailable.verify('[email protected]').disposable? | ||
end | ||
|
||
def test_free? | ||
result = Emailable.verify('[email protected]') | ||
assert result.free? | ||
assert Emailable.verify('[email protected]').free? | ||
end | ||
|
||
def test_role? | ||
result = Emailable.verify('[email protected]') | ||
assert result.role? | ||
assert Emailable.verify('[email protected]').role? | ||
end | ||
|
||
def test_mailbox_full? | ||
result = Emailable.verify('[email protected]') | ||
assert result.mailbox_full? | ||
assert Emailable.verify('[email protected]').mailbox_full? | ||
end | ||
|
||
def test_no_reply? | ||
result = Emailable.verify('[email protected]') | ||
assert result.no_reply? | ||
assert Emailable.verify('[email protected]').no_reply? | ||
end | ||
|
||
def test_slow_verification | ||
|