validate_as_email 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Evently
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ValidateAsEmail
1
+ # ValidateAsEmail [![Build Status](https://secure.travis-ci.org/evently/validate_as_email.png?branch=master)](http://travis-ci.org/evently/validate_as_email) [![CodeClimate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/evently/validate_as_email)
2
2
 
3
3
  Validation of email addresses via the excellent Mail gem that is
4
4
  available in all Rails 3 applications.
@@ -0,0 +1,40 @@
1
+ Feature: ActiveModel validation
2
+
3
+ Scenario Outline: Validation via <Macro>
4
+ Given a file named "active_model_validation.rb" with:
5
+ """
6
+ require 'active_model'
7
+ require 'validate_as_email'
8
+
9
+ class Person
10
+ include ActiveModel::Validations
11
+
12
+ <Macro>
13
+
14
+ attr_accessor :email
15
+
16
+ def initialize(email)
17
+ @email = email
18
+ end
19
+ end
20
+
21
+ a = Person.new('james@logi.cl')
22
+ a.valid?
23
+
24
+ b = Person.new('invalid')
25
+ b.valid?
26
+
27
+ puts a.errors.to_a.inspect
28
+ puts b.errors.to_a.inspect
29
+ """
30
+ When I run `ruby active_model_validation.rb`
31
+ Then it should pass with:
32
+ """
33
+ []
34
+ ["Email is invalid"]
35
+ """
36
+
37
+ Examples:
38
+ | Macro |
39
+ | validates :email, email: true |
40
+ | validates_as_email :email |
@@ -0,0 +1,35 @@
1
+ Feature: ActiveRecord validation
2
+
3
+ Scenario Outline: Validation via <Macro>
4
+ Given a file named "active_record_validation.rb" with:
5
+ """
6
+ require 'logger'
7
+ require 'active_record'
8
+ require 'validate_as_email'
9
+
10
+ setup_active_record
11
+
12
+ class Person < ActiveRecord::Base
13
+ <Macro>
14
+ end
15
+
16
+ a = Person.new(email: 'james@logi.cl')
17
+ a.valid?
18
+
19
+ b = Person.new(email: 'invalid')
20
+ b.valid?
21
+
22
+ puts a.errors.to_a.inspect
23
+ puts b.errors.to_a.inspect
24
+ """
25
+ When I run `ruby active_record_validation.rb`
26
+ Then it should pass with:
27
+ """
28
+ []
29
+ ["Email is invalid"]
30
+ """
31
+
32
+ Examples:
33
+ | Macro |
34
+ | validates :email, email: true |
35
+ | validates_as_email :email |
@@ -0,0 +1,18 @@
1
+ $LOAD_PATH << '../../spec' unless $LOAD_PATH.include?('../../spec')
2
+ $LOAD_PATH.unshift '../../lib' unless $LOAD_PATH.include?('../../lib')
3
+
4
+ def setup_active_record
5
+ ActiveRecord::Base.logger = Logger.new(STDERR)
6
+
7
+ ActiveRecord::Base.establish_connection(
8
+ adapter: 'sqlite3',
9
+ dbfile: ':memory:',
10
+ database: 'validate_as_email_test'
11
+ )
12
+
13
+ ActiveRecord::Schema.define do
14
+ create_table :people do |t|
15
+ t.column :email, :string
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,35 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+
4
+ require 'aruba/cucumber'
5
+
6
+ # Borrowed from VCR
7
+ additional_paths = []
8
+
9
+ Before do
10
+ load_paths, requires = ['../../lib'], []
11
+
12
+ # Put any bundler-managed gems (such as :git gems) on the load path
13
+ # for when aruba shells out. Alternatively, we could hook up aruba to
14
+ # use bundler when it shells out, but invoking bundler for each and
15
+ # every time aruba starts ruby would slow everything down. We really
16
+ # only need it for bundler-managed gems.
17
+ load_paths.push($LOAD_PATH.grep %r|bundler/gems|)
18
+
19
+ if RUBY_VERSION < '1.9'
20
+ requires << 'rubygems'
21
+ else
22
+ load_paths << '.'
23
+ end
24
+
25
+ requires << '../../features/support/cucumber_helpers'
26
+ requires.map! { |r| "-r#{r}" }
27
+ set_env('RUBYOPT', "-I#{load_paths.join(':')} #{requires.join(' ')}")
28
+
29
+ if additional_paths.any?
30
+ existing_paths = ENV['PATH'].split(':')
31
+ set_env('PATH', (additional_paths + existing_paths).join(':'))
32
+ end
33
+
34
+ @aruba_timeout_seconds = RUBY_PLATFORM == 'java' ? 60 : 20
35
+ end
@@ -1,3 +1,3 @@
1
1
  module ValidateAsEmail
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -1,6 +1,3 @@
1
1
  require 'validate_as_email/version'
2
2
  require 'active_model'
3
3
  require 'active_model/validations/email_validator'
4
-
5
- module ValidateAsEmail
6
- end
@@ -0,0 +1,14 @@
1
+ $: << 'lib'
2
+
3
+ require 'validate_as_email'
4
+ require 'rspec/rails/extensions/active_record/base'
5
+
6
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each(&method(:require))
7
+
8
+ RSpec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+
13
+ config.order = 'random'
14
+ end
@@ -0,0 +1,25 @@
1
+ class Model
2
+ include ActiveModel::Validations
3
+
4
+ attr_accessor :attributes
5
+
6
+ def initialize(attributes = {})
7
+ @attributes = attributes
8
+ end
9
+
10
+ def read_attribute_for_validation(key)
11
+ @attributes[key]
12
+ end
13
+
14
+ def email
15
+ @attributes[:email]
16
+ end
17
+
18
+ def email=(email)
19
+ @attributes[:email] = email
20
+ end
21
+ end
22
+
23
+ class Person < Model
24
+ validates :email, email: true
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validate_as_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-19 00:00:00.000000000 Z
12
+ date: 2012-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: '2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: rspec-rails
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +107,54 @@ dependencies:
91
107
  - - ~>
92
108
  - !ruby/object:Gem::Version
93
109
  version: '0.4'
110
+ - !ruby/object:Gem::Dependency
111
+ name: appraisal
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '0.4'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '0.4'
126
+ - !ruby/object:Gem::Dependency
127
+ name: activerecord
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: '3'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '3'
142
+ - !ruby/object:Gem::Dependency
143
+ name: sqlite3
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: '1.3'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: '1.3'
94
158
  description: The ultimate Rails 3 email validator
95
159
  email:
96
160
  - james@logi.cl
@@ -102,7 +166,14 @@ files:
102
166
  - lib/validate_as_email/version.rb
103
167
  - lib/validate_as_email.rb
104
168
  - README.md
169
+ - LICENSE
170
+ - features/active_model.feature
171
+ - features/active_record.feature
172
+ - features/support/cucumber_helpers.rb
173
+ - features/support/env.rb
105
174
  - spec/active_model/validations/email_validator_spec.rb
175
+ - spec/spec_helper.rb
176
+ - spec/support/model.rb
106
177
  homepage: https://github.com/evently/mail_validator
107
178
  licenses: []
108
179
  post_install_message:
@@ -128,5 +199,11 @@ signing_key:
128
199
  specification_version: 3
129
200
  summary: The ultimate Rails 3 email validator. Powered by the Mail gem.
130
201
  test_files:
202
+ - features/active_model.feature
203
+ - features/active_record.feature
204
+ - features/support/cucumber_helpers.rb
205
+ - features/support/env.rb
131
206
  - spec/active_model/validations/email_validator_spec.rb
207
+ - spec/spec_helper.rb
208
+ - spec/support/model.rb
132
209
  has_rdoc: