sample_models 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem 'activerecord', ENV['ACTIVE_RECORD_VERSION']
7
+ gem "activesupport", ENV['ACTIVE_RECORD_VERSION']
8
+
9
+ # Add dependencies to develop your gem here.
10
+ # Include everything needed to run rake, tests, features, etc.
11
+ group :development do
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.6.0"
14
+ end
15
+
16
+ group :test do
17
+ gem 'sqlite3'
18
+ gem "validates_email_format_of"
19
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,25 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activerecord (2.3.10)
5
+ activesupport (= 2.3.10)
6
+ activesupport (2.3.10)
7
+ git (1.2.5)
8
+ jeweler (1.6.0)
9
+ bundler (~> 1.0.0)
10
+ git (>= 1.2.5)
11
+ rake
12
+ rake (0.8.7)
13
+ sqlite3 (1.3.3)
14
+ validates_email_format_of (1.4.5)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ activerecord (= 2.3.10)
21
+ activesupport (= 2.3.10)
22
+ bundler (~> 1.0.0)
23
+ jeweler (~> 1.6.0)
24
+ sqlite3
25
+ validates_email_format_of
data/Rakefile CHANGED
@@ -2,24 +2,9 @@ require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
4
  require 'rubygems'
5
- gem 'rspec'
6
5
 
7
6
  ActiveRecordVersions = %w(3.0.1 2.3.10)
8
7
 
9
- desc 'Default: run all tests and specs.'
10
- task :default => [:test, :spec]
11
-
12
- desc "Run all specs"
13
- task :spec do
14
- ActiveRecordVersions.each do |ar_version|
15
- ENV['ACTIVE_RECORD_VERSION'] = ar_version
16
- cmd = "rspec spec/sample_models_spec.rb"
17
- puts ar_version
18
- puts cmd
19
- puts `#{cmd}`
20
- end
21
- end
22
-
23
8
  desc "Run all tests"
24
9
  task :test do
25
10
  ActiveRecordVersions.each do |ar_version|
@@ -30,6 +15,8 @@ task :test do
30
15
  end
31
16
  end
32
17
 
18
+ task :default => :test
19
+
33
20
  desc 'Generate documentation for the sample_models plugin.'
34
21
  Rake::RDocTask.new(:rdoc) do |rdoc|
35
22
  rdoc.rdoc_dir = 'rdoc'
@@ -39,12 +26,13 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
39
26
  rdoc.rdoc_files.include('lib/**/*.rb')
40
27
  end
41
28
 
42
- begin
43
- require 'jeweler'
44
- Jeweler::Tasks.new do |gem|
45
- gem.name = "sample_models"
46
- gem.summary = %Q{A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases}
47
- gem.description = %Q{
29
+ require 'jeweler'
30
+ Jeweler::Tasks.new do |gem|
31
+ gem.name = "sample_models"
32
+ gem.homepage = "http://github.com/fhwang/sample_models"
33
+ gem.license = "MIT"
34
+ gem.summary = %Q{A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases}
35
+ gem.description = %Q{
48
36
  A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases. It aims to:
49
37
 
50
38
  * meet all your validations automatically
@@ -52,13 +40,9 @@ A library for making it extremely fast for Rails developers to set up and save A
52
40
  * give you a rich set of features so you can specify associated values as concisely as possible
53
41
  * do this with as little configuration as possible
54
42
  }
55
- gem.email = "francis.hwang@profitably.com"
56
- gem.homepage = "http://github.com/fhwang/sample_models"
57
- gem.authors = ["Francis Hwang"]
58
- gem.add_development_dependency('rspec')
59
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
60
- end
61
- Jeweler::GemcutterTasks.new
62
- rescue LoadError
63
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
43
+ gem.email = "francis.hwang@profitably.com"
44
+ gem.authors = ["Francis Hwang"]
45
+ # dependencies defined in Gemfile
64
46
  end
47
+ Jeweler::RubygemsDotOrgTasks.new
48
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.2.2
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sample_models}
8
- s.version = "1.2.1"
8
+ s.version = "1.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Francis Hwang"]
12
- s.date = %q{2010-12-18}
12
+ s.date = %q{2011-05-29}
13
13
  s.description = %q{
14
14
  A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases. It aims to:
15
15
 
@@ -23,71 +23,64 @@ A library for making it extremely fast for Rails developers to set up and save A
23
23
  "README.markdown"
24
24
  ]
25
25
  s.files = [
26
- ".gitignore",
27
- "MIT-LICENSE",
28
- "README.markdown",
29
- "Rakefile",
30
- "VERSION",
31
- "init.rb",
32
- "install.rb",
33
- "lib/sample_models.rb",
34
- "lib/sample_models/creation.rb",
35
- "lib/sample_models/finder.rb",
36
- "lib/sample_models/model.rb",
37
- "lib/sample_models/sampler.rb",
38
- "sample_models.gemspec",
39
- "spec/sample_models_spec.rb",
40
- "spec_or_test/database.yml",
41
- "spec_or_test/setup.rb",
42
- "spec_or_test/specs_or_test_cases.rb",
43
- "spec_or_test/vendor/validates_email_format_of/CHANGELOG",
44
- "spec_or_test/vendor/validates_email_format_of/MIT-LICENSE",
45
- "spec_or_test/vendor/validates_email_format_of/README",
46
- "spec_or_test/vendor/validates_email_format_of/TODO",
47
- "spec_or_test/vendor/validates_email_format_of/init.rb",
48
- "spec_or_test/vendor/validates_email_format_of/lib/validates_email_format_of.rb",
49
- "spec_or_test/vendor/validates_email_format_of/rakefile",
50
- "spec_or_test/vendor/validates_email_format_of/test/database.yml",
51
- "spec_or_test/vendor/validates_email_format_of/test/fixtures/people.yml",
52
- "spec_or_test/vendor/validates_email_format_of/test/fixtures/person.rb",
53
- "spec_or_test/vendor/validates_email_format_of/test/schema.rb",
54
- "spec_or_test/vendor/validates_email_format_of/test/test_helper.rb",
55
- "spec_or_test/vendor/validates_email_format_of/test/validates_email_format_of_test.rb",
56
- "tasks/sample_models_tasks.rake",
57
- "test/db/placeholder",
58
- "test/test_sample_models.rb",
59
- "uninstall.rb",
60
- "vendor/ar_query/MIT-LICENSE",
61
- "vendor/ar_query/README",
62
- "vendor/ar_query/ar_query.gemspec",
63
- "vendor/ar_query/init.rb",
64
- "vendor/ar_query/install.rb",
65
- "vendor/ar_query/lib/ar_query.rb",
66
- "vendor/ar_query/spec/ar_query_spec.rb",
67
- "vendor/ar_query/tasks/ar_query_tasks.rake",
68
- "vendor/ar_query/uninstall.rb"
26
+ "Gemfile",
27
+ "Gemfile.lock",
28
+ "MIT-LICENSE",
29
+ "README.markdown",
30
+ "Rakefile",
31
+ "VERSION",
32
+ "init.rb",
33
+ "install.rb",
34
+ "lib/sample_models.rb",
35
+ "lib/sample_models/creation.rb",
36
+ "lib/sample_models/finder.rb",
37
+ "lib/sample_models/model.rb",
38
+ "lib/sample_models/sampler.rb",
39
+ "sample_models.gemspec",
40
+ "spec/sample_models_spec.rb",
41
+ "spec_or_test/database.yml",
42
+ "spec_or_test/setup.rb",
43
+ "spec_or_test/specs_or_test_cases.rb",
44
+ "tasks/sample_models_tasks.rake",
45
+ "test/db/placeholder",
46
+ "test/test_sample_models.rb",
47
+ "uninstall.rb",
48
+ "vendor/ar_query/MIT-LICENSE",
49
+ "vendor/ar_query/README",
50
+ "vendor/ar_query/ar_query.gemspec",
51
+ "vendor/ar_query/init.rb",
52
+ "vendor/ar_query/install.rb",
53
+ "vendor/ar_query/lib/ar_query.rb",
54
+ "vendor/ar_query/spec/ar_query_spec.rb",
55
+ "vendor/ar_query/tasks/ar_query_tasks.rake",
56
+ "vendor/ar_query/uninstall.rb"
69
57
  ]
70
58
  s.homepage = %q{http://github.com/fhwang/sample_models}
71
- s.rdoc_options = ["--charset=UTF-8"]
59
+ s.licenses = ["MIT"]
72
60
  s.require_paths = ["lib"]
73
61
  s.rubygems_version = %q{1.3.7}
74
62
  s.summary = %q{A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases}
75
- s.test_files = [
76
- "spec/sample_models_spec.rb",
77
- "test/test_sample_models.rb"
78
- ]
79
63
 
80
64
  if s.respond_to? :specification_version then
81
65
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
82
66
  s.specification_version = 3
83
67
 
84
68
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
85
- s.add_development_dependency(%q<rspec>, [">= 0"])
69
+ s.add_runtime_dependency(%q<activerecord>, [">= 0"])
70
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
71
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
72
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
86
73
  else
87
- s.add_dependency(%q<rspec>, [">= 0"])
74
+ s.add_dependency(%q<activerecord>, [">= 0"])
75
+ s.add_dependency(%q<activesupport>, [">= 0"])
76
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
77
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
88
78
  end
89
79
  else
90
- s.add_dependency(%q<rspec>, [">= 0"])
80
+ s.add_dependency(%q<activerecord>, [">= 0"])
81
+ s.add_dependency(%q<activesupport>, [">= 0"])
82
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
83
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
91
84
  end
92
85
  end
93
86
 
@@ -1,14 +1,24 @@
1
- require 'rubygems'
2
- gem 'activerecord', ENV['ACTIVE_RECORD_VERSION']
3
- gem "activesupport", ENV['ACTIVE_RECORD_VERSION']
4
1
  RAILS_ENV = 'test'
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ begin
5
+ Bundler.setup(:default, :test)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+ require 'test/unit'
12
+
5
13
  require 'active_record'
6
14
  require 'active_record/base'
7
15
  require 'active_support/core_ext/logger'
16
+ require 'active_support/core_ext/module/attribute_accessors'
17
+ require 'validates_email_format_of'
8
18
 
9
- require File.dirname(__FILE__) +
10
- '/vendor/validates_email_format_of/lib/validates_email_format_of'
11
- require File.dirname(__FILE__) + '/../lib/sample_models'
19
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
20
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
21
+ require 'sample_models'
12
22
 
13
23
  # Configure ActiveRecord
14
24
  config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sample_models
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 2
10
+ version: 1.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Francis Hwang
@@ -15,12 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-18 00:00:00 -05:00
18
+ date: 2011-05-29 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
23
- prerelease: false
24
22
  requirement: &id001 !ruby/object:Gem::Requirement
25
23
  none: false
26
24
  requirements:
@@ -30,8 +28,56 @@ dependencies:
30
28
  segments:
31
29
  - 0
32
30
  version: "0"
33
- type: :development
31
+ type: :runtime
32
+ name: activerecord
33
+ prerelease: false
34
34
  version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ type: :runtime
46
+ name: activesupport
47
+ prerelease: false
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ hash: 23
56
+ segments:
57
+ - 1
58
+ - 0
59
+ - 0
60
+ version: 1.0.0
61
+ type: :development
62
+ name: bundler
63
+ prerelease: false
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ hash: 15
72
+ segments:
73
+ - 1
74
+ - 6
75
+ - 0
76
+ version: 1.6.0
77
+ type: :development
78
+ name: jeweler
79
+ prerelease: false
80
+ version_requirements: *id004
35
81
  description: |
36
82
 
37
83
  A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases. It aims to:
@@ -49,7 +95,8 @@ extensions: []
49
95
  extra_rdoc_files:
50
96
  - README.markdown
51
97
  files:
52
- - .gitignore
98
+ - Gemfile
99
+ - Gemfile.lock
53
100
  - MIT-LICENSE
54
101
  - README.markdown
55
102
  - Rakefile
@@ -66,19 +113,6 @@ files:
66
113
  - spec_or_test/database.yml
67
114
  - spec_or_test/setup.rb
68
115
  - spec_or_test/specs_or_test_cases.rb
69
- - spec_or_test/vendor/validates_email_format_of/CHANGELOG
70
- - spec_or_test/vendor/validates_email_format_of/MIT-LICENSE
71
- - spec_or_test/vendor/validates_email_format_of/README
72
- - spec_or_test/vendor/validates_email_format_of/TODO
73
- - spec_or_test/vendor/validates_email_format_of/init.rb
74
- - spec_or_test/vendor/validates_email_format_of/lib/validates_email_format_of.rb
75
- - spec_or_test/vendor/validates_email_format_of/rakefile
76
- - spec_or_test/vendor/validates_email_format_of/test/database.yml
77
- - spec_or_test/vendor/validates_email_format_of/test/fixtures/people.yml
78
- - spec_or_test/vendor/validates_email_format_of/test/fixtures/person.rb
79
- - spec_or_test/vendor/validates_email_format_of/test/schema.rb
80
- - spec_or_test/vendor/validates_email_format_of/test/test_helper.rb
81
- - spec_or_test/vendor/validates_email_format_of/test/validates_email_format_of_test.rb
82
116
  - tasks/sample_models_tasks.rake
83
117
  - test/db/placeholder
84
118
  - test/test_sample_models.rb
@@ -94,11 +128,11 @@ files:
94
128
  - vendor/ar_query/uninstall.rb
95
129
  has_rdoc: true
96
130
  homepage: http://github.com/fhwang/sample_models
97
- licenses: []
98
-
131
+ licenses:
132
+ - MIT
99
133
  post_install_message:
100
- rdoc_options:
101
- - --charset=UTF-8
134
+ rdoc_options: []
135
+
102
136
  require_paths:
103
137
  - lib
104
138
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -126,6 +160,5 @@ rubygems_version: 1.3.7
126
160
  signing_key:
127
161
  specification_version: 3
128
162
  summary: A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases
129
- test_files:
130
- - spec/sample_models_spec.rb
131
- - test/test_sample_models.rb
163
+ test_files: []
164
+
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- *~
2
- test/db/*.sqlite3
3
- *.log
4
- spec/*.log
5
- pkg/*
@@ -1,11 +0,0 @@
1
- = CHANGELOG
2
-
3
- == Version 1.0
4
- * initial version
5
-
6
- == Version 1.1 (the Francis Hwang edition)
7
- * moved Regexp out of class methods into the ValidatesEmailFormatOf module
8
-
9
- == TODO
10
- * Create additional test cases to represent more RFC 2822 possibilities
11
- * Package as gem
@@ -1,20 +0,0 @@
1
- Copyright (c) 2006 Alex Dunae
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,28 +0,0 @@
1
- = Validates email format
2
-
3
- Validate various formats of email address against RFC 2822.
4
-
5
- == Usage
6
-
7
- class Person < ActiveRecord::Base
8
- validates_email_format_of :email
9
- end
10
-
11
- == Testing
12
-
13
- To execute the unit tests run <tt>rake test</tt>.
14
-
15
- The unit tests for this plugin use an in-memory sqlite3 database.
16
-
17
- == Resources
18
-
19
- === Subversion
20
-
21
- * http://code.dunae.ca/validates_email_format_of
22
-
23
- == Credits
24
-
25
- Written by Alex Dunae (dunae.ca), 2006-07.
26
-
27
- Thanks to Francis Hwang (http://fhwang.net/) at Diversion Media for
28
- creating the 1.1 update.
@@ -1 +0,0 @@
1
- * Create additional test cases to represent more RFC 2822 possibilities
@@ -1 +0,0 @@
1
- require 'validates_email_format_of'
@@ -1,41 +0,0 @@
1
- module ValidatesEmailFormatOf
2
- Regex = /
3
- ^(
4
- ([A-Za-z0-9]+_+)|
5
- ([A-Za-z0-9]+\-+)|
6
- ([A-Za-z0-9]+\.+)|
7
- ([A-Za-z0-9]+\++)
8
- )*[A-Za-z0-9]+@
9
- ((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$
10
- /ix
11
- end
12
-
13
- module ActiveRecord
14
- module Validations
15
- module ClassMethods
16
- # Validates whether the value of the specified attribute is a valid email address
17
- #
18
- # class User < ActiveRecord::Base
19
- # validates_email_format_of :email, :on => :create
20
- # end
21
- #
22
- # Configuration options:
23
- # * <tt>message</tt> - A custom error message (default is: " does not appear to be a valid e-mail address")
24
- # * <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update)
25
- # * <tt>if</tt> - Specifies a method, proc or string to call to determine if the validation should
26
- # occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }). The
27
- # method, proc or string should return or evaluate to a true or false value.
28
- def validates_email_format_of(*attr_names)
29
- configuration = { :message => ' does not appear to be a valid e-mail address',
30
- :on => :save,
31
- :with => ValidatesEmailFormatOf::Regex }
32
-
33
- configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)
34
-
35
- validates_each(attr_names, configuration) do |record, attr_name, value|
36
- record.errors.add(attr_name, configuration[:message]) unless value.to_s =~ configuration[:with]
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,28 +0,0 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
-
5
- desc 'Default: run unit tests.'
6
- task :default => [:clean_log, :test]
7
-
8
- desc 'Remove the old log file'
9
- task :clean_log do
10
- "rm -f #{File.dirname(__FILE__)}/test/debug.log" if File.exists?(File.dirname(__FILE__) + '/test/debug.log')
11
- end
12
-
13
- desc 'Test the validates_email_format_of plugin.'
14
- Rake::TestTask.new(:test) do |t|
15
- t.libs << 'lib'
16
- t.pattern = 'test/**/*_test.rb'
17
- t.verbose = true
18
- end
19
-
20
- desc 'Generate documentation for the validates_email_format_of plugin.'
21
- Rake::RDocTask.new(:rdoc) do |rdoc|
22
- rdoc.rdoc_dir = 'rdoc'
23
- rdoc.title = 'validates_email_format_of plugin'
24
- rdoc.options << '--line-numbers --inline-source'
25
- rdoc.rdoc_files.include('README')
26
- rdoc.rdoc_files.include('TODO')
27
- rdoc.rdoc_files.include('lib/**/*.rb')
28
- end
@@ -1,3 +0,0 @@
1
- plugin_test:
2
- adapter: sqlite3
3
- database: ":memory:"
@@ -1,3 +0,0 @@
1
- existing:
2
- id: 1
3
- email: test@example.com
@@ -1,3 +0,0 @@
1
- class Person < ActiveRecord::Base
2
- validates_email_format_of :email, :on => :create, :message => 'fails with custom message'
3
- end
@@ -1,5 +0,0 @@
1
- ActiveRecord::Schema.define(:version => 0) do
2
- create_table :people, :force => true do |t|
3
- t.column "email", :string
4
- end
5
- end
@@ -1,35 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__) + '/../lib')
2
- RAILS_ROOT = File.dirname(__FILE__)
3
-
4
- require 'rubygems'
5
- require 'test/unit'
6
- require 'active_record'
7
- require 'active_record/fixtures'
8
- require 'active_support/binding_of_caller'
9
- require 'active_support/breakpoint'
10
- require "#{File.dirname(__FILE__)}/../init"
11
-
12
-
13
- config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
14
- ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
15
- ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'plugin_test'])
16
-
17
- load(File.dirname(__FILE__) + "/schema.rb") if File.exist?(File.dirname(__FILE__) + "/schema.rb")
18
-
19
- Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
20
- $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
21
-
22
- class Test::Unit::TestCase #:nodoc:
23
- def create_fixtures(*table_names)
24
- if block_given?
25
- Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
26
- else
27
- Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
28
- end
29
- end
30
-
31
- self.use_transactional_fixtures = false
32
-
33
- self.use_instantiated_fixtures = false
34
- end
35
-
@@ -1,82 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- class ValidatesEmailFormatOfTest < Test::Unit::TestCase
4
- fixtures :people
5
-
6
- def setup
7
- @valid_email = 'valid@example.com'
8
- @invalid_email = '_invalid@example.com'
9
- end
10
-
11
- def test_should_allow_valid_email_addresses
12
- ['valid@example.com',
13
- 'valid@test.example.com',
14
- 'valid+valid123@test.example.com',
15
- 'valid_valid123@test.example.com',
16
- 'valid-valid+123@test.example.co.uk',
17
- 'valid-valid+1.23@test.example.com.au',
18
- 'valid@example.co.uk',
19
- 'v@example.com',
20
- 'valid@example.ca',
21
- 'valid123.456@example.org',
22
- 'valid123.456@example.travel',
23
- 'valid123.456@example.museum',
24
- 'valid@example.mobi',
25
- 'valid@example.info'].each do |email|
26
- p = create_person(:email => email)
27
- save_passes(p, email)
28
- end
29
- end
30
-
31
- def test_should_not_allow_invalid_email_addresses
32
- ['_invalid@example.com',
33
- 'invalid@example-com',
34
- 'invalid_@example.com',
35
- 'invalid-@example.com',
36
- '.invalid@example.com',
37
- 'invalid.@example.com',
38
- 'invalid@example.com.',
39
- 'invalid@example.com_',
40
- 'invalid@example.com-',
41
- 'invalid-example.com',
42
- 'invalid@example.b#r.com',
43
- 'invalid@example.c',
44
- 'invali d@example.com',
45
- 'invalidexample.com',
46
- 'invalid@example.'].each do |email|
47
- p = create_person(:email => email)
48
- save_fails(p, email)
49
- end
50
- end
51
-
52
- def test_should_respect_validate_on_option
53
- p = create_person(:email => @valid_email)
54
- save_passes(p)
55
-
56
- assert p.update_attributes(:email => @invalid_email)
57
- assert_equal '_invalid@example.com', p.email
58
- end
59
-
60
- def test_should_allow_custom_error_message
61
- p = create_person(:email => @invalid_email)
62
- save_fails(p)
63
- assert_equal 'fails with custom message', p.errors.on(:email)
64
- end
65
-
66
- protected
67
- def create_person(params)
68
- Person.new(params)
69
- end
70
-
71
- def save_passes(p, email = '')
72
- assert p.valid?, " validating #{email}"
73
- assert p.save
74
- assert_nil p.errors.on(:email)
75
- end
76
-
77
- def save_fails(p, email = '')
78
- assert !p.valid?, " validating #{email}"
79
- assert !p.save
80
- assert p.errors.on(:email)
81
- end
82
- end