Module: Matchbox
- Included in:
- Test::Unit::TestCase
- Defined in:
- lib/matchbox.rb,
lib/matchbox/version.rb
Overview
Test::Unit assertions for RSpec and Shoulda matchers.
I created this since:
- I like assertions, not the Shoulda "should" statements.
- I want to use shoulda-matchers in my Rails project.
- I'm in love with the simplicity of the contest gem.
These methods are based upon those found in shoulda-context.
With shoulda-matchers, it can be used like so:
class PostTest < Test::Unit::TestCase
def test_active_record_relations
post = Post.new
assert_accepts belong_to(:topic), post
end
end
Constant Summary collapse
- VERSION =
'1.0.2'
Instance Method Summary collapse
-
#assert_accepts(matcher, target)
Asserts that a matcher matches a given target.
-
#assert_rejects(matcher, target)
Asserts that a matcher does not match a given target.
Instance Method Details
#assert_accepts(matcher, target)
Asserts that a matcher matches a given target.
25 26 27 28 29 30 |
# File 'lib/matchbox.rb', line 25 def assert_accepts(matcher, target) matched = matcher.matches?(target) = matcher. ? assert(matched, ) : assert(matched) end |
#assert_rejects(matcher, target)
Asserts that a matcher does not match a given target.
37 38 39 40 41 42 |
# File 'lib/matchbox.rb', line 37 def assert_rejects(matcher, target) matched = matcher.matches?(target) = matcher. ? assert(!matched, ) : assert(!matched) end |