remarkable_activerecord 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/CHANGELOG +46 -46
  2. data/LICENSE +1 -1
  3. data/README +64 -64
  4. data/lib/remarkable_activerecord.rb +1 -1
  5. data/lib/remarkable_activerecord/base.rb +40 -40
  6. data/lib/remarkable_activerecord/human_names.rb +24 -24
  7. data/lib/remarkable_activerecord/matchers/allow_mass_assignment_of_matcher.rb +14 -14
  8. data/lib/remarkable_activerecord/matchers/allow_values_for_matcher.rb +70 -70
  9. data/lib/remarkable_activerecord/matchers/association_matcher.rb +197 -197
  10. data/lib/remarkable_activerecord/matchers/have_column_matcher.rb +29 -29
  11. data/lib/remarkable_activerecord/matchers/have_index_matcher.rb +20 -20
  12. data/lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb +7 -7
  13. data/lib/remarkable_activerecord/matchers/have_scope_matcher.rb +34 -34
  14. data/lib/remarkable_activerecord/matchers/validate_acceptance_of_matcher.rb +37 -37
  15. data/lib/remarkable_activerecord/matchers/validate_associated_matcher.rb +75 -75
  16. data/lib/remarkable_activerecord/matchers/validate_confirmation_of_matcher.rb +44 -44
  17. data/lib/remarkable_activerecord/matchers/validate_exclusion_of_matcher.rb +17 -17
  18. data/lib/remarkable_activerecord/matchers/validate_inclusion_of_matcher.rb +20 -20
  19. data/lib/remarkable_activerecord/matchers/validate_numericality_of_matcher.rb +14 -14
  20. data/lib/remarkable_activerecord/matchers/validate_uniqueness_of_matcher.rb +80 -61
  21. data/locale/en.yml +253 -253
  22. data/spec/allow_mass_assignment_of_matcher_spec.rb +50 -50
  23. data/spec/allow_values_for_matcher_spec.rb +45 -45
  24. data/spec/association_matcher_spec.rb +612 -612
  25. data/spec/have_column_matcher_spec.rb +67 -67
  26. data/spec/have_index_matcher_spec.rb +61 -61
  27. data/spec/have_readonly_attributes_matcher_spec.rb +40 -40
  28. data/spec/have_scope_matcher_spec.rb +60 -60
  29. data/spec/model_builder.rb +101 -101
  30. data/spec/spec_helper.rb +25 -25
  31. data/spec/validate_acceptance_of_matcher_spec.rb +64 -64
  32. data/spec/validate_associated_matcher_spec.rb +118 -118
  33. data/spec/validate_confirmation_of_matcher_spec.rb +54 -54
  34. data/spec/validate_exclusion_of_matcher_spec.rb +76 -76
  35. data/spec/validate_inclusion_of_matcher_spec.rb +72 -72
  36. data/spec/validate_numericality_of_matcher_spec.rb +100 -100
  37. data/spec/validate_presence_of_matcher_spec.rb +40 -40
  38. data/spec/validate_uniqueness_of_matcher_spec.rb +158 -139
  39. metadata +3 -3
@@ -1,44 +1,44 @@
1
- module Remarkable
2
- module ActiveRecord
3
- module Matchers
4
- class ValidateConfirmationOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
- arguments :collection => :attributes, :as => :attribute
6
-
7
- optional :message
8
- collection_assertions :responds_to_confirmation?, :confirms?
9
-
10
- default_options :message => :confirmation
11
-
12
- protected
13
-
14
- def responds_to_confirmation?
15
- @subject.respond_to?(:"#{@attribute}_confirmation=")
16
- end
17
-
18
- def confirms?
19
- @subject.send(:"#{@attribute}_confirmation=", 'something')
20
- bad?('different')
21
- end
22
-
23
- end
24
-
25
- # Ensures that the model cannot be saved if one of the attributes is not confirmed.
26
- #
27
- # == Options
28
- #
29
- # * <tt>:message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
30
- # Regexp, string or symbol. Default = <tt>I18n.translate('activerecord.errors.messages.confirmation')</tt>
31
- #
32
- # == Examples
33
- #
34
- # should_validate_confirmation_of :email, :password
35
- #
36
- # it { should validate_confirmation_of(:email, :password) }
37
- #
38
- def validate_confirmation_of(*attributes)
39
- ValidateConfirmationOfMatcher.new(*attributes).spec(self)
40
- end
41
-
42
- end
43
- end
44
- end
1
+ module Remarkable
2
+ module ActiveRecord
3
+ module Matchers
4
+ class ValidateConfirmationOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
+ arguments :collection => :attributes, :as => :attribute
6
+
7
+ optional :message
8
+ collection_assertions :responds_to_confirmation?, :confirms?
9
+
10
+ default_options :message => :confirmation
11
+
12
+ protected
13
+
14
+ def responds_to_confirmation?
15
+ @subject.respond_to?(:"#{@attribute}_confirmation=")
16
+ end
17
+
18
+ def confirms?
19
+ @subject.send(:"#{@attribute}_confirmation=", 'something')
20
+ bad?('different')
21
+ end
22
+
23
+ end
24
+
25
+ # Ensures that the model cannot be saved if one of the attributes is not confirmed.
26
+ #
27
+ # == Options
28
+ #
29
+ # * <tt>:message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
30
+ # Regexp, string or symbol. Default = <tt>I18n.translate('activerecord.errors.messages.confirmation')</tt>
31
+ #
32
+ # == Examples
33
+ #
34
+ # should_validate_confirmation_of :email, :password
35
+ #
36
+ # it { should validate_confirmation_of(:email, :password) }
37
+ #
38
+ def validate_confirmation_of(*attributes)
39
+ ValidateConfirmationOfMatcher.new(*attributes).spec(self)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -1,26 +1,26 @@
1
- require File.join(File.dirname(__FILE__), 'allow_values_for_matcher')
2
-
1
+ require File.join(File.dirname(__FILE__), 'allow_values_for_matcher')
2
+
3
3
  module Remarkable
4
4
  module ActiveRecord
5
- module Matchers
6
- class ValidateExclusionOfMatcher < AllowValuesForMatcher #:nodoc:
7
-
8
- default_options :message => :exclusion
9
-
10
- protected
11
-
12
- def valid_values
13
- @in_range ? [ @options[:in].first - 1, @options[:in].last + 1 ] : []
14
- end
15
-
16
- def invalid_values
17
- @options[:in]
18
- end
5
+ module Matchers
6
+ class ValidateExclusionOfMatcher < AllowValuesForMatcher #:nodoc:
7
+
8
+ default_options :message => :exclusion
9
+
10
+ protected
11
+
12
+ def valid_values
13
+ @in_range ? [ @options[:in].first - 1, @options[:in].last + 1 ] : []
14
+ end
15
+
16
+ def invalid_values
17
+ @options[:in]
18
+ end
19
19
 
20
20
  end
21
21
 
22
22
  # Ensures that given values are not valid for the attribute. If a range
23
- # is given, ensures that the attribute is not valid in the given range.
23
+ # is given, ensures that the attribute is not valid in the given range.
24
24
  #
25
25
  # == Options
26
26
  #
@@ -1,27 +1,27 @@
1
- require File.join(File.dirname(__FILE__), 'allow_values_for_matcher')
2
-
1
+ require File.join(File.dirname(__FILE__), 'allow_values_for_matcher')
2
+
3
3
  module Remarkable
4
4
  module ActiveRecord
5
- module Matchers
6
- class ValidateInclusionOfMatcher < AllowValuesForMatcher #:nodoc:
7
-
8
- default_options :message => :inclusion
9
-
10
- protected
11
-
12
- def valid_values
13
- @options[:in]
14
- end
15
-
16
- def invalid_values
17
- @in_range ? [ @options[:in].first - 1, @options[:in].last + 1 ] : []
18
- end
5
+ module Matchers
6
+ class ValidateInclusionOfMatcher < AllowValuesForMatcher #:nodoc:
7
+
8
+ default_options :message => :inclusion
9
+
10
+ protected
11
+
12
+ def valid_values
13
+ @options[:in]
14
+ end
15
+
16
+ def invalid_values
17
+ @in_range ? [ @options[:in].first - 1, @options[:in].last + 1 ] : []
18
+ end
19
19
 
20
20
  end
21
21
 
22
22
  # Ensures that given values are valid for the attribute. If a range
23
- # is given, ensures that the attribute is valid in the given range.
24
- #
23
+ # is given, ensures that the attribute is valid in the given range.
24
+ #
25
25
  # == Options
26
26
  #
27
27
  # * <tt>:in</tt> - values to test inclusion.
@@ -31,9 +31,9 @@ module Remarkable
31
31
  # Regexp, string or symbol. Default = <tt>I18n.translate('activerecord.errors.messages.inclusion')</tt>
32
32
  #
33
33
  # == Examples
34
- #
34
+ #
35
35
  # should_validate_inclusion_of :size, :in => ["S", "M", "L", "XL"]
36
- # should_validate_inclusion_of :age, :in => 18..100
36
+ # should_validate_inclusion_of :age, :in => 18..100
37
37
  #
38
38
  # it { should validate_inclusion_of(:size, :in => ["S", "M", "L", "XL"]) }
39
39
  # it { should validate_inclusion_of(:age, :in => 18..100) }
@@ -130,20 +130,20 @@ module Remarkable
130
130
  (valid_value_for_test / 2) * 2
131
131
  end
132
132
 
133
- # Returns the default message for each key (:odd, :even, :equal_to, ...).
134
- # If the user provided a message, we use it, otherwise we should use
135
- # the given key as message.
136
- #
137
- # For example, a default_message_for(:odd), if none is provided, will be
138
- # :odd. So we have create :odd_message in the options hash, that when
139
- # called later, will return :odd.
140
- #
141
- def default_message_for(key)
142
- if @options[:message]
143
- :message
144
- else
145
- @options[:"#{key}_message"] = key
146
- :"#{key}_message"
133
+ # Returns the default message for each key (:odd, :even, :equal_to, ...).
134
+ # If the user provided a message, we use it, otherwise we should use
135
+ # the given key as message.
136
+ #
137
+ # For example, a default_message_for(:odd), if none is provided, will be
138
+ # :odd. So we have create :odd_message in the options hash, that when
139
+ # called later, will return :odd.
140
+ #
141
+ def default_message_for(key)
142
+ if @options[:message]
143
+ :message
144
+ else
145
+ @options[:"#{key}_message"] = key
146
+ :"#{key}_message"
147
147
  end
148
148
  end
149
149
  end
@@ -2,56 +2,56 @@ module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
4
  class ValidateUniquenessOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
- arguments :collection => :attributes, :as => :attribute
6
-
7
- optional :message
5
+ arguments :collection => :attributes, :as => :attribute
6
+
7
+ optional :message
8
8
  optional :scope, :splat => true
9
- optional :case_sensitive, :allow_nil, :allow_blank, :default => true
9
+ optional :case_sensitive, :allow_nil, :allow_blank, :default => true
10
10
 
11
11
  collection_assertions :find_first_object?, :responds_to_scope?, :is_unique?, :case_sensitive?,
12
12
  :valid_with_new_scope?, :allow_nil?, :allow_blank?
13
-
14
- default_options :message => :taken
15
-
16
- before_assert do
17
- @options[:scope] = [*@options[:scope]].compact if @options[:scope]
18
- end
13
+
14
+ default_options :message => :taken
15
+
16
+ before_assert do
17
+ @options[:scope] = [*@options[:scope]].compact if @options[:scope]
18
+ end
19
19
 
20
20
  private
21
21
 
22
- # Tries to find an object in the database. If allow_nil and/or allow_blank
22
+ # Tries to find an object in the database. If allow_nil and/or allow_blank
23
23
  # is given, we must find a record which is not nil or not blank.
24
24
  #
25
25
  # If any of these attempts fail, the validation fail.
26
26
  #
27
27
  def find_first_object?
28
28
  @existing, message = if @options[:allow_nil]
29
- [ subject_class.find(:first, :conditions => "#{@attribute} IS NOT NULL"), " with #{@attribute} not nil" ]
29
+ [ subject_class.find(:first, :conditions => "#{@attribute} IS NOT NULL"), " with #{@attribute} not nil" ]
30
30
  elsif @options[:allow_blank]
31
- [ subject_class.find(:first, :conditions => "#{@attribute} != ''"), " with #{@attribute} not blank" ]
31
+ [ subject_class.find(:first, :conditions => "#{@attribute} != ''"), " with #{@attribute} not blank" ]
32
32
  else
33
33
  [ subject_class.find(:first), "" ]
34
- end
35
-
36
- return true if @existing
34
+ end
35
+
36
+ return true if @existing
37
37
  raise ScriptError, "could not find a #{subject_class} in the database" + message
38
- end
39
-
38
+ end
39
+
40
40
  # Set subject scope to be equal to the object found.
41
- #
42
- def responds_to_scope?
43
- (@options[:scope] || []).each do |scope|
44
- method = :"#{scope}="
45
- return false, :method => method unless @subject.respond_to?(method)
41
+ #
42
+ def responds_to_scope?
43
+ (@options[:scope] || []).each do |scope|
44
+ method = :"#{scope}="
45
+ return false, :method => method unless @subject.respond_to?(method)
46
46
 
47
47
  @subject.send(method, @existing.send(scope))
48
- end
49
- true
48
+ end
49
+ true
50
50
  end
51
-
51
+
52
52
  # Check if the attribute given is valid and if the validation fails for equal values.
53
53
  #
54
- def is_unique?
54
+ def is_unique?
55
55
  @value = @existing.send(@attribute)
56
56
  return bad?(@value)
57
57
  end
@@ -71,52 +71,71 @@ module Remarkable
71
71
 
72
72
  # Now test that the object is valid when changing the scoped attribute.
73
73
  #
74
- def valid_with_new_scope?
75
- (@options[:scope] || []).each do |scope|
76
- previous_scope_value = @subject.send(scope)
74
+ def valid_with_new_scope?
75
+ (@options[:scope] || []).each do |scope|
76
+ previous_scope_value = @subject.send(scope)
77
+
78
+ @subject.send("#{scope}=", new_value_for_scope(scope))
79
+ return false, :method => scope unless good?(@value)
77
80
 
78
- @subject.send("#{scope}=", new_value_for_scope(scope))
79
- return false, :method => scope unless good?(@value)
80
-
81
81
  @subject.send("#{scope}=", previous_scope_value)
82
82
  end
83
83
  true
84
84
  end
85
-
86
- # Change the existing object attribute to nil to run allow nil validation.
87
- #
85
+
86
+ # Change the existing object attribute to nil to run allow nil
87
+ # validations. If we find any problem while updating the @existing
88
+ # record, it's because we can't save nil values in the database. So it
89
+ # passes when :allow_nil is false, but should raise an error when
90
+ # :allow_nil is true
91
+ #
88
92
  def allow_nil?
89
- @existing.update_attribute(@attribute, nil)
93
+ return true unless @options.key?(:allow_nil)
94
+
95
+ @existing.update_attribute(@attribute, nil)
90
96
  super
91
- end
97
+ rescue Exception => e
98
+ raise ScriptError, "You declared that #{@attribute} accepts nil values in validate_uniqueness_of, " <<
99
+ "but I cannot save nil values in the database, got: #{e.message}" if @options[:allow_nil]
92
100
 
93
- # Change the existing object attribute to blank to run allow blank validation.
94
- #
101
+ true
102
+ end
103
+
104
+ # Change the existing object attribute to blank to run allow blank
105
+ # validation. It uses the same logic as :allow_nil.
106
+ #
95
107
  def allow_blank?
96
- @existing.update_attribute(@attribute, '')
108
+ return true unless @options.key?(:allow_blank)
109
+
110
+ @existing.update_attribute(@attribute, '')
97
111
  super
98
- end
112
+ rescue Exception => e
113
+ raise ScriptError, "You declared that #{@attribute} accepts blank values in validate_uniqueness_of, " <<
114
+ "but I cannot save blank values in the database, got: #{e.message}" if @options[:allow_blank]
115
+
116
+ true
117
+ end
99
118
 
100
- # Returns a value to be used as new scope. It does a range query in the
119
+ # Returns a value to be used as new scope. It does a range query in the
101
120
  # database and tries to return a new value which does not belong to it.
102
121
  #
103
- def new_value_for_scope(scope)
104
- new_scope = (@existing.send(scope) || 999).next.to_s
105
-
106
- # Generate a range of values to search in the database
107
- values = 100.times.inject([new_scope]) {|v,i| v << v.last.next }
108
- conditions = { scope => values, @attribute => @value }
109
-
110
- # Get values from the database, get the scope attribute and map them to string.
111
- db_values = subject_class.find(:all, :conditions => conditions, :select => scope)
112
- db_values.map!{ |r| r.send(scope).to_s }
113
-
114
- if value_to_return = (values - db_values).first
115
- value_to_return
116
- else
117
- raise ScriptError, "Tried to find an unique scope value for #{scope} but I could not. " <<
118
- "The conditions hash was #{conditions.inspect} and it returned all records."
119
- end
122
+ def new_value_for_scope(scope)
123
+ new_scope = (@existing.send(scope) || 999).next.to_s
124
+
125
+ # Generate a range of values to search in the database
126
+ values = 100.times.inject([new_scope]) {|v,i| v << v.last.next }
127
+ conditions = { scope => values, @attribute => @value }
128
+
129
+ # Get values from the database, get the scope attribute and map them to string.
130
+ db_values = subject_class.find(:all, :conditions => conditions, :select => scope)
131
+ db_values.map!{ |r| r.send(scope).to_s }
132
+
133
+ if value_to_return = (values - db_values).first
134
+ value_to_return
135
+ else
136
+ raise ScriptError, "Tried to find an unique scope value for #{scope} but I could not. " <<
137
+ "The conditions hash was #{conditions.inspect} and it returned all records."
138
+ end
120
139
  end
121
140
  end
122
141
 
@@ -124,7 +143,7 @@ module Remarkable
124
143
  # is not unique.
125
144
  #
126
145
  # Requires an existing record in the database. If you supply :allow_nil as
127
- # option, you need to have in the database a record which is not nil in the
146
+ # option, you need to have in the database a record which is not nil in the
128
147
  # given attributes. The same is required for allow_blank option.
129
148
  #
130
149
  # == Options
@@ -1,253 +1,253 @@
1
- en:
2
- remarkable:
3
- active_record:
4
- allow_nil: "{{subject_name}} to {{not}}allow nil values for {{attribute}}"
5
- allow_blank: "{{subject_name}} to {{not}}allow blank values for {{attribute}}"
6
-
7
- allow_values_for:
8
- description: "allow {{in}} as values for {{attributes}}"
9
- expectations:
10
- is_valid: "{{subject_name}} to be valid when {{attribute}} is set to {{value}}"
11
- optionals:
12
- allow_nil:
13
- positive: "allowing nil values"
14
- negative: "not allowing nil values"
15
- allow_blank:
16
- positive: "allowing blank values"
17
- negative: "not allowing blank values"
18
-
19
- allow_mass_assignment_of:
20
- description: "allow mass assignment of {{attributes}}"
21
- expectations:
22
- is_protected: "{{subject_name}} to allow mass assignment of {{attribute}} ({{subject_name}} is protecting {{attribute}})"
23
- is_accessible: "{{subject_name}} to allow mass assignment of {{attribute}} ({{subject_name}} has not made {{attribute}} accessible)"
24
-
25
- association:
26
- belongs_to: belong to
27
- has_many: have many
28
- has_and_belongs_to_many: have and belong to many
29
- has_one: have one
30
- description: "{{macro}} {{associations}}"
31
- expectations:
32
- association_exists: "{{subject_name}} records {{macro}} {{association}}, got no association"
33
- macro_matches: "{{subject_name}} records {{macro}} {{association}}, got {{subject_name}} records {{actual_macro}} {{association}}"
34
- through_exists: "{{subject_name}} records {{macro}} {{association}} through {{through}}, through association does not exist"
35
- join_table_exists: "join table {{actual_join_table}} to exist, but does not"
36
- foreign_key_exists: "foreign key {{actual_foreign_key}} to exist on {{foreign_key_table}}, but does not"
37
- polymorphic_exists: "{{subject_table}} to have {{polymorphic_column}} as column, but does not"
38
- counter_cache_exists: "{{reflection_table}} to have {{counter_cache_column}} as column, but does not"
39
- through_matches: "{{association}} association through {{through}}, got {{actual_through}}"
40
- class_name_matches: "{{association}} association with class name {{class_name}}, got {{actual_class_name}}"
41
- foreign_key_matches: "{{association}} association with foreign key {{foreign_key}}, got {{actual_foreign_key}}"
42
- dependent_matches: "{{association}} association with dependent {{dependent}}, got {{actual_dependent}}"
43
- join_table_matches: "{{association}} association with join table {{join_table}}, got {{actual_join_table}}"
44
- uniq_matches: "{{association}} association with uniq equals to {{uniq}}, got {{actual_uniq}}"
45
- readonly_matches: "{{association}} association with readonly equals to {{readonly}}, got {{actual_readonly}}"
46
- validate_matches: "{{association}} association with validate equals to {{validate}}, got {{actual_validate}}"
47
- autosave_matches: "{{association}} association with autosave equals to {{autosave}}, got {{actual_autosave}}"
48
- polymorphic_matches: "{{association}} association with polymorphic equals to {{polymorphic}}, got {{actual_polymorphic}}"
49
- as_matches: "{{association}} association with polymorphic interface {{as}}, got {{actual_as}}"
50
- counter_cache_matches: "{{association}} association with counter cache {{counter_cache}}, got {{actual_counter_cache}}"
51
- optionals:
52
- through:
53
- positive: "through {{value}}"
54
- class_name:
55
- positive: "with class name {{inspect}}"
56
- foreign_key:
57
- positive: "with foreign key {{inspect}}"
58
- dependent:
59
- positive: "with dependent {{inspect}}"
60
- join_table:
61
- positive: "with join table {{inspect}}"
62
- uniq:
63
- positive: "with unique records"
64
- negative: "without unique records"
65
- readonly:
66
- positive: "with readonly records"
67
- negative: "without readonly records"
68
- validate:
69
- positive: "validating associated records"
70
- negative: "not validating associated records"
71
- autosave:
72
- positive: "autosaving associated records"
73
- negative: "not autosaving associated records"
74
- polymorphic:
75
- positive: "through a polymorphic interface"
76
- as:
77
- positive: "through the polymorphic interface {{inspect}}"
78
- counter_cache:
79
- positive: "with counter cache {{inspect}}"
80
- negative: "without counter cache"
81
-
82
- have_column:
83
- description: "have column(s) named {{columns}}"
84
- expectations:
85
- column_exists: "{{subject_name}} to have column named {{column}}"
86
- options_match: "{{subject_name}} to have column {{column}} with options {{options}}, got {{actual}}"
87
- optionals:
88
- type:
89
- positive: "with type {{inspect}}"
90
- null:
91
- positive: "allowing null values"
92
- negative: "not allowing null values"
93
- default:
94
- positive: "with default {{inspect}}"
95
- negative: "with default {{inspect}}"
96
- limit:
97
- positive: "with limit {{inspect}}"
98
-
99
- have_index:
100
- description: "have index for column(s) {{columns}}"
101
- expectations:
102
- index_exists: "index {{column}} to exist on table {{table_name}}"
103
- is_unique: "index on {{column}} with unique equals to {{unique}}, got {{actual}}"
104
- optionals:
105
- unique:
106
- positive: "with unique values"
107
- negative: "with non unique values"
108
-
109
- have_readonly_attributes:
110
- description: "make {{attributes}} read-only"
111
- expectations:
112
- is_readonly: "{{subject_name}} to make {{attribute}} read-only, got {{actual}}"
113
-
114
- have_scope:
115
- description: "have to scope itself to {{options}} when {{scope_name}} is called"
116
- expectations:
117
- is_scope: "{{scope_name}} when called on {{subject_name}} return a ActiveRecord::NamedScope::Scope object"
118
- options_match: "{{scope_name}} when called on {{subject_name}} scope to {{options}}, got {{actual}}"
119
- optionals:
120
- with:
121
- positive: "with {{inspect}} as argument"
122
-
123
- validate_acceptance_of:
124
- description: "require {{attributes}} to be accepted"
125
- expectations:
126
- requires_acceptance: "{{subject_name}} to be invalid if {{attribute}} is not accepted"
127
- accept_is_valid: "{{subject_name}} to be valid when {{attribute}} is accepted with value {{accept}}"
128
- optionals:
129
- accept:
130
- positive: "with value {{inspect}}"
131
- allow_nil:
132
- positive: "allowing nil values"
133
- negative: "not allowing nil values"
134
-
135
- validate_associated:
136
- description: "require associated {{associations}} to be valid"
137
- expectations:
138
- is_valid: "{{subject_name}} to be invalid when {{association}} is invalid"
139
-
140
- validate_confirmation_of:
141
- description: "require {{attributes}} to be confirmed"
142
- expectations:
143
- responds_to_confirmation: "{{subject_name}} instance responds to {{attribute}}_confirmation"
144
- confirms: "{{subject_name}} to be valid only when {{attribute}} is confirmed"
145
-
146
- validate_exclusion_of:
147
- description: "ensure exclusion of {{attributes}} in {{in}}"
148
- expectations:
149
- is_valid: "{{subject_name}} to be valid when {{attribute}} is set to {{value}}"
150
- is_invalid: "{{subject_name}} to be invalid when {{attribute}} is set to {{value}}"
151
- optionals:
152
- allow_nil:
153
- positive: "allowing nil values"
154
- negative: "not allowing nil values"
155
- allow_blank:
156
- positive: "allowing blank values"
157
- negative: "not allowing blank values"
158
-
159
- validate_inclusion_of:
160
- description: "ensure inclusion of {{attributes}} in {{in}}"
161
- expectations:
162
- is_valid: "{{subject_name}} to be valid when {{attribute}} is set to {{value}}"
163
- is_invalid: "{{subject_name}} to be invalid when {{attribute}} is set to {{value}}"
164
- optionals:
165
- allow_nil:
166
- positive: "allowing nil values"
167
- negative: "not allowing nil values"
168
- allow_blank:
169
- positive: "allowing blank values"
170
- negative: "not allowing blank values"
171
-
172
- validate_length_of:
173
- description: "ensure length of {{attributes}}"
174
- expectations:
175
- less_than_min_length: "{{subject_name}} to be invalid when {{attribute}} length is less than {{minimum}} characters"
176
- exactly_min_length: "{{subject_name}} to be valid when {{attribute}} length is {{minimum}} characters"
177
- more_than_max_length: "{{subject_name}} to be invalid when {{attribute}} length is more than {{maximum}} characters"
178
- exactly_max_length: "{{subject_name}} to be valid when {{attribute}} length is {{maximum}} characters"
179
- optionals:
180
- within:
181
- positive: "is within {{inspect}} characters"
182
- maximum:
183
- positive: "is maximum {{inspect}} characters"
184
- minimum:
185
- positive: "is minimum {{inspect}} characters"
186
- is:
187
- positive: "is equal to {{inspect}} characters"
188
- allow_nil:
189
- positive: "allowing nil values"
190
- negative: "not allowing nil values"
191
- allow_blank:
192
- positive: "allowing blank values"
193
- negative: "not allowing blank values"
194
-
195
- validate_numericality_of:
196
- description: "ensure numericality of {{attributes}}"
197
- expectations:
198
- only_numeric_values: "{{subject_name}} to allow only numeric values for {{attribute}}"
199
- only_integer: "{{subject_name}} to {{not}}allow only integer values for {{attribute}}"
200
- only_even: "{{subject_name}} to allow only even values for {{attribute}}"
201
- only_odd: "{{subject_name}} to allow only odd values for {{attribute}}"
202
- equals_to: "{{subject_name}} to be valid only when {{attribute}} is equal to {{count}}"
203
- more_than_maximum: "{{subject_name}} to be invalid when {{attribute}} is greater than {{count}}"
204
- less_than_minimum: "{{subject_name}} to be invalid when {{attribute}} is less than {{count}}"
205
- optionals:
206
- only_integer:
207
- positive: "allowing only integer values"
208
- odd:
209
- positive: "allowing only odd values"
210
- even:
211
- positive: "allowing only even values"
212
- equal_to:
213
- positive: "is equal to {{inspect}}"
214
- less_than:
215
- positive: "is less than {{inspect}}"
216
- greater_than:
217
- positive: "is greater than {{inspect}}"
218
- less_than_or_equal_to:
219
- positive: "is less than or equal to {{inspect}}"
220
- greater_than_or_equal_to:
221
- positive: "is greater than or equal to {{inspect}}"
222
- allow_nil:
223
- positive: "allowing nil values"
224
- negative: "not allowing nil values"
225
- allow_blank:
226
- positive: "allowing blank values"
227
- negative: "not allowing blank values"
228
-
229
- validate_presence_of:
230
- description: "require {{attributes}} to be set"
231
- expectations:
232
- allow_nil: "{{subject_name}} to require {{attribute}} to be set"
233
-
234
- validate_uniqueness_of:
235
- description: "require unique values for {{attributes}}"
236
- expectations:
237
- responds_to_scope: "{{subject_name}} instance responds to {{method}}"
238
- is_unique: "{{subject_name}} to require unique values for {{attribute}}"
239
- case_sensitive: "{{subject_name}} to {{not}}be case sensitive on {{attribute}} validation"
240
- valid_with_new_scope: "{{subject_name}} to be valid when {{attribute}} scope ({{method}}) change"
241
- optionals:
242
- scope:
243
- positive: "scoped to {{inspect}}"
244
- case_sensitive:
245
- positive: "case sensitive"
246
- negative: "case insensitive"
247
- allow_nil:
248
- positive: "allowing nil values"
249
- negative: "not allowing nil values"
250
- allow_blank:
251
- positive: "allowing blank values"
252
- negative: "not allowing blank values"
253
-
1
+ en:
2
+ remarkable:
3
+ active_record:
4
+ allow_nil: "{{subject_name}} to {{not}}allow nil values for {{attribute}}"
5
+ allow_blank: "{{subject_name}} to {{not}}allow blank values for {{attribute}}"
6
+
7
+ allow_values_for:
8
+ description: "allow {{in}} as values for {{attributes}}"
9
+ expectations:
10
+ is_valid: "{{subject_name}} to be valid when {{attribute}} is set to {{value}}"
11
+ optionals:
12
+ allow_nil:
13
+ positive: "allowing nil values"
14
+ negative: "not allowing nil values"
15
+ allow_blank:
16
+ positive: "allowing blank values"
17
+ negative: "not allowing blank values"
18
+
19
+ allow_mass_assignment_of:
20
+ description: "allow mass assignment of {{attributes}}"
21
+ expectations:
22
+ is_protected: "{{subject_name}} to allow mass assignment of {{attribute}} ({{subject_name}} is protecting {{attribute}})"
23
+ is_accessible: "{{subject_name}} to allow mass assignment of {{attribute}} ({{subject_name}} has not made {{attribute}} accessible)"
24
+
25
+ association:
26
+ belongs_to: belong to
27
+ has_many: have many
28
+ has_and_belongs_to_many: have and belong to many
29
+ has_one: have one
30
+ description: "{{macro}} {{associations}}"
31
+ expectations:
32
+ association_exists: "{{subject_name}} records {{macro}} {{association}}, got no association"
33
+ macro_matches: "{{subject_name}} records {{macro}} {{association}}, got {{subject_name}} records {{actual_macro}} {{association}}"
34
+ through_exists: "{{subject_name}} records {{macro}} {{association}} through {{through}}, through association does not exist"
35
+ join_table_exists: "join table {{actual_join_table}} to exist, but does not"
36
+ foreign_key_exists: "foreign key {{actual_foreign_key}} to exist on {{foreign_key_table}}, but does not"
37
+ polymorphic_exists: "{{subject_table}} to have {{polymorphic_column}} as column, but does not"
38
+ counter_cache_exists: "{{reflection_table}} to have {{counter_cache_column}} as column, but does not"
39
+ through_matches: "{{association}} association through {{through}}, got {{actual_through}}"
40
+ class_name_matches: "{{association}} association with class name {{class_name}}, got {{actual_class_name}}"
41
+ foreign_key_matches: "{{association}} association with foreign key {{foreign_key}}, got {{actual_foreign_key}}"
42
+ dependent_matches: "{{association}} association with dependent {{dependent}}, got {{actual_dependent}}"
43
+ join_table_matches: "{{association}} association with join table {{join_table}}, got {{actual_join_table}}"
44
+ uniq_matches: "{{association}} association with uniq equals to {{uniq}}, got {{actual_uniq}}"
45
+ readonly_matches: "{{association}} association with readonly equals to {{readonly}}, got {{actual_readonly}}"
46
+ validate_matches: "{{association}} association with validate equals to {{validate}}, got {{actual_validate}}"
47
+ autosave_matches: "{{association}} association with autosave equals to {{autosave}}, got {{actual_autosave}}"
48
+ polymorphic_matches: "{{association}} association with polymorphic equals to {{polymorphic}}, got {{actual_polymorphic}}"
49
+ as_matches: "{{association}} association with polymorphic interface {{as}}, got {{actual_as}}"
50
+ counter_cache_matches: "{{association}} association with counter cache {{counter_cache}}, got {{actual_counter_cache}}"
51
+ optionals:
52
+ through:
53
+ positive: "through {{value}}"
54
+ class_name:
55
+ positive: "with class name {{inspect}}"
56
+ foreign_key:
57
+ positive: "with foreign key {{inspect}}"
58
+ dependent:
59
+ positive: "with dependent {{inspect}}"
60
+ join_table:
61
+ positive: "with join table {{inspect}}"
62
+ uniq:
63
+ positive: "with unique records"
64
+ negative: "without unique records"
65
+ readonly:
66
+ positive: "with readonly records"
67
+ negative: "without readonly records"
68
+ validate:
69
+ positive: "validating associated records"
70
+ negative: "not validating associated records"
71
+ autosave:
72
+ positive: "autosaving associated records"
73
+ negative: "not autosaving associated records"
74
+ polymorphic:
75
+ positive: "through a polymorphic interface"
76
+ as:
77
+ positive: "through the polymorphic interface {{inspect}}"
78
+ counter_cache:
79
+ positive: "with counter cache {{inspect}}"
80
+ negative: "without counter cache"
81
+
82
+ have_column:
83
+ description: "have column(s) named {{columns}}"
84
+ expectations:
85
+ column_exists: "{{subject_name}} to have column named {{column}}"
86
+ options_match: "{{subject_name}} to have column {{column}} with options {{options}}, got {{actual}}"
87
+ optionals:
88
+ type:
89
+ positive: "with type {{inspect}}"
90
+ null:
91
+ positive: "allowing null values"
92
+ negative: "not allowing null values"
93
+ default:
94
+ positive: "with default {{inspect}}"
95
+ negative: "with default {{inspect}}"
96
+ limit:
97
+ positive: "with limit {{inspect}}"
98
+
99
+ have_index:
100
+ description: "have index for column(s) {{columns}}"
101
+ expectations:
102
+ index_exists: "index {{column}} to exist on table {{table_name}}"
103
+ is_unique: "index on {{column}} with unique equals to {{unique}}, got {{actual}}"
104
+ optionals:
105
+ unique:
106
+ positive: "with unique values"
107
+ negative: "with non unique values"
108
+
109
+ have_readonly_attributes:
110
+ description: "make {{attributes}} read-only"
111
+ expectations:
112
+ is_readonly: "{{subject_name}} to make {{attribute}} read-only, got {{actual}}"
113
+
114
+ have_scope:
115
+ description: "have to scope itself to {{options}} when {{scope_name}} is called"
116
+ expectations:
117
+ is_scope: "{{scope_name}} when called on {{subject_name}} return a ActiveRecord::NamedScope::Scope object"
118
+ options_match: "{{scope_name}} when called on {{subject_name}} scope to {{options}}, got {{actual}}"
119
+ optionals:
120
+ with:
121
+ positive: "with {{inspect}} as argument"
122
+
123
+ validate_acceptance_of:
124
+ description: "require {{attributes}} to be accepted"
125
+ expectations:
126
+ requires_acceptance: "{{subject_name}} to be invalid if {{attribute}} is not accepted"
127
+ accept_is_valid: "{{subject_name}} to be valid when {{attribute}} is accepted with value {{accept}}"
128
+ optionals:
129
+ accept:
130
+ positive: "with value {{inspect}}"
131
+ allow_nil:
132
+ positive: "allowing nil values"
133
+ negative: "not allowing nil values"
134
+
135
+ validate_associated:
136
+ description: "require associated {{associations}} to be valid"
137
+ expectations:
138
+ is_valid: "{{subject_name}} to be invalid when {{association}} is invalid"
139
+
140
+ validate_confirmation_of:
141
+ description: "require {{attributes}} to be confirmed"
142
+ expectations:
143
+ responds_to_confirmation: "{{subject_name}} instance responds to {{attribute}}_confirmation"
144
+ confirms: "{{subject_name}} to be valid only when {{attribute}} is confirmed"
145
+
146
+ validate_exclusion_of:
147
+ description: "ensure exclusion of {{attributes}} in {{in}}"
148
+ expectations:
149
+ is_valid: "{{subject_name}} to be valid when {{attribute}} is set to {{value}}"
150
+ is_invalid: "{{subject_name}} to be invalid when {{attribute}} is set to {{value}}"
151
+ optionals:
152
+ allow_nil:
153
+ positive: "allowing nil values"
154
+ negative: "not allowing nil values"
155
+ allow_blank:
156
+ positive: "allowing blank values"
157
+ negative: "not allowing blank values"
158
+
159
+ validate_inclusion_of:
160
+ description: "ensure inclusion of {{attributes}} in {{in}}"
161
+ expectations:
162
+ is_valid: "{{subject_name}} to be valid when {{attribute}} is set to {{value}}"
163
+ is_invalid: "{{subject_name}} to be invalid when {{attribute}} is set to {{value}}"
164
+ optionals:
165
+ allow_nil:
166
+ positive: "allowing nil values"
167
+ negative: "not allowing nil values"
168
+ allow_blank:
169
+ positive: "allowing blank values"
170
+ negative: "not allowing blank values"
171
+
172
+ validate_length_of:
173
+ description: "ensure length of {{attributes}}"
174
+ expectations:
175
+ less_than_min_length: "{{subject_name}} to be invalid when {{attribute}} length is less than {{minimum}} characters"
176
+ exactly_min_length: "{{subject_name}} to be valid when {{attribute}} length is {{minimum}} characters"
177
+ more_than_max_length: "{{subject_name}} to be invalid when {{attribute}} length is more than {{maximum}} characters"
178
+ exactly_max_length: "{{subject_name}} to be valid when {{attribute}} length is {{maximum}} characters"
179
+ optionals:
180
+ within:
181
+ positive: "is within {{inspect}} characters"
182
+ maximum:
183
+ positive: "is maximum {{inspect}} characters"
184
+ minimum:
185
+ positive: "is minimum {{inspect}} characters"
186
+ is:
187
+ positive: "is equal to {{inspect}} characters"
188
+ allow_nil:
189
+ positive: "allowing nil values"
190
+ negative: "not allowing nil values"
191
+ allow_blank:
192
+ positive: "allowing blank values"
193
+ negative: "not allowing blank values"
194
+
195
+ validate_numericality_of:
196
+ description: "ensure numericality of {{attributes}}"
197
+ expectations:
198
+ only_numeric_values: "{{subject_name}} to allow only numeric values for {{attribute}}"
199
+ only_integer: "{{subject_name}} to {{not}}allow only integer values for {{attribute}}"
200
+ only_even: "{{subject_name}} to allow only even values for {{attribute}}"
201
+ only_odd: "{{subject_name}} to allow only odd values for {{attribute}}"
202
+ equals_to: "{{subject_name}} to be valid only when {{attribute}} is equal to {{count}}"
203
+ more_than_maximum: "{{subject_name}} to be invalid when {{attribute}} is greater than {{count}}"
204
+ less_than_minimum: "{{subject_name}} to be invalid when {{attribute}} is less than {{count}}"
205
+ optionals:
206
+ only_integer:
207
+ positive: "allowing only integer values"
208
+ odd:
209
+ positive: "allowing only odd values"
210
+ even:
211
+ positive: "allowing only even values"
212
+ equal_to:
213
+ positive: "is equal to {{inspect}}"
214
+ less_than:
215
+ positive: "is less than {{inspect}}"
216
+ greater_than:
217
+ positive: "is greater than {{inspect}}"
218
+ less_than_or_equal_to:
219
+ positive: "is less than or equal to {{inspect}}"
220
+ greater_than_or_equal_to:
221
+ positive: "is greater than or equal to {{inspect}}"
222
+ allow_nil:
223
+ positive: "allowing nil values"
224
+ negative: "not allowing nil values"
225
+ allow_blank:
226
+ positive: "allowing blank values"
227
+ negative: "not allowing blank values"
228
+
229
+ validate_presence_of:
230
+ description: "require {{attributes}} to be set"
231
+ expectations:
232
+ allow_nil: "{{subject_name}} to require {{attribute}} to be set"
233
+
234
+ validate_uniqueness_of:
235
+ description: "require unique values for {{attributes}}"
236
+ expectations:
237
+ responds_to_scope: "{{subject_name}} instance responds to {{method}}"
238
+ is_unique: "{{subject_name}} to require unique values for {{attribute}}"
239
+ case_sensitive: "{{subject_name}} to {{not}}be case sensitive on {{attribute}} validation"
240
+ valid_with_new_scope: "{{subject_name}} to be valid when {{attribute}} scope ({{method}}) change"
241
+ optionals:
242
+ scope:
243
+ positive: "scoped to {{inspect}}"
244
+ case_sensitive:
245
+ positive: "case sensitive"
246
+ negative: "case insensitive"
247
+ allow_nil:
248
+ positive: "allowing nil values"
249
+ negative: "not allowing nil values"
250
+ allow_blank:
251
+ positive: "allowing blank values"
252
+ negative: "not allowing blank values"
253
+