modelizer 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/lib/modelizer.rb +21 -4
- metadata +6 -26
data/CHANGELOG.rdoc
CHANGED
data/lib/modelizer.rb
CHANGED
@@ -4,10 +4,22 @@ require "modelizer/validations"
|
|
4
4
|
module Modelizer
|
5
5
|
|
6
6
|
# Duh.
|
7
|
-
VERSION = "2.
|
7
|
+
VERSION = "2.1.0"
|
8
8
|
|
9
9
|
include Modelizer::Assertions
|
10
10
|
|
11
|
+
# Test classes that should be considered abstract when rendering
|
12
|
+
# tests for a model template.
|
13
|
+
|
14
|
+
TEST_CLASSES = []
|
15
|
+
|
16
|
+
%w(Test::Unit::TestCase Minitest::Unit::TestCase
|
17
|
+
ActiveSupport::TestCase).each do |k|
|
18
|
+
|
19
|
+
TEST_CLASSES <<
|
20
|
+
k.split("::").inject(Object) { |a, b| a.const_get b } rescue nil
|
21
|
+
end
|
22
|
+
|
11
23
|
@@cache = {}
|
12
24
|
def self.cache; @@cache end
|
13
25
|
|
@@ -16,6 +28,10 @@ module Modelizer
|
|
16
28
|
target.extend Modelizer::Validations
|
17
29
|
end
|
18
30
|
|
31
|
+
@@namespace = true
|
32
|
+
def self.namespace?; @@namespace end
|
33
|
+
def self.namespace= ns; @@namespace = ns end
|
34
|
+
|
19
35
|
def self.underscore classname
|
20
36
|
classname.gsub(/::/, '_').
|
21
37
|
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
@@ -49,8 +65,9 @@ module Modelizer
|
|
49
65
|
|
50
66
|
::Modelizer.cache[klass] = [defaults, block]
|
51
67
|
|
52
|
-
klass
|
53
|
-
|
68
|
+
klass = klass.name
|
69
|
+
nsklass = Modelizer.namespace? ? klass : klass.split("::").last
|
70
|
+
model = ::Modelizer.underscore nsklass
|
54
71
|
|
55
72
|
module_eval <<-END, __FILE__, __LINE__ + 1
|
56
73
|
def valid_#{model}_attributes extras = {}
|
@@ -104,7 +121,7 @@ module Modelizer
|
|
104
121
|
end
|
105
122
|
END
|
106
123
|
|
107
|
-
if
|
124
|
+
if TEST_CLASSES.include? self
|
108
125
|
eval <<-END, nil, file, line - 2
|
109
126
|
class ::ModelTemplateFor#{klass}Test < ActiveSupport::TestCase
|
110
127
|
#{test}
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modelizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 15
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 2
|
7
|
+
- 1
|
8
8
|
- 0
|
9
|
-
|
10
|
-
version: 2.0.0
|
9
|
+
version: 2.1.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- John Barnette
|
@@ -15,41 +14,24 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-12-18 00:00:00 -08:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
21
|
+
name: hoe
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 7
|
30
28
|
segments:
|
31
29
|
- 2
|
30
|
+
- 8
|
32
31
|
- 0
|
33
|
-
|
34
|
-
version: 2.0.4
|
32
|
+
version: 2.8.0
|
35
33
|
type: :development
|
36
34
|
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: hoe
|
39
|
-
prerelease: false
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ">="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 21
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
- 6
|
49
|
-
- 1
|
50
|
-
version: 2.6.1
|
51
|
-
type: :development
|
52
|
-
version_requirements: *id002
|
53
35
|
description: |-
|
54
36
|
Need a simple, consistent way to create model instances and check
|
55
37
|
validations in your Rails tests? Use the Modelizer.
|
@@ -89,7 +71,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
71
|
requirements:
|
90
72
|
- - ">="
|
91
73
|
- !ruby/object:Gem::Version
|
92
|
-
hash: 3
|
93
74
|
segments:
|
94
75
|
- 0
|
95
76
|
version: "0"
|
@@ -98,7 +79,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
79
|
requirements:
|
99
80
|
- - ">="
|
100
81
|
- !ruby/object:Gem::Version
|
101
|
-
hash: 3
|
102
82
|
segments:
|
103
83
|
- 0
|
104
84
|
version: "0"
|