Custom macros or matchers

14 views
Skip to first unread message

Sukima

unread,
Oct 13, 2010, 9:32:51 AM10/13/10
to shoulda
This question was brushed on a year ago in the context to which syntax
to use. However with the deprecation of macros from the source (ie
preferring the matcher syntax, "should match_matcher") There is little
clue as to creating your own custom phrases. Most documentation
suggests that one would develop a custom macro like so:

should_require_custom_assertions

By putting a should_require_custom_assertions.rb file in the
shoulda_macros directory.

However this is conflict with the natural syntax the current source
uses. For a contrasting example:

should require_custom_assertions

But there is no documentation explaining the syntax of a matcher nor
where to put it nor how to include it.

Unfortunately this builds several problems. It's inconsistent to new
users which confuses them. It also makes it difficult for use because
of the not so intuitive inclusion code in your test_helper.rb:

require 'shoulda_matchers/require_custom_assertions.rb'
...
include Shoulda::CustomAssertions::Matchers
extend Shouda::CustomAssertions::Matchers

Granted those who use RSpec probably never have these issues I
wouldn't know as my projects have been too small for RSpec needs.
Hence why I usually stick with TestCase. Is the mixing of the two
syntax's correct? How do you add custom matchers or should macros be
used regardless of there deprecation in the source?
Reply all
Reply to author
Forward
0 new messages