BT

Your opinion matters! Please fill in the InfoQ Survey!

Rails BDD with Macros, I18n,... with Remarkable

| by Sebastien Auvray Follow 0 Followers on May 04, 2009. Estimated reading time: 1 minute |

A note to our readers: As per your request we have developed a set of features that allow you to reduce the noise, while not losing sight of anything that is important. Get email and web notifications by choosing the topics you are interested in.

There are many ways to develop, test and integrate your Rails application: from TDD with the basic Test::Unit or ZenTest, to BDD with RSpec, Shoulda or Cucumber. It's also possible to write  custom RSpec matchers.

It can be difficult to find the right tool and find out their best practices. Remarkable tries to unify the syntax and adds some more flavors to make Rails BDD painless.

Remarkable is a framework using its own DSL. Remarkable extends RSpec by providing macros and I18n support. It comes with an exhaustive collection of RSpec matchers covering all ActiveRecord validations with all options (:through, :source, :source_type, :class_name, :foreign_key, ...). It also has a collection of matchers for ActionController.

You can use either RSpec or Shoulda-like syntax (from the project website):

    1) it { should validate_numericality_of(:age).greater_than(18).only_integer }

    2) it { should validate_numericality_of(:age, :greater_than => 18, :only_integer => true) }


    3) should_validate_numericality_of :age, :greater_than => 18, :only_integer => true

    4) should_validate_numericality_of :age do |m|
         m.only_integer
         m.greater_than 18
         # Or: m.greater_than = 18

       end

At the end, you will be able to write easily your model specifications: 

  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

Remarkable 3.0.10 is available and quite an active project; Next releases should come up with more Rails matchers such as ActionView supports.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT