= Remarkable ActiveModel Remarkable ActiveModel is a collection of matchers to ActiveModel. Why use Remarkable? * Matchers for all ActiveModel validations, with support to all options. The only exceptions are validate_format_of (which should be invoked as allow_values_for) and the :on option; This means you can test your validations any model that mixes-in ActiveModel::Validations * Tests and more tests. We have a huge tests suite ready to run and tested in ActiveModel 3.0.0; * Great documentation; * I18n. Upcoming features: * Matchers wrapping ActiveModel::Lint for testing ActiveModel API compliance. This means your custom models using RESTClient, for example, can play nice with Rails. * Matchers testing ActiveModel::Serialization This allows you to test for compliance if you are using special serialization methods, or require the use of Presenters in your application. == Installation sudo gem install remarkable_activemodel --pre Add this to your Gemfile: group :test do gem 'remarkable_activemodel', '>=4.0.0.alpha2' end Drop this into your spec/spec_helper.rb or spec/support/remarkable.rb file: require 'remarkable/active_model' == 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_validate_presence_of :body should_validate_presence_of :title end For those who likes more the Rspec way can simply do: describe Post do it { should validate_presence_of(:body) } it { should validate_presence_of(:title) } 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 ActiveModel 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 install i18n 2. Include the matchers. Remarkable Rails gem is the responsable to add ActiveModel matchers to rspec. If you are not using it, you have to do: Remarkable.include_matchers!(Remarkable::ActiveModel, Rspec::Core::ExampleGroup) This will make ActiveModel matchers available in all rspec example groups.