judge 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -4
- data/Gemfile.lock +46 -42
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/judge.gemspec +17 -16
- data/lib/generators/judge/templates/judge.js +64 -51
- data/lib/judge.rb +0 -4
- data/lib/judge/form.rb +8 -20
- data/lib/judge/utils.rb +72 -8
- data/spec/javascripts/JudgeSpec.js +66 -122
- data/spec/javascripts/fixtures/form.html +537 -58
- data/test/dummy/Gemfile +3 -0
- data/test/dummy/Gemfile.lock +75 -0
- data/test/dummy/app/views/foos/new.html.erb +1 -1
- data/test/dummy/config/locales/en.yml +7 -0
- data/test/judge_test.rb +37 -15
- metadata +71 -112
data/test/dummy/Gemfile
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
GEM
|
2
|
+
specs:
|
3
|
+
abstract (1.0.0)
|
4
|
+
actionmailer (3.0.3)
|
5
|
+
actionpack (= 3.0.3)
|
6
|
+
mail (~> 2.2.9)
|
7
|
+
actionpack (3.0.3)
|
8
|
+
activemodel (= 3.0.3)
|
9
|
+
activesupport (= 3.0.3)
|
10
|
+
builder (~> 2.1.2)
|
11
|
+
erubis (~> 2.6.6)
|
12
|
+
i18n (~> 0.4)
|
13
|
+
rack (~> 1.2.1)
|
14
|
+
rack-mount (~> 0.6.13)
|
15
|
+
rack-test (~> 0.5.6)
|
16
|
+
tzinfo (~> 0.3.23)
|
17
|
+
activemodel (3.0.3)
|
18
|
+
activesupport (= 3.0.3)
|
19
|
+
builder (~> 2.1.2)
|
20
|
+
i18n (~> 0.4)
|
21
|
+
activerecord (3.0.3)
|
22
|
+
activemodel (= 3.0.3)
|
23
|
+
activesupport (= 3.0.3)
|
24
|
+
arel (~> 2.0.2)
|
25
|
+
tzinfo (~> 0.3.23)
|
26
|
+
activeresource (3.0.3)
|
27
|
+
activemodel (= 3.0.3)
|
28
|
+
activesupport (= 3.0.3)
|
29
|
+
activesupport (3.0.3)
|
30
|
+
arel (2.0.10)
|
31
|
+
builder (2.1.2)
|
32
|
+
erubis (2.6.6)
|
33
|
+
abstract (>= 1.0.0)
|
34
|
+
i18n (0.5.0)
|
35
|
+
judge (0.4.3)
|
36
|
+
mail (2.2.15)
|
37
|
+
activesupport (>= 2.3.6)
|
38
|
+
i18n (>= 0.4.0)
|
39
|
+
mime-types (~> 1.16)
|
40
|
+
treetop (~> 1.4.8)
|
41
|
+
mime-types (1.16)
|
42
|
+
polyglot (0.3.2)
|
43
|
+
rack (1.2.4)
|
44
|
+
rack-mount (0.6.14)
|
45
|
+
rack (>= 1.0.0)
|
46
|
+
rack-test (0.5.7)
|
47
|
+
rack (>= 1.0)
|
48
|
+
rails (3.0.3)
|
49
|
+
actionmailer (= 3.0.3)
|
50
|
+
actionpack (= 3.0.3)
|
51
|
+
activerecord (= 3.0.3)
|
52
|
+
activeresource (= 3.0.3)
|
53
|
+
activesupport (= 3.0.3)
|
54
|
+
bundler (~> 1.0)
|
55
|
+
railties (= 3.0.3)
|
56
|
+
railties (3.0.3)
|
57
|
+
actionpack (= 3.0.3)
|
58
|
+
activesupport (= 3.0.3)
|
59
|
+
rake (>= 0.8.7)
|
60
|
+
thor (~> 0.14.4)
|
61
|
+
rake (0.9.2)
|
62
|
+
sqlite3-ruby (1.3.2)
|
63
|
+
thor (0.14.6)
|
64
|
+
treetop (1.4.10)
|
65
|
+
polyglot
|
66
|
+
polyglot (>= 0.3.1)
|
67
|
+
tzinfo (0.3.30)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
judge
|
74
|
+
rails (~> 3.0.3)
|
75
|
+
sqlite3-ruby (~> 1.3.2)
|
data/test/judge_test.rb
CHANGED
@@ -3,17 +3,7 @@ require 'test_helper'
|
|
3
3
|
class JudgeTest < ActionController::TestCase
|
4
4
|
tests FoosController
|
5
5
|
|
6
|
-
context "
|
7
|
-
|
8
|
-
should "include validation messages in data attribute" do
|
9
|
-
get :new
|
10
|
-
assert_equal Hash, error_messages.class
|
11
|
-
assert error_messages.include? "inclusion"
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
context "validators" do
|
6
|
+
context "JSONified validators" do
|
17
7
|
|
18
8
|
setup { get :new }
|
19
9
|
|
@@ -27,6 +17,7 @@ class JudgeTest < ActionController::TestCase
|
|
27
17
|
assert_equal "length", validators.first["kind"]
|
28
18
|
assert_equal Fixnum, validators.first["options"]["minimum"].class
|
29
19
|
assert_equal Fixnum, validators.first["options"]["maximum"].class
|
20
|
+
|
30
21
|
assert validators.first["options"]["allow_blank"]
|
31
22
|
end
|
32
23
|
|
@@ -77,10 +68,10 @@ class JudgeTest < ActionController::TestCase
|
|
77
68
|
|
78
69
|
end
|
79
70
|
|
80
|
-
context "
|
71
|
+
context "form builder" do
|
81
72
|
setup do
|
82
73
|
get :new
|
83
|
-
@form = Nokogiri::HTML(css_select("form
|
74
|
+
@form = Nokogiri::HTML(css_select("form").first.to_s)
|
84
75
|
end
|
85
76
|
|
86
77
|
should "do validated_select" do
|
@@ -145,14 +136,45 @@ class JudgeTest < ActionController::TestCase
|
|
145
136
|
|
146
137
|
end
|
147
138
|
|
139
|
+
context "data attribute messages option" do
|
140
|
+
|
141
|
+
setup do
|
142
|
+
get :new
|
143
|
+
@exclusion_validator = validators_from("select#foo_three").first
|
144
|
+
end
|
145
|
+
|
146
|
+
should "be present" do
|
147
|
+
assert_equal Hash, @exclusion_validator["messages"].class
|
148
|
+
end
|
149
|
+
|
150
|
+
should "include base message" do
|
151
|
+
assert @exclusion_validator["messages"]["exclusion"], "base message not found"
|
152
|
+
end
|
153
|
+
|
154
|
+
should "lookup i18n error message" do
|
155
|
+
assert_equal "activerecord errors messages blank", @exclusion_validator["messages"]["blank"]
|
156
|
+
end
|
157
|
+
|
158
|
+
should "not include blank message if allow_blank is true" do
|
159
|
+
length_validator = validators_from("input#foo_two_foobar").first
|
160
|
+
assert_equal nil, length_validator["messages"]["blank"]
|
161
|
+
end
|
162
|
+
|
163
|
+
should "include not_an_integer message if only_integer is true" do
|
164
|
+
numericality_validator = validators_from("textarea#foo_four").first
|
165
|
+
assert numericality_validator["messages"]["not_an_integer"], "not_an_integer message not found"
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
148
170
|
def validators_from(selector)
|
149
|
-
form = Nokogiri::HTML(css_select("form
|
171
|
+
form = Nokogiri::HTML(css_select("form").first.to_s)
|
150
172
|
data_attribute = form.css(selector).first["data-validate"]
|
151
173
|
JSON.parse(data_attribute)
|
152
174
|
end
|
153
175
|
|
154
176
|
def error_messages
|
155
|
-
form = Nokogiri::HTML(css_select("form
|
177
|
+
form = Nokogiri::HTML(css_select("form").first.to_s)
|
156
178
|
data_attribute = form.css("form").first["data-error-messages"]
|
157
179
|
JSON.parse(data_attribute)
|
158
180
|
end
|
metadata
CHANGED
@@ -1,152 +1,113 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: judge
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 4
|
8
|
-
- 3
|
9
|
-
version: 0.4.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Joe Corcoran
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2011-08-16 00:00:00 +01:00
|
12
|
+
date: 2011-11-13 00:00:00.000000000 +00:00
|
18
13
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
21
16
|
name: bundler
|
22
|
-
requirement: &
|
17
|
+
requirement: &2168570340 !ruby/object:Gem::Requirement
|
23
18
|
none: false
|
24
|
-
requirements:
|
19
|
+
requirements:
|
25
20
|
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 1
|
29
|
-
- 0
|
30
|
-
- 0
|
31
|
-
version: 1.0.0
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.18
|
32
23
|
type: :development
|
33
24
|
prerelease: false
|
34
|
-
version_requirements: *
|
35
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: *2168570340
|
26
|
+
- !ruby/object:Gem::Dependency
|
36
27
|
name: jeweler
|
37
|
-
requirement: &
|
28
|
+
requirement: &2168569740 !ruby/object:Gem::Requirement
|
38
29
|
none: false
|
39
|
-
requirements:
|
30
|
+
requirements:
|
40
31
|
- - ~>
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
segments:
|
43
|
-
- 1
|
44
|
-
- 5
|
45
|
-
- 2
|
32
|
+
- !ruby/object:Gem::Version
|
46
33
|
version: 1.5.2
|
47
34
|
type: :development
|
48
35
|
prerelease: false
|
49
|
-
version_requirements: *
|
50
|
-
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: *2168569740
|
37
|
+
- !ruby/object:Gem::Dependency
|
51
38
|
name: jasmine
|
52
|
-
requirement: &
|
39
|
+
requirement: &2168569100 !ruby/object:Gem::Requirement
|
53
40
|
none: false
|
54
|
-
requirements:
|
41
|
+
requirements:
|
55
42
|
- - ~>
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
segments:
|
58
|
-
- 1
|
59
|
-
- 0
|
60
|
-
- 2
|
43
|
+
- !ruby/object:Gem::Version
|
61
44
|
version: 1.0.2
|
62
45
|
type: :development
|
63
46
|
prerelease: false
|
64
|
-
version_requirements: *
|
65
|
-
- !ruby/object:Gem::Dependency
|
47
|
+
version_requirements: *2168569100
|
48
|
+
- !ruby/object:Gem::Dependency
|
66
49
|
name: rails
|
67
|
-
requirement: &
|
50
|
+
requirement: &2168568460 !ruby/object:Gem::Requirement
|
68
51
|
none: false
|
69
|
-
requirements:
|
52
|
+
requirements:
|
70
53
|
- - ~>
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
- 3
|
74
|
-
- 0
|
75
|
-
- 3
|
76
|
-
version: 3.0.3
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 3.0.10
|
77
56
|
type: :development
|
78
57
|
prerelease: false
|
79
|
-
version_requirements: *
|
80
|
-
- !ruby/object:Gem::Dependency
|
58
|
+
version_requirements: *2168568460
|
59
|
+
- !ruby/object:Gem::Dependency
|
81
60
|
name: shoulda
|
82
|
-
requirement: &
|
61
|
+
requirement: &2168567820 !ruby/object:Gem::Requirement
|
83
62
|
none: false
|
84
|
-
requirements:
|
63
|
+
requirements:
|
85
64
|
- - ~>
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
segments:
|
88
|
-
- 2
|
89
|
-
- 11
|
90
|
-
- 3
|
65
|
+
- !ruby/object:Gem::Version
|
91
66
|
version: 2.11.3
|
92
67
|
type: :development
|
93
68
|
prerelease: false
|
94
|
-
version_requirements: *
|
95
|
-
- !ruby/object:Gem::Dependency
|
69
|
+
version_requirements: *2168567820
|
70
|
+
- !ruby/object:Gem::Dependency
|
96
71
|
name: sqlite3-ruby
|
97
|
-
requirement: &
|
72
|
+
requirement: &2168531380 !ruby/object:Gem::Requirement
|
98
73
|
none: false
|
99
|
-
requirements:
|
74
|
+
requirements:
|
100
75
|
- - ~>
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
segments:
|
103
|
-
- 1
|
104
|
-
- 3
|
105
|
-
- 2
|
76
|
+
- !ruby/object:Gem::Version
|
106
77
|
version: 1.3.2
|
107
78
|
type: :development
|
108
79
|
prerelease: false
|
109
|
-
version_requirements: *
|
110
|
-
- !ruby/object:Gem::Dependency
|
80
|
+
version_requirements: *2168531380
|
81
|
+
- !ruby/object:Gem::Dependency
|
111
82
|
name: nokogiri
|
112
|
-
requirement: &
|
83
|
+
requirement: &2168530420 !ruby/object:Gem::Requirement
|
113
84
|
none: false
|
114
|
-
requirements:
|
85
|
+
requirements:
|
115
86
|
- - ~>
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
|
118
|
-
- 1
|
119
|
-
- 4
|
120
|
-
- 4
|
121
|
-
version: 1.4.4
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.4.7
|
122
89
|
type: :development
|
123
90
|
prerelease: false
|
124
|
-
version_requirements: *
|
125
|
-
- !ruby/object:Gem::Dependency
|
91
|
+
version_requirements: *2168530420
|
92
|
+
- !ruby/object:Gem::Dependency
|
126
93
|
name: json
|
127
|
-
requirement: &
|
94
|
+
requirement: &2168529340 !ruby/object:Gem::Requirement
|
128
95
|
none: false
|
129
|
-
requirements:
|
96
|
+
requirements:
|
130
97
|
- - ~>
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
133
|
-
- 1
|
134
|
-
- 4
|
135
|
-
- 6
|
136
|
-
version: 1.4.6
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 1.6.0
|
137
100
|
type: :development
|
138
101
|
prerelease: false
|
139
|
-
version_requirements: *
|
102
|
+
version_requirements: *2168529340
|
140
103
|
description: Validate forms in-place using your model validations
|
141
104
|
email: joe@tribesports.com
|
142
105
|
executables: []
|
143
|
-
|
144
106
|
extensions: []
|
145
|
-
|
146
|
-
extra_rdoc_files:
|
107
|
+
extra_rdoc_files:
|
147
108
|
- LICENSE.txt
|
148
109
|
- README.md
|
149
|
-
files:
|
110
|
+
files:
|
150
111
|
- .document
|
151
112
|
- .travis.yml
|
152
113
|
- Gemfile
|
@@ -177,6 +138,8 @@ files:
|
|
177
138
|
- spec/javascripts/support/jasmine_config.rb
|
178
139
|
- spec/javascripts/support/jasmine_runner.rb
|
179
140
|
- spec/javascripts/support/phantomRunner.js
|
141
|
+
- test/dummy/Gemfile
|
142
|
+
- test/dummy/Gemfile.lock
|
180
143
|
- test/dummy/Rakefile
|
181
144
|
- test/dummy/app/controllers/application_controller.rb
|
182
145
|
- test/dummy/app/controllers/foos_controller.rb
|
@@ -227,38 +190,34 @@ files:
|
|
227
190
|
- test/test_helper.rb
|
228
191
|
has_rdoc: true
|
229
192
|
homepage: http://github.com/joecorcoran/judge
|
230
|
-
licenses:
|
193
|
+
licenses:
|
231
194
|
- MIT
|
232
195
|
post_install_message:
|
233
196
|
rdoc_options: []
|
234
|
-
|
235
|
-
require_paths:
|
197
|
+
require_paths:
|
236
198
|
- lib
|
237
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
238
200
|
none: false
|
239
|
-
requirements:
|
240
|
-
- -
|
241
|
-
- !ruby/object:Gem::Version
|
242
|
-
|
243
|
-
segments:
|
201
|
+
requirements:
|
202
|
+
- - ! '>='
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
segments:
|
244
206
|
- 0
|
245
|
-
|
246
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
|
+
hash: 780299096256091398
|
208
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
247
209
|
none: false
|
248
|
-
requirements:
|
249
|
-
- -
|
250
|
-
- !ruby/object:Gem::Version
|
251
|
-
|
252
|
-
- 0
|
253
|
-
version: "0"
|
210
|
+
requirements:
|
211
|
+
- - ! '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
254
214
|
requirements: []
|
255
|
-
|
256
215
|
rubyforge_project:
|
257
|
-
rubygems_version: 1.
|
216
|
+
rubygems_version: 1.6.2
|
258
217
|
signing_key:
|
259
218
|
specification_version: 3
|
260
219
|
summary: Simple client-side ActiveModel::Validators
|
261
|
-
test_files:
|
220
|
+
test_files:
|
262
221
|
- spec/javascripts/support/jasmine_config.rb
|
263
222
|
- spec/javascripts/support/jasmine_runner.rb
|
264
223
|
- test/dummy/app/controllers/application_controller.rb
|