Skip to content

Commit

Permalink
Remove unused RFC gem (#4068)
Browse files Browse the repository at this point in the history
* the RFC gem doesn't support ruby 3.3, but we don't seem to use it anyway
  • Loading branch information
sethboyles authored Nov 7, 2024
1 parent 1351c06 commit f54e578
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 62 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ gem 'public_suffix'
gem 'puma'
gem 'rake'
gem 'redis'
gem 'rfc822'
gem 'rubyzip', '>= 1.3.0'
gem 'sequel', '~> 5.86'
gem 'sequel_pg', require: 'sequel'
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ GEM
reverse_markdown (2.1.1)
nokogiri
rexml (3.3.9)
rfc822 (0.1.5)
roodi (5.0.0)
ruby_parser (~> 3.2, >= 3.2.2)
rspec (3.13.0)
Expand Down Expand Up @@ -651,7 +650,6 @@ DEPENDENCIES
railties (~> 7.2.1)
rake
redis
rfc822
roodi
rspec (~> 3.13.0)
rspec-collection_matchers
Expand Down
7 changes: 0 additions & 7 deletions lib/sequel_plugins/vcap_validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,5 @@ def validates_url(attr, opts={})

validates_format(URI::DEFAULT_PARSER.make_regexp(%w[http https]), attr, message: opts.fetch(:message, :url))
end

# Validates that an attribute is a valid email address
#
# @param [Symbol] The attribute to validate
def validates_email(attr)
validates_format(RFC822::EMAIL_REGEXP_WHOLE, attr, message: :email) if send(attr)
end
end
end
2 changes: 0 additions & 2 deletions lib/vcap/rest_api/message.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'vcap/json_message'
require 'rfc822'

module VCAP
module RestAPI
Expand Down Expand Up @@ -58,7 +57,6 @@ def self.schema_doc(schema)

URL = UrlDecorator.new(URI::DEFAULT_PARSER.make_regexp(%w[http https]))
HTTPS_URL = HttpsUrlDecorator.new(URI::DEFAULT_PARSER.make_regexp('https'))
EMAIL = EmailDecorator.new(RFC822::EMAIL_REGEXP_WHOLE)
GIT_URL = GitUrlDecorator.new(URI::DEFAULT_PARSER.make_regexp(%w[http https git]))

# The block will be evaluated in the context of the schema validator used
Expand Down
9 changes: 0 additions & 9 deletions spec/unit/lib/ext/validation_error_message_overrides_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@
end
end

context 'with a custom readable_regexp for an email' do
let(:regexp) { VCAP::RestAPI::Message::EMAIL }

it 'generates a readable message' do
expected_emsg = 'must be a valid email'
expect { subject.fail!(regexp, object) }.to raise_error(Membrane::SchemaValidationError, /#{expected_emsg}/)
end
end

context 'with a custom readable_regexp for a git URL' do
let(:regexp) { VCAP::RestAPI::Message::GIT_URL }

Expand Down
41 changes: 0 additions & 41 deletions spec/unit/lib/sequel_plugins/vcap_validations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,45 +63,4 @@ def self.define_validations(&)
end
end
end

describe 'validates_email' do
before do
@c.define_validations { validates_email(:val) }
end

it 'allows a valid email' do
@m.val = '[email protected]'
expect(@m).to be_valid
end

it 'does not allow an email with no domain' do
@m.val = 'some_guy'
expect(@m).not_to be_valid
end

it 'does not allow an email with no user' do
@m.val = '@somedomain.com'
expect(@m).not_to be_valid
end

it 'does not allow a malformed email with multiple @' do
@m.val = 'foo@[email protected]'
expect(@m).not_to be_valid
end

it 'allows a nil email' do
@m.val = nil
expect(@m).to be_valid
end

it 'does not allow an empty email' do
@m.val = ''
expect(@m).not_to be_valid
end

it 'does not allow an email with only spaces' do
@m.val = ' '
expect(@m).not_to be_valid
end
end
end

0 comments on commit f54e578

Please sign in to comment.