remarkable_activerecord 3.0.0 → 3.0.1

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/README CHANGED
@@ -1,2 +1,82 @@
1
- Remarkable ActiveRecord
2
- =======================
1
+ = Remarkable ActiveRecord
2
+
3
+ Remarkable ActiveRecord is a collection of matchers to ActiveRecord. Why use
4
+ Remarkable?
5
+
6
+ * The only one with matchers for all ActiveRecord validations, with support to
7
+ all options;
8
+
9
+ * Matchers for all ActiveRecord associations. The only one which supports all
10
+ these options:
11
+
12
+ :through, :class_name, :foreign_key, :dependent, :join_table, :uniq,
13
+ :readonly, :validate, :autosave, :counter_cache, :polymorphic
14
+
15
+ Besides in Remarkable 3.0 matchers became much smarter. Whenever :join_table
16
+ or :through is given as option, it checks if the given table exists. Whenever
17
+ :foreign_key or :counter_cache is given, it checks if the given column exists;
18
+
19
+ * Tests and more tests. We have a huge tests suite ready to run and tested in
20
+ ActiveRecord 2.1.2, 2.2.2 and 2.3.2;
21
+
22
+ * Great documentation;
23
+
24
+ * I18n.
25
+
26
+ == Examples
27
+
28
+ All Remarkable macros can be accessed in two different ways. For those who prefer the Shoulda style, let’s look at some model tests:
29
+
30
+ describe Post do
31
+ should_belong_to :user
32
+ should_have_many :comments
33
+ should_have_and_belong_to_many :tags
34
+
35
+ should_validate_presence_of :body
36
+ should_validate_presence_of :title
37
+ should_validate_uniqueness_of :title, :allow_blank => true
38
+ end
39
+
40
+ For those who likes more the Rspec way can simply do:
41
+
42
+ describe Post do
43
+ it { should belong_to(:user) }
44
+ it { should have_many(:comments) }
45
+ it { should have_and_belong_to_many(:tags) }
46
+
47
+ it { should validate_presence_of(:body) }
48
+ it { should validate_presence_of(:title) }
49
+ it { should validate_uniqueness_of(:title, :allow_blank => true) }
50
+ end
51
+
52
+ == I18n
53
+
54
+ All matchers come with I18n support. If you want to translate your matchers,
55
+ grab make a copy of locale/en.yml and start to translate it.
56
+
57
+ Then add your new locale file to Remarkable:
58
+
59
+ Remarkable.add_locale 'path/to/my_locale.yml'
60
+
61
+ And then:
62
+
63
+ Remarkable.locale = :my_locale
64
+
65
+ == Using it outside Rails
66
+
67
+ If you want to use Remarkable ActiveRecord outside Rails, you have to remember
68
+ a few things:
69
+
70
+ 1. Internationalization is powered by the I18n gem. If you are using it with Rails,
71
+ it will use the built in gem, otherwise you will have to install the gem by hand:
72
+
73
+ gem sources -a http://gems.github.com
74
+ sudo gem install svenfuchs-i18n
75
+
76
+ 2. Include the matchers. Remarkable Rails gem is the responsable to add
77
+ ActiveRecord matchers to rspec. If you are not using it, you have to do:
78
+
79
+ Remarkable.include_matchers!(Remarkable::ActiveRecord, Spec::Example::ExampleGroup)
80
+
81
+ This will make ActiveRecord matchers available in all rspec example groups.
82
+
@@ -2,6 +2,14 @@ module Remarkable
2
2
  module ActiveRecord
3
3
  class Base < Remarkable::Base
4
4
 
5
+ # Provides a way to send options to all ActiveRecord matchers.
6
+ #
7
+ # validates_presence_of(:name).with_options(:allow_nil => false)
8
+ #
9
+ # Is equivalent to:
10
+ #
11
+ # validates_presence_of(:name, :allow_nil => false)
12
+ #
5
13
  def with_options(opts={})
6
14
  @options.merge!(opts)
7
15
  self
@@ -205,7 +213,7 @@ module Remarkable
205
213
  # Changes how collection are interpolated to provide localized names
206
214
  # whenever is possible.
207
215
  #
208
- def collection_interpolation
216
+ def collection_interpolation #:nodoc:
209
217
  described_class = if @subject
210
218
  subject_class
211
219
  elsif @spec
@@ -1,7 +1,7 @@
1
1
  if defined?(Spec)
2
- module Spec
3
- module Example
4
- module ExampleGroupMethods
2
+ module Spec #:nodoc:
3
+ module Example #:nodoc:
4
+ module ExampleGroupMethods #:nodoc:
5
5
 
6
6
  # This allows "describe User" to use the I18n human name of User.
7
7
  #
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class AllowMassAssignmentOfMatcher < Remarkable::ActiveRecord::Base
4
+ class AllowMassAssignmentOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
5
  arguments :collection => :attributes, :as => :attribute
6
6
 
7
7
  collection_assertions :is_protected?, :is_accessible?
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class AllowValuesForMatcher < Remarkable::ActiveRecord::Base
4
+ class AllowValuesForMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
5
  arguments :collection => :attributes, :as => :attribute
6
6
 
7
7
  optional :message
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class AssociationMatcher < Remarkable::ActiveRecord::Base
4
+ class AssociationMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
5
  arguments :macro, :collection => :associations, :as => :association
6
6
 
7
7
  optionals :through, :class_name, :foreign_key, :dependent, :join_table, :as
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class HaveColumnMatcher < Remarkable::ActiveRecord::Base
4
+ class HaveColumnMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
5
  arguments :collection => :columns, :as => :column
6
6
 
7
7
  optional :type, :default, :precision, :limit, :scale, :sql_type
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class HaveIndexMatcher < Remarkable::ActiveRecord::Base
4
+ class HaveIndexMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
5
  arguments :collection => :columns, :as => :column
6
6
 
7
7
  optional :unique, :default => true
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class HaveReadonlyAttributesMatcher < Remarkable::ActiveRecord::Base
4
+ class HaveReadonlyAttributesMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
5
  arguments :collection => :attributes, :as => :attribute
6
6
  collection_assertions :is_readonly?
7
7
 
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class HaveScopeMatcher < Remarkable::ActiveRecord::Base
4
+ class HaveScopeMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
5
  arguments :scope_name
6
6
  assertions :is_scope?, :options_match?
7
7
 
@@ -1,8 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class ValidateAcceptanceOfMatcher < Remarkable::ActiveRecord::Base
5
-
4
+ class ValidateAcceptanceOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
6
5
  arguments :collection => :attributes, :as => :attribute
7
6
 
8
7
  optional :accept, :message
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class ValidateAssociatedMatcher < Remarkable::ActiveRecord::Base
4
+ class ValidateAssociatedMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
5
  arguments :collection => :associations, :as => :association, :block => :block
6
6
  optional :message, :builder
7
7
 
@@ -1,8 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class ValidateConfirmationOfMatcher < Remarkable::ActiveRecord::Base
5
-
4
+ class ValidateConfirmationOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
6
5
  arguments :collection => :attributes, :as => :attribute
7
6
 
8
7
  optional :message
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'allow_values_for_matcher')
3
3
  module Remarkable
4
4
  module ActiveRecord
5
5
  module Matchers
6
- class ValidateExclusionOfMatcher < AllowValuesForMatcher
6
+ class ValidateExclusionOfMatcher < AllowValuesForMatcher #:nodoc:
7
7
 
8
8
  default_options :message => :exclusion
9
9
 
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'allow_values_for_matcher')
3
3
  module Remarkable
4
4
  module ActiveRecord
5
5
  module Matchers
6
- class ValidateInclusionOfMatcher < AllowValuesForMatcher
6
+ class ValidateInclusionOfMatcher < AllowValuesForMatcher #:nodoc:
7
7
 
8
8
  default_options :message => :inclusion
9
9
 
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class ValidateLengthOfMatcher < Remarkable::ActiveRecord::Base
4
+ class ValidateLengthOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
5
  arguments :collection => :attributes, :as => :attribute
6
6
 
7
7
  optional :within, :alias => :in
@@ -1,8 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class ValidateNumericalityOfMatcher < Remarkable::ActiveRecord::Base
5
-
4
+ class ValidateNumericalityOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
6
5
  arguments :collection => :attributes, :as => :attribute
7
6
 
8
7
  optional :equal_to, :greater_than_or_equal_to, :greater_than,
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class ValidatePresenceOfMatcher < Remarkable::ActiveRecord::Base
4
+ class ValidatePresenceOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
5
  arguments :collection => :attributes, :as => :attribute
6
6
  optional :message
7
7
 
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module ActiveRecord
3
3
  module Matchers
4
- class ValidateUniquenessOfMatcher < Remarkable::ActiveRecord::Base
4
+ class ValidateUniquenessOfMatcher < Remarkable::ActiveRecord::Base #:nodoc:
5
5
  arguments :collection => :attributes, :as => :attribute
6
6
 
7
7
  optional :message
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remarkable_activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Brando
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-04-09 00:00:00 +02:00
14
+ date: 2009-04-10 00:00:00 +02:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,7 @@ dependencies:
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 3.0.0
25
+ version: 3.0.1
26
26
  version:
27
27
  description: "Remarkable ActiveRecord: collection of matchers and macros with I18n for ActiveRecord"
28
28
  email: