= Remarkable ActiveRecord Remarkable ActiveRecord is a collection of matchers to ActiveRecord. Why use Remarkable? * The only one with matchers for all ActiveRecord validations, with support to all options; * Matchers for all ActiveRecord associations. The only one which supports all these options: :through, :class_name, :foreign_key, :dependent, :join_table, :uniq, :readonly, :validate, :autosave, :counter_cache, :polymorphic Besides in Remarkable 3.0 matchers became much smarter. Whenever :join_table or :through is given as option, it checks if the given table exists. Whenever :foreign_key or :counter_cache is given, it checks if the given column exists; * Tests and more tests. We have a huge tests suite ready to run and tested in ActiveRecord 2.1.2, 2.2.2 and 2.3.2; * Great documentation; * I18n. == Examples All Remarkable macros can be accessed in two different ways. For those who prefer the Shoulda style, let’s look at some model tests: describe Post do should_belong_to :user should_have_many :comments should_have_and_belong_to_many :tags should_validate_presence_of :body should_validate_presence_of :title should_validate_uniqueness_of :title, :allow_blank => true end For those who likes more the Rspec way can simply do: describe Post do it { should belong_to(:user) } it { should have_many(:comments) } it { should have_and_belong_to_many(:tags) } it { should validate_presence_of(:body) } it { should validate_presence_of(:title) } it { should validate_uniqueness_of(:title, :allow_blank => true) } end == I18n All matchers come with I18n support. If you want to translate your matchers, grab make a copy of locale/en.yml and start to translate it. Then add your new locale file to Remarkable: Remarkable.add_locale 'path/to/my_locale.yml' And then: Remarkable.locale = :my_locale == Using it outside Rails If you want to use Remarkable ActiveRecord outside Rails, you have to remember a few things: 1. Internationalization is powered by the I18n gem. If you are using it with Rails, it will use the built in gem, otherwise you will have to install the gem by hand: gem sources -a http://gems.github.com sudo gem install svenfuchs-i18n 2. Include the matchers. Remarkable Rails gem is the responsable to add ActiveRecord matchers to rspec. If you are not using it, you have to do: Remarkable.include_matchers!(Remarkable::ActiveRecord, Spec::Example::ExampleGroup) This will make ActiveRecord matchers available in all rspec example groups.