schema_validations 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ gemfile:
6
+ - gemfiles/Gemfile.rails-2.3
7
+ - gemfiles/Gemfile.rails-3.0
8
+ - gemfiles/Gemfile.rails-3.1
9
+ - gemfiles/Gemfile.rails-3.2
10
+ notifications:
11
+ recipients:
12
+ - michal.lomnicki@gmail.com
13
+ - ronen@barzel.org
data/README.rdoc CHANGED
@@ -1,5 +1,12 @@
1
1
  = SchemaValidations
2
2
 
3
+ SchemaValidations is an ActiveRecord extension that keeps your model class
4
+ definitions simpler and more DRY, by automatically defining validations
5
+ based on the database schema.
6
+
7
+ {<img src="https://secure.travis-ci.org/lomba/schema_validations.png"/>}[http://travis-ci.org/lomba/schema_validations]
8
+ {<img src="https://gemnasium.com/lomba/schema_validations.png" alt="Dependency Status" />}[https://gemnasium.com/lomba/schema_validations]
9
+
3
10
  == Overview
4
11
 
5
12
  One of the great things about Rails (ActiveRecord, in particular) is that it
@@ -96,8 +103,8 @@ you probably want -- but if you don't want them, you can disable them using
96
103
  == Compatibility
97
104
 
98
105
  SchemaValidations supports all combinations of:
99
- * rails 2.3, 3.0, or 3.1
100
- * MRI ruby 1.8.7 or 1.9.2
106
+ * rails 2.3, 3.0, 3.1, or 3.2
107
+ * MRI ruby 1.8.7, 1.9.2, or 1.9.3
101
108
 
102
109
  == How do I know what it did?
103
110
  If you're curious (or dubious) about what validations SchemaValidations defines, you can check the log file. For every assocation that SchemaValidations defines, it generates an info entry such as
@@ -106,16 +113,18 @@ If you're curious (or dubious) about what validations SchemaValidations defines,
106
113
 
107
114
  which shows the exact validation definition call.
108
115
 
109
- SchemaValidations defines the validations lazily, only creating them when a
110
- record of the class is first validated. So you may need to search through
111
- the log file for "schema_validations" to find them all (and some may not be
112
- defined at all if they were never needed for the logged use case).
113
-
114
- == I don't use constraints
115
- TODO and blame you
116
+ SchemaValidations defines the validations lazily for each class, only
117
+ creating them when they are needed (to validate a record of the class, or
118
+ in response to introspection on the class). So you may need to search
119
+ through the log file for "schema_validations" to find all the validations,
120
+ and some classes' validations may not be defined at all if they
121
+ were never needed for the logged use case.
116
122
 
117
123
  == History
118
124
 
125
+ * Recent Release notes:
126
+ * 0.2.0 - new feature: ActiveRecord#validators and ActiveRecord#validators_on now ensure schema_validations are loaded
127
+
119
128
  * SchemaValidations is derived from the "Red Hill On Rails" plugin schema_validations originally created by harukizaemon (https://github.com/harukizaemon)
120
129
 
121
130
  * SchemaValidations was created in 2011 by Michał Łomnicki and Ronen Barzel
@@ -132,11 +141,10 @@ full combo of tests, after you've forked & cloned:
132
141
 
133
142
  See <tt>./runspecs --help</tt> for other options. You can also pick a specific version of rails and ruby to use, such as:
134
143
  $ rvm use 1.9.2
135
- $ export SCHEMA_VALIDATIONS_RAILS_VERSION=3.1
136
- $ bundle update --local rails
144
+ $ export BUNDLE_GEMFILE=gemfiles/Gemfile.rails-3.1
137
145
  $ rake spec
138
146
 
139
- If you're running ruby 1.9.2, code coverage results will be in coverage/index.html -- it should be at 100% coverage.
147
+ If you're running ruby 1.9, code coverage results will be in coverage/index.html -- it should be at 100% coverage.
140
148
 
141
149
  == License
142
150
 
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ end
8
8
 
9
9
  task :default => :spec
10
10
 
11
- require 'rake/rdoctask'
11
+ require 'rdoc/task'
12
12
  Rake::RDocTask.new do |rdoc|
13
13
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
14
14
 
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path => File.expand_path('../..', __FILE__)
4
+ gem "rails", "~> 2.3"
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: /Users/ronen/github/schema_validations
3
+ specs:
4
+ schema_validations (0.1.2)
5
+ schema_plus
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (2.3.14)
11
+ actionpack (= 2.3.14)
12
+ actionpack (2.3.14)
13
+ activesupport (= 2.3.14)
14
+ rack (~> 1.1.0)
15
+ activerecord (2.3.14)
16
+ activesupport (= 2.3.14)
17
+ activeresource (2.3.14)
18
+ activesupport (= 2.3.14)
19
+ activesupport (2.3.14)
20
+ diff-lcs (1.1.3)
21
+ json (1.7.3)
22
+ multi_json (1.3.6)
23
+ rack (1.1.3)
24
+ rails (2.3.14)
25
+ actionmailer (= 2.3.14)
26
+ actionpack (= 2.3.14)
27
+ activerecord (= 2.3.14)
28
+ activeresource (= 2.3.14)
29
+ activesupport (= 2.3.14)
30
+ rake (>= 0.8.3)
31
+ rake (0.9.2.2)
32
+ rdoc (3.12)
33
+ json (~> 1.4)
34
+ rspec (2.10.0)
35
+ rspec-core (~> 2.10.0)
36
+ rspec-expectations (~> 2.10.0)
37
+ rspec-mocks (~> 2.10.0)
38
+ rspec-core (2.10.1)
39
+ rspec-expectations (2.10.0)
40
+ diff-lcs (~> 1.1.3)
41
+ rspec-mocks (2.10.1)
42
+ schema_plus (0.4.1)
43
+ rails
44
+ valuable
45
+ simplecov (0.6.4)
46
+ multi_json (~> 1.0)
47
+ simplecov-html (~> 0.5.3)
48
+ simplecov-gem-adapter (1.0.1)
49
+ simplecov
50
+ simplecov-html (0.5.3)
51
+ sqlite3 (1.3.6)
52
+ valuable (0.9.5)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ rails (~> 2.3)
59
+ rake
60
+ rdoc
61
+ rspec
62
+ schema_validations!
63
+ simplecov
64
+ simplecov-gem-adapter
65
+ sqlite3
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path => File.expand_path('../..', __FILE__)
4
+ gem "rails", "~> 3.0.0"
@@ -0,0 +1,110 @@
1
+ PATH
2
+ remote: /Users/ronen/github/schema_validations
3
+ specs:
4
+ schema_validations (0.1.2)
5
+ schema_plus
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.13)
12
+ actionpack (= 3.0.13)
13
+ mail (~> 2.2.19)
14
+ actionpack (3.0.13)
15
+ activemodel (= 3.0.13)
16
+ activesupport (= 3.0.13)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.5.0)
20
+ rack (~> 1.2.5)
21
+ rack-mount (~> 0.6.14)
22
+ rack-test (~> 0.5.7)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.13)
25
+ activesupport (= 3.0.13)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.5.0)
28
+ activerecord (3.0.13)
29
+ activemodel (= 3.0.13)
30
+ activesupport (= 3.0.13)
31
+ arel (~> 2.0.10)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.13)
34
+ activemodel (= 3.0.13)
35
+ activesupport (= 3.0.13)
36
+ activesupport (3.0.13)
37
+ arel (2.0.10)
38
+ builder (2.1.2)
39
+ diff-lcs (1.1.3)
40
+ erubis (2.6.6)
41
+ abstract (>= 1.0.0)
42
+ i18n (0.5.0)
43
+ json (1.7.3)
44
+ mail (2.2.19)
45
+ activesupport (>= 2.3.6)
46
+ i18n (>= 0.4.0)
47
+ mime-types (~> 1.16)
48
+ treetop (~> 1.4.8)
49
+ mime-types (1.18)
50
+ multi_json (1.3.6)
51
+ polyglot (0.3.3)
52
+ rack (1.2.5)
53
+ rack-mount (0.6.14)
54
+ rack (>= 1.0.0)
55
+ rack-test (0.5.7)
56
+ rack (>= 1.0)
57
+ rails (3.0.13)
58
+ actionmailer (= 3.0.13)
59
+ actionpack (= 3.0.13)
60
+ activerecord (= 3.0.13)
61
+ activeresource (= 3.0.13)
62
+ activesupport (= 3.0.13)
63
+ bundler (~> 1.0)
64
+ railties (= 3.0.13)
65
+ railties (3.0.13)
66
+ actionpack (= 3.0.13)
67
+ activesupport (= 3.0.13)
68
+ rake (>= 0.8.7)
69
+ rdoc (~> 3.4)
70
+ thor (~> 0.14.4)
71
+ rake (0.9.2.2)
72
+ rdoc (3.12)
73
+ json (~> 1.4)
74
+ rspec (2.10.0)
75
+ rspec-core (~> 2.10.0)
76
+ rspec-expectations (~> 2.10.0)
77
+ rspec-mocks (~> 2.10.0)
78
+ rspec-core (2.10.1)
79
+ rspec-expectations (2.10.0)
80
+ diff-lcs (~> 1.1.3)
81
+ rspec-mocks (2.10.1)
82
+ schema_plus (0.4.1)
83
+ rails
84
+ valuable
85
+ simplecov (0.6.4)
86
+ multi_json (~> 1.0)
87
+ simplecov-html (~> 0.5.3)
88
+ simplecov-gem-adapter (1.0.1)
89
+ simplecov
90
+ simplecov-html (0.5.3)
91
+ sqlite3 (1.3.6)
92
+ thor (0.14.6)
93
+ treetop (1.4.10)
94
+ polyglot
95
+ polyglot (>= 0.3.1)
96
+ tzinfo (0.3.33)
97
+ valuable (0.9.5)
98
+
99
+ PLATFORMS
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ rails (~> 3.0.0)
104
+ rake
105
+ rdoc
106
+ rspec
107
+ schema_validations!
108
+ simplecov
109
+ simplecov-gem-adapter
110
+ sqlite3
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path => File.expand_path('../..', __FILE__)
4
+ gem "rails", "~> 3.1.0"
@@ -0,0 +1,120 @@
1
+ PATH
2
+ remote: /Users/ronen/github/schema_validations
3
+ specs:
4
+ schema_validations (0.1.2)
5
+ schema_plus
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (3.1.5)
11
+ actionpack (= 3.1.5)
12
+ mail (~> 2.3.3)
13
+ actionpack (3.1.5)
14
+ activemodel (= 3.1.5)
15
+ activesupport (= 3.1.5)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ i18n (~> 0.6)
19
+ rack (~> 1.3.6)
20
+ rack-cache (~> 1.2)
21
+ rack-mount (~> 0.8.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.0.4)
24
+ activemodel (3.1.5)
25
+ activesupport (= 3.1.5)
26
+ builder (~> 3.0.0)
27
+ i18n (~> 0.6)
28
+ activerecord (3.1.5)
29
+ activemodel (= 3.1.5)
30
+ activesupport (= 3.1.5)
31
+ arel (~> 2.2.3)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.1.5)
34
+ activemodel (= 3.1.5)
35
+ activesupport (= 3.1.5)
36
+ activesupport (3.1.5)
37
+ multi_json (>= 1.0, < 1.3)
38
+ arel (2.2.3)
39
+ builder (3.0.0)
40
+ diff-lcs (1.1.3)
41
+ erubis (2.7.0)
42
+ hike (1.2.1)
43
+ i18n (0.6.0)
44
+ json (1.7.3)
45
+ mail (2.3.3)
46
+ i18n (>= 0.4.0)
47
+ mime-types (~> 1.16)
48
+ treetop (~> 1.4.8)
49
+ mime-types (1.18)
50
+ multi_json (1.2.0)
51
+ polyglot (0.3.3)
52
+ rack (1.3.6)
53
+ rack-cache (1.2)
54
+ rack (>= 0.4)
55
+ rack-mount (0.8.3)
56
+ rack (>= 1.0.0)
57
+ rack-ssl (1.3.2)
58
+ rack
59
+ rack-test (0.6.1)
60
+ rack (>= 1.0)
61
+ rails (3.1.5)
62
+ actionmailer (= 3.1.5)
63
+ actionpack (= 3.1.5)
64
+ activerecord (= 3.1.5)
65
+ activeresource (= 3.1.5)
66
+ activesupport (= 3.1.5)
67
+ bundler (~> 1.0)
68
+ railties (= 3.1.5)
69
+ railties (3.1.5)
70
+ actionpack (= 3.1.5)
71
+ activesupport (= 3.1.5)
72
+ rack-ssl (~> 1.3.2)
73
+ rake (>= 0.8.7)
74
+ rdoc (~> 3.4)
75
+ thor (~> 0.14.6)
76
+ rake (0.9.2.2)
77
+ rdoc (3.12)
78
+ json (~> 1.4)
79
+ rspec (2.10.0)
80
+ rspec-core (~> 2.10.0)
81
+ rspec-expectations (~> 2.10.0)
82
+ rspec-mocks (~> 2.10.0)
83
+ rspec-core (2.10.1)
84
+ rspec-expectations (2.10.0)
85
+ diff-lcs (~> 1.1.3)
86
+ rspec-mocks (2.10.1)
87
+ schema_plus (0.4.1)
88
+ rails
89
+ valuable
90
+ simplecov (0.6.4)
91
+ multi_json (~> 1.0)
92
+ simplecov-html (~> 0.5.3)
93
+ simplecov-gem-adapter (1.0.1)
94
+ simplecov
95
+ simplecov-html (0.5.3)
96
+ sprockets (2.0.4)
97
+ hike (~> 1.2)
98
+ rack (~> 1.0)
99
+ tilt (~> 1.1, != 1.3.0)
100
+ sqlite3 (1.3.6)
101
+ thor (0.14.6)
102
+ tilt (1.3.3)
103
+ treetop (1.4.10)
104
+ polyglot
105
+ polyglot (>= 0.3.1)
106
+ tzinfo (0.3.33)
107
+ valuable (0.9.5)
108
+
109
+ PLATFORMS
110
+ ruby
111
+
112
+ DEPENDENCIES
113
+ rails (~> 3.1.0)
114
+ rake
115
+ rdoc
116
+ rspec
117
+ schema_validations!
118
+ simplecov
119
+ simplecov-gem-adapter
120
+ sqlite3
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path => File.expand_path('../..', __FILE__)
4
+ gem "rails", "~> 3.2.0"
@@ -0,0 +1,118 @@
1
+ PATH
2
+ remote: /Users/ronen/github/schema_validations
3
+ specs:
4
+ schema_validations (0.1.2)
5
+ schema_plus
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.5)
11
+ actionpack (= 3.2.5)
12
+ mail (~> 2.4.4)
13
+ actionpack (3.2.5)
14
+ activemodel (= 3.2.5)
15
+ activesupport (= 3.2.5)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.1)
19
+ rack (~> 1.4.0)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.1.3)
23
+ activemodel (3.2.5)
24
+ activesupport (= 3.2.5)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.5)
27
+ activemodel (= 3.2.5)
28
+ activesupport (= 3.2.5)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.5)
32
+ activemodel (= 3.2.5)
33
+ activesupport (= 3.2.5)
34
+ activesupport (3.2.5)
35
+ i18n (~> 0.6)
36
+ multi_json (~> 1.0)
37
+ arel (3.0.2)
38
+ builder (3.0.0)
39
+ diff-lcs (1.1.3)
40
+ erubis (2.7.0)
41
+ hike (1.2.1)
42
+ i18n (0.6.0)
43
+ journey (1.0.3)
44
+ json (1.7.3)
45
+ mail (2.4.4)
46
+ i18n (>= 0.4.0)
47
+ mime-types (~> 1.16)
48
+ treetop (~> 1.4.8)
49
+ mime-types (1.18)
50
+ multi_json (1.3.6)
51
+ polyglot (0.3.3)
52
+ rack (1.4.1)
53
+ rack-cache (1.2)
54
+ rack (>= 0.4)
55
+ rack-ssl (1.3.2)
56
+ rack
57
+ rack-test (0.6.1)
58
+ rack (>= 1.0)
59
+ rails (3.2.5)
60
+ actionmailer (= 3.2.5)
61
+ actionpack (= 3.2.5)
62
+ activerecord (= 3.2.5)
63
+ activeresource (= 3.2.5)
64
+ activesupport (= 3.2.5)
65
+ bundler (~> 1.0)
66
+ railties (= 3.2.5)
67
+ railties (3.2.5)
68
+ actionpack (= 3.2.5)
69
+ activesupport (= 3.2.5)
70
+ rack-ssl (~> 1.3.2)
71
+ rake (>= 0.8.7)
72
+ rdoc (~> 3.4)
73
+ thor (>= 0.14.6, < 2.0)
74
+ rake (0.9.2.2)
75
+ rdoc (3.12)
76
+ json (~> 1.4)
77
+ rspec (2.10.0)
78
+ rspec-core (~> 2.10.0)
79
+ rspec-expectations (~> 2.10.0)
80
+ rspec-mocks (~> 2.10.0)
81
+ rspec-core (2.10.1)
82
+ rspec-expectations (2.10.0)
83
+ diff-lcs (~> 1.1.3)
84
+ rspec-mocks (2.10.1)
85
+ schema_plus (0.4.1)
86
+ rails
87
+ valuable
88
+ simplecov (0.6.4)
89
+ multi_json (~> 1.0)
90
+ simplecov-html (~> 0.5.3)
91
+ simplecov-gem-adapter (1.0.1)
92
+ simplecov
93
+ simplecov-html (0.5.3)
94
+ sprockets (2.1.3)
95
+ hike (~> 1.2)
96
+ rack (~> 1.0)
97
+ tilt (~> 1.1, != 1.3.0)
98
+ sqlite3 (1.3.6)
99
+ thor (0.15.2)
100
+ tilt (1.3.3)
101
+ treetop (1.4.10)
102
+ polyglot
103
+ polyglot (>= 0.3.1)
104
+ tzinfo (0.3.33)
105
+ valuable (0.9.5)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ rails (~> 3.2.0)
112
+ rake
113
+ rdoc
114
+ rspec
115
+ schema_validations!
116
+ simplecov
117
+ simplecov-gem-adapter
118
+ sqlite3
@@ -5,6 +5,10 @@ module SchemaValidations
5
5
  def self.extended(base) # :nodoc:
6
6
  base.delegate :load_schema_validations, :to => 'self.class'
7
7
  base.class_attribute :schema_validations_loaded
8
+ class << base
9
+ alias_method_chain :validators, :schema_validations
10
+ alias_method_chain :validators_on, :schema_validations
11
+ end if base.respond_to? :validators
8
12
  end
9
13
 
10
14
  def inherited(klass) # :nodoc:
@@ -12,6 +16,16 @@ module SchemaValidations
12
16
  before_validation :load_schema_validations unless schema_validations_loaded?
13
17
  end
14
18
 
19
+ def validators_with_schema_validations
20
+ load_schema_validations unless schema_validations_loaded?
21
+ validators_without_schema_validations
22
+ end
23
+
24
+ def validators_on_with_schema_validations(*args)
25
+ load_schema_validations unless schema_validations_loaded?
26
+ validators_on_without_schema_validations(*args)
27
+ end
28
+
15
29
  # Per-model override of Config options. Use via, e.g.
16
30
  # class MyModel < ActiveRecord::Base
17
31
  # schema_validations :auto_create => false
@@ -1,3 +1,3 @@
1
1
  module SchemaValidations
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/runspecs CHANGED
@@ -2,20 +2,26 @@
2
2
 
3
3
  require 'optparse'
4
4
  require 'ostruct'
5
+ require 'tempfile'
5
6
 
6
- PROJECT = File.basename(File.expand_path('..', __FILE__))
7
-
8
- RUBY_VERSIONS = %W[1.8.7 1.9.2]
9
- RAILS_VERSIONS = %W[2.3 3.0 3.1]
7
+ RUBY_VERSIONS = %W[1.8.7 1.9.2 1.9.3]
8
+ RAILS_VERSIONS = %W[2.3 3.0 3.1 3.2]
10
9
 
11
10
  o = OpenStruct.new
12
11
  o.ruby_versions = RUBY_VERSIONS
13
12
  o.rails_versions = RAILS_VERSIONS
14
- o.run_cmd = "rake spec"
15
13
 
16
14
  OptionParser.new do |opts|
17
15
  opts.banner = "Usage: #{$0} [options]"
18
16
 
17
+ opts.on("-n", "--dry-run", "Do a dry run without executing actions") do |v|
18
+ o.dry_run = true
19
+ end
20
+
21
+ opts.on("--update", "Update gem dependencies") do |v|
22
+ o.update = v
23
+ end
24
+
19
25
  opts.on("--install", "Install gem dependencies") do |v|
20
26
  o.install = v
21
27
  end
@@ -35,24 +41,43 @@ OptionParser.new do |opts|
35
41
 
36
42
  end.parse!
37
43
 
38
- cmds = if o.install
39
- ['bundle update']
40
- else
41
- ['bundle update --local rails | grep rails', o.run_cmd]
42
- end
43
44
 
44
- n = 1
45
+ Combo = Struct.new(:ruby, :rails)
46
+
47
+ combos = o.ruby_versions.product(o.rails_versions).map{|product| Combo.new(*product)}.select {|combo|
48
+ case
49
+ when combo.rails >= "3.2" && combo.ruby <= "1.8.7" then false
50
+ else true
51
+ end
52
+ }
53
+
54
+
55
+ GEMFILES_DIR = File.expand_path('../gemfiles', __FILE__)
45
56
  total = o.ruby_versions.size * o.rails_versions.size
46
- o.ruby_versions.each do |ruby|
47
- o.rails_versions.each do |rails|
48
- puts "\n\n*** ruby version #{ruby} - rails version #{rails} [#{n} of #{total}]\n\n"
49
- n += 1
50
- allcmds = []
51
- allcmds << "rvm use #{ruby}"
52
- allcmds << "export #{PROJECT.upcase}_RAILS_VERSION=#{rails}"
53
- allcmds += cmds
54
- allcmds << 'exit'
55
- system %Q{echo '#{allcmds.join(' \n ')}' | bash -i} or abort "aborting #{$0}"
57
+ errs = []
58
+ combos.each_with_index do |combo, n|
59
+ ruby = combo.ruby
60
+ rails = combo.rails
61
+
62
+ cmd = case
63
+ when o.update
64
+ "bundle update"
65
+ when o.install
66
+ "bundle install"
67
+ else
68
+ "bundle exec rake spec"
69
+ end
70
+
71
+ command = %Q{BUNDLE_GEMFILE="#{File.join(GEMFILES_DIR, "Gemfile.rails-#{rails}")}" rvm #{ruby} do #{cmd}}
72
+
73
+ puts "\n\n*** ruby version #{ruby} - rails version #{rails} [#{n+1} of #{combos.size}]\n\n#{command}"
74
+
75
+ next if o.dry_run
76
+
77
+ Tempfile.open('runspecs') do |file|
78
+ system("(#{command}) 2>&1 | tee #{file.path}")
79
+ file.rewind
80
+ errs << "ruby #{ruby}, rails #{rails}" if file.readlines.grep(/^Failed examples/).any?
56
81
  end
57
82
  end
58
-
83
+ puts errs.any? ? "\n*** #{errs.size} failures:\n\t#{errs.join("\n\t")}" : "\n*** #{combos.size > 1 ? 'all versions' : 'spec'} succeeded ***" unless o.dry_run
@@ -21,20 +21,11 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_dependency("schema_plus")
23
23
 
24
- case ENV['SCHEMA_VALIDATIONS_RAILS_VERSION']
25
- when '2.3'
26
- s.add_development_dependency("rails", "~> 2.3")
27
- when '3.0'
28
- s.add_development_dependency("rails", "~> 3.0")
29
- when '3.1'
30
- s.add_development_dependency("rails", ">= 3.1.0.rc4")
31
- end
32
-
33
- s.add_development_dependency("rake", "~> 0.8.7")
24
+ s.add_development_dependency("rake")
25
+ s.add_development_dependency("rdoc")
34
26
  s.add_development_dependency("rspec")
35
27
  s.add_development_dependency("sqlite3")
36
28
  s.add_development_dependency("simplecov")
37
29
  s.add_development_dependency("simplecov-gem-adapter")
38
- s.add_development_dependency("ruby-debug19") if RUBY_VERSION >= "1.9.2"
39
30
  end
40
31
 
@@ -23,6 +23,14 @@ describe "Validations" do
23
23
  end
24
24
  end
25
25
 
26
+ # only expect this to work in Rails >= 3, which conveniently is when
27
+ # :validators was defined
28
+ if ActiveRecord::Base.respond_to? :validators
29
+ it "should define validators before attempting validation" do
30
+ Article.validators_on(:content).should_not be_blank
31
+ end
32
+ end
33
+
26
34
  it "should be valid with valid attributes" do
27
35
  Article.new(valid_attributes).should be_valid
28
36
  end
metadata CHANGED
@@ -1,112 +1,154 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: schema_validations
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
4
5
  prerelease:
5
- version: 0.1.2
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Ronen Barzel
9
- - "Micha\xC5\x82 \xC5\x81omnicki"
9
+ - Michał Łomnicki
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
-
14
- date: 2011-08-02 00:00:00 -07:00
15
- default_executable:
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
13
+ date: 2012-10-20 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
18
16
  name: schema_plus
19
- prerelease: false
20
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
21
18
  none: false
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
26
23
  type: :runtime
27
- version_requirements: *id001
28
- - !ruby/object:Gem::Dependency
29
- name: rake
30
24
  prerelease: false
31
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: !ruby/object:Gem::Requirement
32
26
  none: false
33
- requirements:
34
- - - ~>
35
- - !ruby/object:Gem::Version
36
- version: 0.8.7
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rake
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
37
39
  type: :development
38
- version_requirements: *id002
39
- - !ruby/object:Gem::Dependency
40
- name: rspec
41
40
  prerelease: false
42
- requirement: &id003 !ruby/object:Gem::Requirement
41
+ version_requirements: !ruby/object:Gem::Requirement
43
42
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: "0"
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rdoc
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
48
55
  type: :development
49
- version_requirements: *id003
50
- - !ruby/object:Gem::Dependency
51
- name: sqlite3
52
56
  prerelease: false
53
- requirement: &id004 !ruby/object:Gem::Requirement
57
+ version_requirements: !ruby/object:Gem::Requirement
54
58
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: "0"
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: rspec
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
59
71
  type: :development
60
- version_requirements: *id004
61
- - !ruby/object:Gem::Dependency
62
- name: simplecov
63
72
  prerelease: false
64
- requirement: &id005 !ruby/object:Gem::Requirement
73
+ version_requirements: !ruby/object:Gem::Requirement
65
74
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: "0"
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: sqlite3
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
70
87
  type: :development
71
- version_requirements: *id005
72
- - !ruby/object:Gem::Dependency
73
- name: simplecov-gem-adapter
74
88
  prerelease: false
75
- requirement: &id006 !ruby/object:Gem::Requirement
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: simplecov
97
+ requirement: !ruby/object:Gem::Requirement
76
98
  none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: "0"
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
81
103
  type: :development
82
- version_requirements: *id006
83
- - !ruby/object:Gem::Dependency
84
- name: ruby-debug19
85
104
  prerelease: false
86
- requirement: &id007 !ruby/object:Gem::Requirement
105
+ version_requirements: !ruby/object:Gem::Requirement
87
106
  none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: "0"
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov-gem-adapter
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
92
119
  type: :development
93
- version_requirements: *id007
94
- description: SchemaValidations extends ActiveRecord to automatically create validations by inspecting the database schema. This makes your models more DRY as you no longer need to duplicate NOT NULL, unique, numeric and varchar constraints on the model level.
95
- email:
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ description: SchemaValidations extends ActiveRecord to automatically create validations
128
+ by inspecting the database schema. This makes your models more DRY as you no longer
129
+ need to duplicate NOT NULL, unique, numeric and varchar constraints on the model
130
+ level.
131
+ email:
96
132
  - ronen@barzel.org
97
133
  - michal.lomnicki@gmail.com
98
134
  executables: []
99
-
100
135
  extensions: []
101
-
102
136
  extra_rdoc_files: []
103
-
104
- files:
137
+ files:
105
138
  - .gitignore
139
+ - .travis.yml
106
140
  - Gemfile
107
141
  - MIT-LICENSE
108
142
  - README.rdoc
109
143
  - Rakefile
144
+ - gemfiles/Gemfile.rails-2.3
145
+ - gemfiles/Gemfile.rails-2.3.lock
146
+ - gemfiles/Gemfile.rails-3.0
147
+ - gemfiles/Gemfile.rails-3.0.lock
148
+ - gemfiles/Gemfile.rails-3.1
149
+ - gemfiles/Gemfile.rails-3.1.lock
150
+ - gemfiles/Gemfile.rails-3.2
151
+ - gemfiles/Gemfile.rails-3.2.lock
110
152
  - init.rb
111
153
  - lib/schema_validations.rb
112
154
  - lib/schema_validations/active_record/validations.rb
@@ -118,35 +160,37 @@ files:
118
160
  - spec/spec_helper.rb
119
161
  - spec/support/active_model.rb
120
162
  - spec/validations_spec.rb
121
- has_rdoc: true
122
163
  homepage: https://github.com/lomba/schema_validations
123
164
  licenses: []
124
-
125
165
  post_install_message:
126
166
  rdoc_options: []
127
-
128
- require_paths:
167
+ require_paths:
129
168
  - lib
130
- required_ruby_version: !ruby/object:Gem::Requirement
169
+ required_ruby_version: !ruby/object:Gem::Requirement
131
170
  none: false
132
- requirements:
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- version: "0"
136
- required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ segments:
176
+ - 0
177
+ hash: 4384088821395640106
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
179
  none: false
138
- requirements:
139
- - - ">="
140
- - !ruby/object:Gem::Version
141
- version: "0"
180
+ requirements:
181
+ - - ! '>='
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ segments:
185
+ - 0
186
+ hash: 4384088821395640106
142
187
  requirements: []
143
-
144
188
  rubyforge_project: schema_validations
145
- rubygems_version: 1.6.2
189
+ rubygems_version: 1.8.24
146
190
  signing_key:
147
191
  specification_version: 3
148
192
  summary: Automatically creates validations basing on the database schema.
149
- test_files:
193
+ test_files:
150
194
  - spec/connection.rb
151
195
  - spec/spec_helper.rb
152
196
  - spec/support/active_model.rb