validatious-on-rails 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -7,12 +7,12 @@ require 'rake/rdoctask'
7
7
  NAME = "validatious-on-rails"
8
8
  SUMMARY = %Q{Rails plugin that maps model validations to class names on form elements to integrate with Validatious.}
9
9
  HOMEPAGE = "http://github.com/grimen/#{NAME}"
10
- AUTHORS = ["Christian Johansen", "Jonas Grimfelt"]
11
- EMAIL = "christian@cjohansen.no"
10
+ AUTHORS = ["Jonas Grimfelt", "Christian Johansen"]
11
+ EMAIL = "grimen@gmail.com"
12
12
  SUPPORT_FILES = %w(README)
13
13
 
14
14
  begin
15
- gem 'technicalpickles-jeweler', '>= 1.2.1'
15
+ gem 'jeweler', '>= 1.2.1'
16
16
  require 'jeweler'
17
17
  Jeweler::Tasks.new do |gemspec|
18
18
  gemspec.name = NAME
@@ -1,6 +1,12 @@
1
1
  module ValidatiousOnRails
2
2
  module Helpers
3
3
 
4
+ def self.included(base)
5
+ base.class_eval do
6
+ extend ClassMethods
7
+ end
8
+ end
9
+
4
10
  def attach_validator_for(object_name, method, options = {})
5
11
  options = ::ValidatiousOnRails::ModelValidations.options_for(object_name, method, options, @content_for_validatious)
6
12
  custom_js = options.delete(:js)
@@ -30,6 +36,19 @@ module ValidatiousOnRails
30
36
  return args, tail
31
37
  end
32
38
 
39
+ module ClassMethods
40
+
41
+ def define_with_validatious_support(field_type)
42
+ define_method :"#{field_type}_with_validation" do |*args|
43
+ args, tail = ::ValidatiousOnRails::Helpers.extract_args!(*args)
44
+ options = self.attach_validator_for(args.first, args.second, args.extract_options!)
45
+ self.send :"#{field_type}_without_validation", *((args << options) + tail)
46
+ end
47
+ alias_method_chain field_type, :validation
48
+ end
49
+
50
+ end
51
+
33
52
  end
34
53
  end
35
54
 
@@ -16,55 +16,40 @@ module ActionView # :nodoc:
16
16
  # so the hooking of these helpers don't have to be very explicit.
17
17
  #
18
18
  FIELD_TYPES.each do |field_type|
19
- define_method :"#{field_type}_with_validation" do |*args|
20
- args, tail = ::ValidatiousOnRails::Helpers.extract_args!(*args)
21
- options = self.attach_validator_for(args.first, args.second, args.extract_options!)
22
- self.send :"#{field_type}_without_validation", *((args << options) + tail)
23
- end
24
- alias_method_chain field_type, :validation
19
+ define_with_validatious_support(field_type)
25
20
  end
26
21
 
27
22
  # Adds the title attribute to label tags when there is no title
28
23
  # set, and the label text is provided. The title is set to object_name.humanize
29
24
  #
30
25
  def label_with_title(object_name, method, text = nil, options = {})
31
- options[:title] ||= method.to_s.humanize unless text.nil?
26
+ options[:title] ||= object_name.to_s.classify.constantize.human_attribute_name(method.to_s) unless text.nil?
32
27
  label_without_title(object_name, method, text, options)
33
28
  end
34
29
  alias_method_chain :label, :title
35
30
 
36
31
  end
37
32
 
38
- module FormOptionsHelper
33
+ module FormOptionsHelper # :nodoc:
39
34
 
40
35
  include ::ValidatiousOnRails::Helpers
41
36
 
42
- FIELD_TYPES = [:time_zone_select, :select, :collection_select, :grouped_options_for_select].freeze
37
+ FIELD_TYPES = [:time_zone_select, :select, :collection_select, :grouped_collection_select].freeze
43
38
 
44
39
  FIELD_TYPES.each do |field_type|
45
- define_method :"#{field_type}_with_validation" do |*args|
46
- args, tail = ::ValidatiousOnRails::Helpers.extract_args!(*args)
47
- options = self.attach_validator_for(args.first, args.second, args.extract_options!)
48
- self.send :"#{field_type}_without_validation", *((args << options) + tail)
49
- end
50
- alias_method_chain field_type, :validation
40
+ define_with_validatious_support(field_type)
51
41
  end
52
42
 
53
43
  end
54
44
 
55
- module DateHelper
45
+ module DateHelper # :nodoc:
56
46
 
57
47
  include ::ValidatiousOnRails::Helpers
58
48
 
59
49
  FIELD_TYPES = [:date_select, :datetime_select, :time_select].freeze
60
50
 
61
51
  FIELD_TYPES.each do |field_type|
62
- define_method :"#{field_type}_with_validation" do |*args|
63
- args, tail = ::ValidatiousOnRails::Helpers.extract_args!(*args)
64
- options = self.attach_validator_for(args.first, args.second, args.extract_options!)
65
- self.send :"#{field_type}_without_validation", *((args << options) + tail)
66
- end
67
- alias_method_chain field_type, :validation
52
+ define_with_validatious_support(field_type)
68
53
  end
69
54
 
70
55
  end
data/test/test_helper.rb CHANGED
@@ -52,6 +52,8 @@ build_model :bogus_items do
52
52
  string :url
53
53
  string :name
54
54
  string :email
55
+ string :file_path
56
+ string :dummie
55
57
 
56
58
  text :body
57
59
  integer :variant
@@ -61,7 +63,7 @@ build_model :bogus_items do
61
63
  string :field_with_client_side_validations
62
64
  string :field_without_client_side_validations
63
65
 
64
- validates_presence_of :name, :body, :variant
66
+ validates_presence_of :name, :body, :variant, :file_path, :dummie
65
67
  validates_confirmation_of :name
66
68
  validates_acceptance_of :signed, :accept => true
67
69
  validates_format_of :url,
@@ -88,3 +90,20 @@ RAILS_ROOT = File.join(File.dirname(__FILE__)) unless defined?(RAILS_ROOT)
88
90
  # Log file for testing only.
89
91
  #
90
92
  ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'debug.log'))
93
+
94
+ module Test::Unit::Assertions
95
+
96
+ #
97
+ # Assert that a piece of HTML includes the class name.
98
+ #
99
+ def assert_has_class(class_name, html, message = nil)
100
+ # Might need to consider this...but works a bit better.
101
+ classes = html.scan(/class="([^"]*)"/).collect { |c| c.to_s.split(' ') }.flatten
102
+ full_message = build_message(message, "<?>\nexpected to include class(es) <?>.\n", html, class_name)
103
+
104
+ assert_block(full_message) do
105
+ class_name.split(' ').all? { |cname| classes.include?(cname) }
106
+ end
107
+ end
108
+
109
+ end
@@ -1,162 +1,253 @@
1
1
  # encoding: utf-8
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), *%w(.. .. test_helper)))
3
3
 
4
- module Test::Unit::Assertions
5
-
6
- #
7
- # Assert that a piece of HTML includes the class name.
8
- #
9
- def assert_has_class(class_name, html, message = nil)
10
- # Might need to consider this...but works a bit better.
11
- classes = html.scan(/class="([^"]*)"/).collect { |c| c.to_s.split(' ') }.flatten
12
- full_message = build_message(message, "<?>\nexpected to include class(es) <?>.\n", html, class_name)
13
-
14
- assert_block(full_message) do
15
- class_name.split(' ').all? { |cname| classes.include?(cname) }
16
- end
17
- end
18
-
19
- end
20
-
21
4
  require 'action_view/test_case'
22
5
 
23
6
  class FormHelperTest < ::ActionView::TestCase
24
7
 
25
- include ActionView::Helpers::FormHelper
8
+ include ::ActionView::Helpers::FormHelper
9
+ include ::ActiveSupport
26
10
 
27
- def setup
11
+ before do
28
12
  @bogus_item = BogusItem.new
29
13
  end
30
14
 
31
- test "attach custom javascript validations to layout" do
32
- @content_for_validatious = nil
33
- view_output = form_for(@bogus_item, :url => '/bogus_items') do |f|
34
- concat f.text_field(:url)
15
+ context "layout" do
16
+ test "attach custom javascript validations to layout" do
17
+ @content_for_validatious = nil
18
+ view_output = form_for(@bogus_item, :url => '/bogus_items') do |f|
19
+ concat f.text_field(:url)
20
+ end
21
+ assert_match /v2.Validator/, @content_for_validatious
35
22
  end
36
- assert_match /v2.Validator/, @content_for_validatious
37
23
  end
38
24
 
39
- test "required :text_field" do
40
- # Using helper
41
- assert_has_class 'presence', text_field(:bogus_item, :name)
42
- assert_has_class 'presence some_other_class', text_field(:bogus_item, :name, :class => 'some_other_class')
43
-
44
- # Using builder
45
- assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
46
- concat f.text_field(:name)
47
- }
48
- assert_has_class 'presence text', form_for(@bogus_item, :url => '/bogus_items') { |f|
49
- concat f.text_field(:name, :class => 'text')
50
- }
51
- end
25
+ context "field class names" do
26
+ context "form helpers" do
27
+ test ":text_field" do
28
+ # Using helper
29
+ assert_has_class 'presence', text_field(:bogus_item, :name, {})
30
+ assert_has_class 'presence some_other_class', text_field(:bogus_item, :name, :class => 'some_other_class')
31
+ # Using builder
32
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
33
+ concat f.text_field(:name, {})
34
+ }
35
+ assert_has_class 'presence text', form_for(@bogus_item, :url => '/bogus_items') { |f|
36
+ concat f.text_field(:name, :class => 'text')
37
+ }
38
+ end
52
39
 
53
- test "required :password_field" do
54
- # Using helper
55
- assert_has_class 'presence', password_field(:bogus_item, :name)
56
- assert_has_class 'presence some_other_class', password_field(:bogus_item, :name, :class => 'some_other_class')
57
-
58
- # Using builder
59
- assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
60
- concat f.password_field(:name)
61
- }
62
- assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
63
- concat f.password_field(:name, :class => 'some_other_class')
64
- }
65
- end
40
+ test ":password_field" do
41
+ # Using helper
42
+ assert_has_class 'presence', password_field(:bogus_item, :name, {})
43
+ assert_has_class 'presence some_other_class', password_field(:bogus_item, :name, :class => 'some_other_class')
44
+ # Using builder
45
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
46
+ concat f.password_field(:name, {})
47
+ }
48
+ assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
49
+ concat f.password_field(:name, :class => 'some_other_class')
50
+ }
51
+ end
66
52
 
67
- test "required :text_area" do
68
- # Using helper
69
- assert_has_class 'presence', text_area(:bogus_item, :body)
70
- assert_has_class 'presence some_other_class', text_area(:bogus_item, :body, :class => 'some_other_class')
71
-
72
- # Using builder
73
- assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
74
- concat f.text_area(:body)
75
- }
76
- assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
77
- concat f.text_area(:body, :class => 'some_other_class')
78
- }
79
- end
53
+ test ":text_area" do
54
+ # Using helper
55
+ assert_has_class 'presence', text_area(:bogus_item, :body, {})
56
+ assert_has_class 'presence some_other_class', text_area(:bogus_item, :body, :class => 'some_other_class')
57
+ # Using builder
58
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
59
+ concat f.text_area(:body, {})
60
+ }
61
+ assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
62
+ concat f.text_area(:body, :class => 'some_other_class')
63
+ }
64
+ end
80
65
 
81
- test "required :check_box" do # a.k.a. "acceptance required"
82
- # Using helper
83
- assert_has_class 'acceptance-accept_true', check_box(:bogus_item, :signed)
84
- assert_has_class 'acceptance-accept_true some_other_class', check_box(:bogus_item, :signed, :class => 'some_other_class')
85
-
86
- # Using builder
87
- assert_has_class 'acceptance-accept_true', form_for(@bogus_item, :url => '/bogus_items') { |f|
88
- concat f.check_box(:signed)
89
- }
90
- assert_has_class 'acceptance-accept_true some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
91
- concat f.check_box(:signed, :class => 'some_other_class')
92
- }
93
- end
66
+ test ":check_box" do # a.k.a. "acceptance required"
67
+ # Using +helper+
68
+ assert_has_class 'acceptance-accept_true', check_box(:bogus_item, :signed, {}, '1', '0')
69
+ assert_has_class 'acceptance-accept_true some_other_class', check_box(:bogus_item, :signed, :class => 'some_other_class')
70
+ # Using builder
71
+ assert_has_class 'acceptance-accept_true', form_for(@bogus_item, :url => '/bogus_items') { |f|
72
+ concat f.check_box(:signed, {})
73
+ }
74
+ assert_has_class 'acceptance-accept_true some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
75
+ concat f.check_box(:signed, :class => 'some_other_class')
76
+ }
77
+ end
94
78
 
95
- test "required :radio_button" do
96
- # Using helper
97
- assert_has_class 'presence', radio_button(:bogus_item, :variant, 1)
98
- assert_has_class 'presence some_other_class', radio_button(:bogus_item, :variant, 1, :class => 'some_other_class')
99
-
100
- assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
101
- concat f.radio_button(:variant, 1)
102
- }
103
- assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
104
- concat f.radio_button(:variant, 1, :class => 'some_other_class')
105
- }
106
- end
79
+ test ":radio_button" do
80
+ # Using helper
81
+ assert_has_class 'presence', radio_button(:bogus_item, :variant, 1, {})
82
+ assert_has_class 'presence some_other_class', radio_button(:bogus_item, :variant, 1, :class => 'some_other_class')
83
+ # Using builder
84
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
85
+ concat f.radio_button(:variant, 1, {})
86
+ }
87
+ assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
88
+ concat f.radio_button(:variant, 1, :class => 'some_other_class')
89
+ }
90
+ end
91
+
92
+ test ":file_field" do
93
+ # Using helper
94
+ assert_has_class 'presence', file_field(:bogus_item, :file_path, {})
95
+ assert_has_class 'presence some_other_class', file_field(:bogus_item, :file_path, :class => 'some_other_class')
96
+ # Using builder
97
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
98
+ concat f.file_field(:variant, {})
99
+ }
100
+ assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
101
+ concat f.file_field(:variant, :class => 'some_other_class')
102
+ }
103
+ end
104
+ end
107
105
 
108
- test "confirmation_of :name field" do
109
- # Using helper
110
- assert_has_class 'confirmation-of_name', text_field(:bogus_item, :name_confirmation)
111
- assert_has_class 'confirmation-of_name some_other_class', text_field(:bogus_item, :name_confirmation, :class => 'some_other_class')
112
-
113
- # Using builder
114
- assert_has_class 'confirmation-of_name', form_for(@bogus_item, :url => '/bogus_items') { |f|
115
- concat f.text_field(:name_confirmation)
116
- }
117
- assert_has_class 'confirmation-of_name some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
118
- concat f.text_field(:name_confirmation, :class => 'some_other_class')
119
- }
120
- end
106
+ context "form options fields" do
107
+ test ":select" do
108
+ # Using helper
109
+ assert_has_class 'presence', select(:bogus_item, :variant, [], {}, {})
110
+ assert_has_class 'presence some_other_class', select(:bogus_item, :variant, [], {}, :class => 'some_other_class')
111
+ # Using builder
112
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
113
+ concat f.select(:variant, [], {}, {})
114
+ }
115
+ assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
116
+ concat f.select(:variant, [], {}, :class => 'some_other_class')
117
+ }
118
+ end
121
119
 
122
- test "format_of :url field" do
123
- # Using helper
124
- assert_has_class 'url', text_field(:bogus_item, :url)
125
- assert_has_class 'url some_other_class', text_field(:bogus_item, :url, :class => 'some_other_class')
126
-
127
- # Using builder
128
- assert_has_class 'url', form_for(@bogus_item, :url => '/bogus_items') { |f|
129
- concat f.text_field(:url)
130
- }
131
- assert_has_class 'url some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
132
- concat f.text_field(:url, :class => 'some_other_class')
133
- }
134
- assert_match /v2.Validator\.add\(.*\{.*"url"/, @content_for_validatious
135
- end
136
-
137
- test "exclusion_of :variant field" do
138
- # TODO
139
- end
120
+ test ":collection_select" do
121
+ # Using helper
122
+ assert_has_class 'presence', collection_select(:bogus_item, :variant, [], :to_param, :to_s, {}, {})
123
+ assert_has_class 'presence some_other_class', collection_select(:bogus_item, :variant, [], :to_param, :to_s, {}, :class => 'some_other_class')
124
+ # Using builder
125
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
126
+ concat f.collection_select(:variant, [], :to_param, :to_s, {}, {})
127
+ }
128
+ assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
129
+ concat f.collection_select(:variant, [], :to_param, :to_s, {}, :class => 'some_other_class')
130
+ }
131
+ end
140
132
 
141
- test "inclusion_of :variant field" do
142
- # TODO
143
- end
133
+ test ":grouped_collection_select" do
134
+ # Using helper
135
+ assert_has_class 'presence', grouped_collection_select(:bogus_item, :variant, [], :bogus_items, :name, :id, :name, {}, {})
136
+ assert_has_class 'presence some_other_class', grouped_collection_select(:bogus_item, :variant, [], :bogus_items, :name, :id, :name, {}, :class => 'some_other_class')
137
+ # Using builder
138
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
139
+ concat f.grouped_collection_select(:variant, [], :bogus_items, :name, :id, :name, {}, {})
140
+ }
141
+ assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
142
+ concat f.grouped_collection_select(:variant, [], :bogus_items, :name, :id, :name, {}, :class => 'some_other_class')
143
+ }
144
+ end
144
145
 
145
- test "regular label" do
146
- # Using helper
147
- assert_equal "<label for=\"bogus_item_name\">Name</label>", label(:bogus_item, :name)
146
+ test ":time_zone_select" do
147
+ # Using helper
148
+ assert_has_class 'presence', time_zone_select(:bogus_item, :dummie, TimeZone.us_zones, {}, {})
149
+ assert_has_class 'presence some_other_class', time_zone_select(:bogus_item, :dummie, TimeZone.us_zones, {}, :class => 'some_other_class')
150
+ # Using builder
151
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
152
+ concat f.time_zone_select(:dummie, TimeZone.us_zones, {}, {})
153
+ }
154
+ assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
155
+ concat f.time_zone_select(:dummie, TimeZone.us_zones, {}, :class => 'some_other_class')
156
+ }
157
+ end
158
+ end
159
+
160
+ context "date helper fields" do
161
+ test ":datetime_select" do
162
+ # Using helper
163
+ assert_has_class 'presence', datetime_select(:bogus_item, :dummie, {}, {})
164
+ assert_has_class 'presence some_other_class', datetime_select(:bogus_item, :dummie, {}, :class => 'some_other_class')
165
+ # Using builder
166
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
167
+ concat f.datetime_select(:dummie, {}, {})
168
+ }
169
+ assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
170
+ concat f.datetime_select(:dummie, {}, :class => 'some_other_class')
171
+ }
172
+ end
173
+
174
+ test ":date_select" do
175
+ # Using helper
176
+ assert_has_class 'presence', date_select(:bogus_item, :dummie, {}, {})
177
+ assert_has_class 'presence some_other_class', date_select(:bogus_item, :dummie, {}, :class => 'some_other_class')
178
+ # Using builder
179
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
180
+ concat f.date_select(:dummie, {}, {})
181
+ }
182
+ assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
183
+ concat f.date_select(:dummie, {}, :class => 'some_other_class')
184
+ }
185
+ end
186
+
187
+ test ":time_select" do
188
+ # Using helper
189
+ assert_has_class 'presence', time_select(:bogus_item, :dummie, {}, {})
190
+ assert_has_class 'presence some_other_class', time_select(:bogus_item, :dummie, {}, :class => 'some_other_class')
191
+ # Using builder
192
+ assert_has_class 'presence', form_for(@bogus_item, :url => '/bogus_items') { |f|
193
+ concat f.time_select(:dummie, {}, {})
194
+ }
195
+ assert_has_class 'presence some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
196
+ concat f.time_select(:dummie, {}, :class => 'some_other_class')
197
+ }
198
+ end
199
+ end
148
200
  end
149
201
 
150
- test "label with title" do
151
- # Using helper
152
- assert_equal "<label for=\"bogus_item_name\" title=\"craaazy\">Name</label>",
153
- label(:bogus_item, :name, nil, :title => "craaazy")
202
+ context "validator types" do
203
+ test "confirmation_of" do
204
+ # Using helper
205
+ assert_has_class 'confirmation-of_name', text_field(:bogus_item, :name_confirmation, {})
206
+ assert_has_class 'confirmation-of_name some_other_class', text_field(:bogus_item, :name_confirmation, :class => 'some_other_class')
207
+ # Using builder
208
+ assert_has_class 'confirmation-of_name', form_for(@bogus_item, :url => '/bogus_items') { |f|
209
+ concat f.text_field(:name_confirmation, {})
210
+ }
211
+ assert_has_class 'confirmation-of_name some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
212
+ concat f.text_field(:name_confirmation, :class => 'some_other_class')
213
+ }
214
+ end
215
+
216
+ test "format_of" do
217
+ # Using helper
218
+ assert_has_class 'url', text_field(:bogus_item, :url, {})
219
+ assert_has_class 'url some_other_class', text_field(:bogus_item, :url, :class => 'some_other_class')
220
+ # Using builder
221
+ assert_has_class 'url', form_for(@bogus_item, :url => '/bogus_items') { |f|
222
+ concat f.text_field(:url, {})
223
+ }
224
+ assert_has_class 'url some_other_class', form_for(@bogus_item, :url => '/bogus_items') { |f|
225
+ concat f.text_field(:url, :class => 'some_other_class')
226
+ }
227
+ assert_match /v2.Validator\.add\(.*\{.*"url"/, @content_for_validatious
228
+ end
229
+
230
+ # TODO: The other validators...
154
231
  end
155
232
 
156
- test "label without title" do
157
- # Using helper
158
- assert_equal "<label for=\"bogus_item_name\" title=\"Name\">Your name</label>",
159
- label(:bogus_item, :name, "Your name")
233
+ # TODO: Re-visit label - needed still?
234
+ context "label" do
235
+ test "regular" do
236
+ # Using helper
237
+ assert_equal "<label for=\"bogus_item_name\">Name</label>", label(:bogus_item, :name)
238
+ end
239
+
240
+ test "with title" do
241
+ # Using helper
242
+ assert_equal "<label for=\"bogus_item_name\" title=\"craaazy\">Name</label>",
243
+ label(:bogus_item, :name, nil, :title => "craaazy")
244
+ end
245
+
246
+ test "without title" do
247
+ # Using helper
248
+ assert_equal "<label for=\"bogus_item_name\" title=\"Name\">Your name</label>",
249
+ label(:bogus_item, :name, "Your name")
250
+ end
160
251
  end
161
252
 
162
253
  private
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validatious-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
- - Christian Johansen
8
7
  - Jonas Grimfelt
8
+ - Christian Johansen
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-10-17 00:00:00 +02:00
13
+ date: 2009-10-19 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
17
17
  description: Rails plugin that maps model validations to class names on form elements to integrate with Validatious.
18
- email: christian@cjohansen.no
18
+ email: grimen@gmail.com
19
19
  executables: []
20
20
 
21
21
  extensions: []