<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>remarkable_activerecord/spec/model_builder.rb</filename>
    </added>
    <added>
      <filename>remarkable_activerecord/spec/validate_length_of_matcher_spec.rb</filename>
    </added>
    <added>
      <filename>remarkable_activerecord/spec/validate_numericality_of_matcher_spec.rb</filename>
    </added>
    <added>
      <filename>remarkable_activerecord/spec/validate_presence_of_matcher_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -14,4 +14,5 @@ bundle
 lib/remarkable-more.rb
 *.DS_Store
 ./gems
-*.diff
\ No newline at end of file
+*.diff
+memory</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -12,15 +12,6 @@ module Remarkable
   end
 end
 
-# Load rspec
-begin
-  require 'spec'
-rescue LoadError
-  require 'rubygems'
-  gem 'spec'
-  require 'spec'
-end
-
 # Load core files
 dir = File.dirname(__FILE__)
 require File.join(dir, 'remarkable', 'version')
@@ -30,9 +21,13 @@ require File.join(dir, 'remarkable', 'messages')
 
 require File.join(dir, 'remarkable', 'base')
 require File.join(dir, 'remarkable', 'macros')
-
-require File.join(dir, 'remarkable', 'rspec')
 require File.join(dir, 'remarkable', 'core_ext', 'array')
 
+# Loads rspec files only if spec is defined
+if defined?(Spec)
+  require File.join(dir, 'remarkable', 'rspec')
+end
+
+
 # Add Remarkable default locale file
 Remarkable.add_locale File.join(dir, '..', 'locale', 'en.yml')</diff>
      <filename>remarkable/lib/remarkable.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,7 +34,7 @@ module Remarkable
 end
 
 # Load I18n
-RAILS_I18N = Object.const_defined?('I18n') # Rails &gt;= 2.2
+RAILS_I18N = Object.const_defined?(:I18n) unless Object.const_defined?(:RAILS_I18N) # Rails &gt;= 2.2
 
 unless RAILS_I18N
   begin</diff>
      <filename>remarkable/lib/remarkable/i18n.rb</filename>
    </modified>
    <modified>
      <diff>@@ -74,9 +74,9 @@ module Remarkable
         # to be used as default.
         #
         def allow_nil?(message_key=:message) #:nodoc:
-          bool, options = assert_good_or_bad_if_key(:allow_nil, nil, message_key)
+          valid, options = assert_good_or_bad_if_key(:allow_nil, nil, message_key)
 
-          unless bool
+          unless valid
             default = Remarkable.t &quot;remarkable.active_record.allow_nil&quot;, default_i18n_options.except(:scope).merge(options)
             return false, options.merge(:default =&gt; default)
           end
@@ -91,9 +91,9 @@ module Remarkable
         # to be used as default.
         #
         def allow_blank?(message_key=:message) #:nodoc:
-          bool, options = assert_good_or_bad_if_key(:allow_blank, '', message_key)
+          valid, options = assert_good_or_bad_if_key(:allow_blank, '', message_key)
 
-          unless bool
+          unless valid
             default = Remarkable.t &quot;remarkable.active_record.allow_blank&quot;, default_i18n_options.except(:scope).merge(options)
             return false, options.merge(:default =&gt; default)
           end</diff>
      <filename>remarkable_activerecord/lib/remarkable_activerecord/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,20 +7,17 @@ module Remarkable
         optional :within, :alias =&gt; :in
         optional :minimum, :maximum, :is
         optional :allow_nil, :allow_blank, :default =&gt; true
-        optional :message, :short_message, :long_message
+        optional :message, :too_short, :too_long, :wrong_length
 
         collection_assertions :less_than_min_length?, :exactly_min_length?, :allow_nil?,
                               :more_than_max_length?, :exactly_max_length?, :allow_blank?
 
-        # Reassign :in to :within
-        after_initialize do
+        before_assert do
+          # Reassign :in to :within
           @options[:within] ||= @options.delete(:in) if @options.key? :in
-        end
 
-        before_assert do
           if @options[:is]
-            @min_value, @max_value = @options[:is], nil
-            @options[:message] ||= :wrong_length
+            @min_value, @max_value = @options[:is], @options[:is]
           elsif @options[:within]
             @min_value, @max_value = @options[:within].first, @options[:within].last
           elsif @options[:maximum]
@@ -28,49 +25,43 @@ module Remarkable
           elsif @options[:minimum]
             @min_value, @max_value = @options[:minimum], nil
           end
-
-          # Reassing message to short_message and long_message
-          if @options[:message] &amp;&amp; !@options.slice(:is, :maximum, :minimum).empty?
-            @options[:short_message] = @options.delete(:message)
-            @options[:long_message]  = @options[:short_message]
-          end
         end
 
-        default_options :short_message =&gt; :too_short, :long_message =&gt; :too_long
+        default_options :too_short =&gt; :too_short, :too_long =&gt; :too_long, :wrong_length =&gt; :wrong_length
 
         protected
           def allow_nil?
-            super(:short_message)
+            super(default_message_for(:too_short))
           end
 
           def allow_blank?
-            super(:short_message)
+            super(default_message_for(:too_short))
           end
 
           def less_than_min_length?
             return true if @min_value.nil? || @min_value &lt;= 1 ||
-                           bad?(value_for_length(@min_value - 1), :short_message)
+                           bad?(value_for_length(@min_value - 1), default_message_for(:too_short))
 
             return false, :count =&gt; @min_value
           end
 
           def exactly_min_length?
             return true if @min_value.nil? || @min_value &lt;= 0 ||
-                           good?(value_for_length(@min_value), :short_message)
+                           good?(value_for_length(@min_value), default_message_for(:too_short))
 
             return false, :count =&gt; @min_value
           end
 
           def more_than_max_length?
             return true if @max_value.nil? ||
-                           bad?(value_for_length(@max_value + 1), :long_message)
+                           bad?(value_for_length(@max_value + 1), default_message_for(:too_long))
 
             return false, :count =&gt; @max_value
           end
 
           def exactly_max_length?
             return true if @max_value.nil? || @min_value == @max_value ||
-                           good?(value_for_length(@max_value), :long_message)
+                           good?(value_for_length(@max_value), default_message_for(:too_long))
 
             return false, :count =&gt; @max_value
           end
@@ -78,6 +69,16 @@ module Remarkable
           def value_for_length(value)
             &quot;x&quot; * value
           end
+
+          # Returns the default message for the validation type.
+          # If user supplied :message, it will return it. Otherwise it will return
+          # wrong_length on :is validation and :too_short or :too_long in the other
+          # types.
+          #
+          def default_message_for(validation_type)
+            return :message if @options[:message]
+            @options.key?(:is) ? :wrong_length : validation_type
+          end
       end
 
       # Validates the length of the given attributes. You have also to supply</diff>
      <filename>remarkable_activerecord/lib/remarkable_activerecord/validations/validate_length_of_matcher.rb</filename>
    </modified>
    <modified>
      <diff>@@ -72,12 +72,20 @@ module Remarkable
             assert_bad_or_good_if_key(:only_integer, valid_value_for_test.to_f, default_message_for(:number))
           end
 
+          # If ActiveRecord, when we supply :even, does not matter the value, it
+          # considers that should even values should be accepted.
+          #
           def only_even?
-            assert_bad_or_good_if_key(:even, even_valid_value_for_test + 1, default_message_for(:even))
+            return true unless @options[:even]
+            bad?(even_valid_value_for_test + 1, default_message_for(:even))
           end
 
+          # If ActiveRecord, when we supply :odd, does not matter the value, it
+          # considers that should odd values should be accepted.
+          #
           def only_odd?
-            assert_bad_or_good_if_key(:odd, even_valid_value_for_test, default_message_for(:odd))
+            return true unless @options[:odd]
+            bad?(even_valid_value_for_test, default_message_for(:odd))
           end
 
           # Check equal_to for all registered values.</diff>
      <filename>remarkable_activerecord/lib/remarkable_activerecord/validations/validate_numericality_of_matcher.rb</filename>
    </modified>
    <modified>
      <diff>@@ -55,8 +55,8 @@ en:
         missing:
           only_numeric_values: &quot;allow non-numeric values for {{attribute}}&quot;
           only_integer: &quot;{{not}}allow non-integer values for {{attribute}}&quot;
-          only_even: &quot;{{not}}allow non-even values for {{attribute}}&quot;
-          only_odd: &quot;{{not}}allow non-odd values for {{attribute}}&quot;
+          only_even: &quot;allow non-even values for {{attribute}}&quot;
+          only_odd: &quot;allow non-odd values for {{attribute}}&quot;
           equal_to: &quot;not allow {{attribute}} to be equal to {{count}}&quot;
           more_than_maximum: &quot;allow {{attribute}} to be greater than {{count}}&quot;
           less_than_minimum: &quot;allow {{attribute}} to be less than {{count}}&quot;</diff>
      <filename>remarkable_activerecord/locale/en.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,21 @@
 require 'rubygems'
 require 'ruby-debug'
+require 'active_support'
+require 'active_record'
 
+# Configure ActiveRecord connection
+ActiveRecord::Base.establish_connection(
+  :adapter =&gt; 'sqlite3',
+  :dbfile  =&gt; 'memory'
+)
+
+# Load Remarkable core on place to avoid gem to be loaded
 dir = File.dirname(__FILE__)
-FIXTURE_PATH = File.join(dir, &quot;fixtures&quot;)
-require File.join(dir, '..', '..', 'remarkable_rails', 'spec', 'rails_loader_helper')
+require File.join(dir, '..', '..', 'remarkable', 'lib', 'remarkable')
+
+# Load Remarkable ActiveRecord
+require File.join(dir, 'model_builder')
+require File.join(dir, '..', 'lib', 'remarkable_activerecord')
 
-rails_load! do
-  # Load Remarkable ActiveRecord
-  require File.join(dir, '..', 'lib', 'remarkable_activerecord')
-end
+# Include matchers
+Remarkable.include_matchers!(Remarkable::ActiveRecord, Spec::Example::ExampleGroup)</diff>
      <filename>remarkable_activerecord/spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>remarkable_activerecord/spec/matchers/validate_length_of_matcher_spec.rb</filename>
    </removed>
    <removed>
      <filename>remarkable_activerecord/spec/matchers/validate_numericality_of_matcher_spec.rb</filename>
    </removed>
    <removed>
      <filename>remarkable_activerecord/spec/matchers/validate_presence_of_matcher_spec.rb</filename>
    </removed>
    <removed>
      <filename>remarkable_activerecord/spec/models/address_spec.rb</filename>
    </removed>
    <removed>
      <filename>remarkable_activerecord/spec/models/product_spec.rb</filename>
    </removed>
    <removed>
      <filename>remarkable_activerecord/spec/models/user_spec.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>616810c0f9ed22f58fe8543ffdc8a483fb146089</id>
    </parent>
  </parents>
  <author>
    <name>Jos&#233; Valim</name>
    <email>jose.valim@gmail.com</email>
  </author>
  <url>http://github.com/carlosbrando/remarkable/commit/81447550413ca378ebc982a46caf780c7ffbe560</url>
  <id>81447550413ca378ebc982a46caf780c7ffbe560</id>
  <committed-date>2009-03-12T06:25:08-07:00</committed-date>
  <authored-date>2009-03-12T06:25:08-07:00</authored-date>
  <message>Using unit test for ActiveRecord matchers (faster, simpler and better).</message>
  <tree>e6e1b19d81d9a7d151a64e33338e9fa91274f3e7</tree>
  <committer>
    <name>Jos&#233; Valim</name>
    <email>jose.valim@gmail.com</email>
  </committer>
</commit>
