validates_as_email_address 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,9 @@
1
1
  *SVN*
2
2
 
3
+ *0.0.3* (June 22nd, 2008)
4
+
5
+ * Remove log files from gems
6
+
3
7
  *0.0.2* (May 5th, 2008)
4
8
 
5
9
  * Update documentation
data/README CHANGED
@@ -42,6 +42,14 @@ the email address.
42
42
  Before you can run any tests, the following gem must be installed:
43
43
  * plugin_test_helper[http://wiki.pluginaweek.org/Plugin_test_helper]
44
44
 
45
+ To run against a specific version of Rails:
46
+
47
+ rake test RAILS_FRAMEWORK_ROOT=/path/to/rails
48
+
49
+ == Dependencies
50
+
51
+ * Rails 2.0 or later
52
+
45
53
  == References
46
54
 
47
55
  * Cal Henderson - {Parsing Email Adresses in PHP}[http://iamcal.com/publish/articles/php/parsing_email]
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/gempackagetask'
4
4
  require 'rake/contrib/sshpublisher'
5
5
 
6
6
  PKG_NAME = 'validates_as_email_address'
7
- PKG_VERSION = '0.0.2'
7
+ PKG_VERSION = '0.0.3'
8
8
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
9
9
  RUBY_FORGE_PROJECT = 'pluginaweek'
10
10
 
@@ -22,6 +22,7 @@ desc 'Generate documentation for the validates_as_email_address plugin.'
22
22
  Rake::RDocTask.new(:rdoc) do |rdoc|
23
23
  rdoc.rdoc_dir = 'rdoc'
24
24
  rdoc.title = 'ValidatesAsEmailAddress'
25
+ rdoc.template = '../rdoc_template.rb'
25
26
  rdoc.options << '--line-numbers' << '--inline-source'
26
27
  rdoc.rdoc_files.include('README')
27
28
  rdoc.rdoc_files.include('lib/**/*.rb')
@@ -33,7 +34,7 @@ spec = Gem::Specification.new do |s|
33
34
  s.platform = Gem::Platform::RUBY
34
35
  s.summary = 'Adds support for validating the format/length of email addresses'
35
36
 
36
- s.files = FileList['{lib,test}/**/*'].to_a + %w(CHANGELOG init.rb LICENSE Rakefile README)
37
+ s.files = FileList['{lib,test}/**/*'].to_a - FileList['test/app_root/log/*'].to_a + %w(CHANGELOG init.rb LICENSE Rakefile README)
37
38
  s.require_path = 'lib'
38
39
  s.autorequire = 'validates_as_email_address'
39
40
  s.has_rdoc = true
@@ -61,13 +62,13 @@ task :pdoc => [:rdoc] do
61
62
  end
62
63
 
63
64
  desc 'Publish the API docs and gem'
64
- task :publish => [:pdoc, :release]
65
+ task :publish => [:pgem, :pdoc, :release]
65
66
 
66
67
  desc 'Publish the release files to RubyForge.'
67
68
  task :release => [:gem, :package] do
68
69
  require 'rubyforge'
69
70
 
70
- ruby_forge = RubyForge.new
71
+ ruby_forge = RubyForge.new.configure
71
72
  ruby_forge.login
72
73
 
73
74
  %w( gem tgz zip ).each do |ext|
data/test/factory.rb ADDED
@@ -0,0 +1,31 @@
1
+ module Factory
2
+ # Build actions for the class
3
+ def self.build(klass, &block)
4
+ name = klass.to_s.underscore
5
+ define_method("#{name}_attributes", block)
6
+
7
+ module_eval <<-end_eval
8
+ def valid_#{name}_attributes(attributes = {})
9
+ #{name}_attributes(attributes)
10
+ attributes
11
+ end
12
+
13
+ def new_#{name}(attributes = {})
14
+ #{klass}.new(valid_#{name}_attributes(attributes))
15
+ end
16
+
17
+ def create_#{name}(*args)
18
+ record = new_#{name}(*args)
19
+ record.save!
20
+ record.reload
21
+ record
22
+ end
23
+ end_eval
24
+ end
25
+
26
+ build User do |attributes|
27
+ attributes.reverse_merge!(
28
+ :email => 'john.smith@gmail.com'
29
+ )
30
+ end
31
+ end
data/test/test_helper.rb CHANGED
@@ -4,4 +4,10 @@ require 'rubygems'
4
4
  require 'plugin_test_helper'
5
5
 
6
6
  # Run the migrations
7
- ActiveRecord::Migrator.migrate("#{RAILS_ROOT}/db/migrate")
7
+ ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
8
+
9
+ # Mixin the factory helper
10
+ require File.expand_path("#{File.dirname(__FILE__)}/factory")
11
+ class Test::Unit::TestCase #:nodoc:
12
+ include Factory
13
+ end
@@ -1,15 +1,12 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
3
  class ValidatesAsEmailAddressTest < Test::Unit::TestCase
4
- def test_should_require_legal_rfc822_format
5
- [
6
- 'Max@Job 3:14',
7
- 'Job@Book of Job',
8
- 'J. P. \'s-Gravezande, a.k.a. The Hacker!@example.com',
9
- ].each do |address|
10
- assert !User.new(:email => address).valid?, "#{address} should be illegal."
11
- end
12
-
4
+ def test_should_be_valid_with_a_valid_set_of_attributes
5
+ user = new_user
6
+ assert user.valid?
7
+ end
8
+
9
+ def test_should_allow_legal_rfc822_formats
13
10
  [
14
11
  'test@example',
15
12
  'test@example.com',
@@ -18,12 +15,32 @@ class ValidatesAsEmailAddressTest < Test::Unit::TestCase
18
15
  'me@[187.223.45.119]',
19
16
  'someone@123.com',
20
17
  ].each do |address|
21
- assert User.new(:email => address).valid?, "#{address} should be legal."
18
+ user = new_user(:email => address)
19
+ assert user.valid?, "#{address} should be legal."
22
20
  end
23
21
  end
24
22
 
25
- def test_not_allow_email_addresses_longer_than_320_characters
26
- assert User.new(:email => 'a' * 314 + '@a.com').valid?
27
- assert !User.new(:email => 'a' * 315 + '@a.com').valid?
23
+ def test_should_not_allow_illegal_rfc822_formats
24
+ [
25
+ 'Max@Job 3:14',
26
+ 'Job@Book of Job',
27
+ 'J. P. \'s-Gravezande, a.k.a. The Hacker!@example.com',
28
+ ].each do |address|
29
+ user = new_user(:email => address)
30
+ assert !user.valid?, "#{address} should be illegal."
31
+ assert_equal 1, Array(user.errors.on(:email)).size
32
+ end
33
+ end
34
+
35
+ def test_not_allow_emails_longer_than_320_characters
36
+ user = new_user(:email => 'a' * 313 + '@a.com')
37
+ assert user.valid?
38
+
39
+ user.email = 'a' + user.email
40
+ assert user.valid?
41
+
42
+ user.email = 'a' + user.email
43
+ assert !user.valid?
44
+ assert_equal 1, Array(user.errors.on(:email)).size
28
45
  end
29
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_as_email_address
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Pfeifer
@@ -9,7 +9,7 @@ autorequire: validates_as_email_address
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-05 00:00:00 -04:00
12
+ date: 2008-06-22 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -22,19 +22,19 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
- - lib/validates_as_email_address.rb
26
25
  - lib/validates_as_email_address
27
26
  - lib/validates_as_email_address/rfc_822.rb
27
+ - lib/validates_as_email_address.rb
28
28
  - test/app_root
29
- - test/app_root/log
30
- - test/app_root/log/in_memory.log
31
- - test/app_root/db
32
- - test/app_root/db/migrate
33
- - test/app_root/db/migrate/001_create_users.rb
34
29
  - test/app_root/app
35
30
  - test/app_root/app/models
36
31
  - test/app_root/app/models/user.rb
32
+ - test/app_root/db
33
+ - test/app_root/db/migrate
34
+ - test/app_root/db/migrate/001_create_users.rb
35
+ - test/app_root/log
37
36
  - test/test_helper.rb
37
+ - test/factory.rb
38
38
  - test/unit
39
39
  - test/unit/validates_as_email_address_test.rb
40
40
  - CHANGELOG
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements: []
65
65
 
66
66
  rubyforge_project:
67
- rubygems_version: 1.1.0
67
+ rubygems_version: 1.1.1
68
68
  signing_key:
69
69
  specification_version: 2
70
70
  summary: Adds support for validating the format/length of email addresses
@@ -1,39 +0,0 @@
1
- # Logfile created on Sun Apr 06 00:59:11 -0400 2008 SQL (0.000430) select sqlite_version(*)
2
- SQL (0.000442) CREATE TABLE "schema_info" (version varchar(255))
3
- SQL (0.000121) INSERT INTO "schema_info" (version) VALUES(0)
4
- SQL (0.000224) SELECT version FROM schema_info
5
- Migrating to CreateUsers (1)
6
- SQL (0.000223)  SELECT name
7
- FROM sqlite_master
8
- WHERE type = 'table' AND NOT name = 'sqlite_sequence'
9
- 
10
- SQL (0.000428) select sqlite_version(*)
11
- SQL (0.000429) CREATE TABLE "schema_info" (version varchar(255))
12
- SQL (0.000115) INSERT INTO "schema_info" (version) VALUES(0)
13
- SQL (0.000221) SELECT version FROM schema_info
14
- Migrating to CreateUsers (1)
15
- SQL (0.000359) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar(320) NOT NULL) 
16
- SQL (0.000106) UPDATE schema_info SET version = 1
17
- SQL (0.000431) select sqlite_version(*)
18
- SQL (0.000426) CREATE TABLE "schema_info" (version varchar(255))
19
- SQL (0.000114) INSERT INTO "schema_info" (version) VALUES(0)
20
- SQL (0.000224) SELECT version FROM schema_info
21
- Migrating to CreateUsers (1)
22
- SQL (0.000352) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar(320) NOT NULL) 
23
- SQL (0.000105) UPDATE schema_info SET version = 1
24
- SQL (0.000460)  SELECT name
25
- FROM sqlite_master
26
- WHERE type = 'table' AND NOT name = 'sqlite_sequence'
27
- 
28
- SQL (0.000260) select sqlite_version(*)
29
- SQL (0.000324) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
30
- SQL (0.000255) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
31
- SQL (0.000211)  SELECT name
32
- FROM sqlite_master
33
- WHERE type = 'table' AND NOT name = 'sqlite_sequence'
34
- 
35
- SQL (0.000150) SELECT version FROM schema_migrations
36
- Migrating to CreateUsers (1)
37
- SQL (0.000093) SELECT version FROM schema_migrations
38
- SQL (0.000361) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar(320) NOT NULL) 
39
- SQL (0.000151) INSERT INTO schema_migrations (version) VALUES ('1')