0
@@ -36,14 +36,14 @@ module ThoughtBot # :nodoc:
0
# * <tt>:message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
0
- # Regexp or string. Default = <tt>
/blank/</tt>
0
+ # Regexp or string. Default = <tt>
ActiveRecord::Errors.default_error_messages[:blank]</tt>
0
# should_require_attributes :name, :phone_number
0
def should_require_attributes(*attributes)
0
message = get_options!(attributes, :message)
0
+ message ||=
::ActiveRecord::Errors.default_error_messages[:blank]0
attributes.each do |attribute|
0
@@ -58,7 +58,7 @@ module ThoughtBot # :nodoc:
0
# * <tt>:message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
0
- # Regexp or string. Default = <tt>
/taken/</tt>
0
+ # Regexp or string. Default = <tt>
ActiveRecord::Errors.default_error_messages[:taken]</tt>
0
# * <tt>:scoped_to</tt> - field(s) to scope the uniqueness to.
0
@@ -70,7 +70,7 @@ module ThoughtBot # :nodoc:
0
def should_require_unique_attributes(*attributes)
0
message, scope = get_options!(attributes, :message, :scoped_to)
0
scope = [*scope].compact
0
+ message ||=
::ActiveRecord::Errors.default_error_messages[:taken]0
attributes.each do |attribute|
0
@@ -156,14 +156,14 @@ module ThoughtBot # :nodoc:
0
# * <tt>:message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
0
- # Regexp or string. Default = <tt>
/invalid/</tt>
0
+ # Regexp or string. Default = <tt>
ActiveRecord::Errors.default_error_messages[:invalid]</tt>
0
# should_not_allow_values_for :isbn, "bad 1", "bad 2"
0
def should_not_allow_values_for(attribute, *bad_values)
0
message = get_options!(bad_values, :message)
0
+ message ||=
::ActiveRecord::Errors.default_error_messages[:invalid]0
should "not allow #{attribute} to be set to #{v.inspect}" do
0
@@ -199,17 +199,17 @@ module ThoughtBot # :nodoc:
0
# * <tt>:short_message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
0
- # Regexp or string. Default = <tt>
/short/</tt>
0
+ # Regexp or string. Default = <tt>
ActiveRecord::Errors.default_error_messages[:too_short] % range.first</tt>
0
# * <tt>:long_message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
0
- # Regexp or string. Default = <tt>
/long/</tt>
0
+ # Regexp or string. Default = <tt>
ActiveRecord::Errors.default_error_messages[:too_long] % range.last</tt>
0
# should_ensure_length_in_range :password, (6..20)
0
def should_ensure_length_in_range(attribute, range, opts = {})
0
short_message, long_message = get_options!([opts], :short_message, :long_message)
0
- short_message ||= /short/
0
- long_message ||= /long/
0
+ short_message ||= ::ActiveRecord::Errors.default_error_messages[:too_short] % range.first
0
+ long_message ||= ::ActiveRecord::Errors.default_error_messages[:too_long] % range.last
0
min_length = range.first
0
@@ -251,14 +251,14 @@ module ThoughtBot # :nodoc:
0
# * <tt>:short_message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
0
- # Regexp or string. Default = <tt>
/short/</tt>
0
+ # Regexp or string. Default = <tt>
ActiveRecord::Errors.default_error_messages[:too_short] % min_length</tt>
0
# should_ensure_length_at_least :name, 3
0
def should_ensure_length_at_least(attribute, min_length, opts = {})
0
short_message = get_options!([opts], :short_message)
0
- short_message ||=
/short/0
+ short_message ||=
::ActiveRecord::Errors.default_error_messages[:too_short] % min_length0
@@ -282,14 +282,14 @@ module ThoughtBot # :nodoc:
0
# * <tt>:message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
0
- # Regexp or string. Default = <tt>
/short/</tt>
0
+ # Regexp or string. Default = <tt>
ActiveRecord::Errors.default_error_messages[:wrong_length] % length</tt>
0
# should_ensure_length_is :ssn, 9
0
def should_ensure_length_is(attribute, length, opts = {})
0
message = get_options!([opts], :message)
0
- message ||=
/wrong length/0
+ message ||=
::ActiveRecord::Errors.default_error_messages[:wrong_length] % length0
@@ -317,17 +317,17 @@ module ThoughtBot # :nodoc:
0
# * <tt>:low_message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
0
- # Regexp or string. Default = <tt>
/included/</tt>
0
+ # Regexp or string. Default = <tt>
ActiveRecord::Errors.default_error_messages[:inclusion]</tt>
0
# * <tt>:high_message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
0
- # Regexp or string. Default = <tt>
/included/</tt>
0
+ # Regexp or string. Default = <tt>
ActiveRecord::Errors.default_error_messages[:inclusion]</tt>
0
# should_ensure_value_in_range :age, (0..100)
0
def should_ensure_value_in_range(attribute, range, opts = {})
0
low_message, high_message = get_options!([opts], :low_message, :high_message)
0
- low_message ||= /included/
0
- high_message ||= /included/
0
+ low_message ||= ::ActiveRecord::Errors.default_error_messages[:inclusion]
0
+ high_message ||= ::ActiveRecord::Errors.default_error_messages[:inclusion]
0
@@ -362,14 +362,14 @@ module ThoughtBot # :nodoc:
0
# * <tt>:message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
0
- # Regexp or string. Default = <tt>
/number/</tt>
0
+ # Regexp or string. Default = <tt>
ActiveRecord::Errors.default_error_messages[:not_a_number]</tt>
0
# should_only_allow_numeric_values_for :age
0
def should_only_allow_numeric_values_for(*attributes)
0
message = get_options!(attributes, :message)
0
+ message ||=
::ActiveRecord::Errors.default_error_messages[:not_a_number]0
attributes.each do |attribute|
0
attribute = attribute.to_sym
0
@@ -605,14 +605,14 @@ module ThoughtBot # :nodoc:
0
# * <tt>:message</tt> - value the test expects to find in <tt>errors.on(:attribute)</tt>.
0
- # Regexp or string. Default = <tt>
/must be accepted/</tt>
0
+ # Regexp or string. Default = <tt>
ActiveRecord::Errors.default_error_messages[:accepted]</tt>
0
# should_require_acceptance_of :eula
0
def should_require_acceptance_of(*attributes)
0
message = get_options!(attributes, :message)
0
- message ||=
/must be accepted/0
+ message ||=
::ActiveRecord::Errors.default_error_messages[:accepted]0
attributes.each do |attribute|
Unfortunately, this breaks shoulda on edge rails. default_error_messages are run through I18n now. I haven’t tried it, but I believe the older method will still work.
brandonarbini, I just created a ticket to track the fix for this.
Fixed. See: http://github.com/thoughtbot/shoulda/commit/c60fa4be85af2c8273460c7fc0881847b4dbd171