Skip to content
Newer
Older
100644 34 lines (20 sloc) 874 Bytes
1ec6e88 @uhlenbrock First commit
uhlenbrock authored Apr 22, 2008
1 == BodyMatcher
2
3 BodyMatcher simplifies your view testing. Forget assert_select.
4
5 Activate it by including it in your Test::Unit::TestCase class:
6
7 class Test::Unit::TestCase
8 include BodyMatcher
9
10 self.use_transactional_fixtures = true
11 self.use_instantiated_fixtures = false
12 end
13
14 Simple assertions:
15
16 body['#web_results'].should.match /results from the web/i
17
18 body['#categories_dropdown'].should.include "#{topic}[#{count}]"
19
20 Access the attributes:
21
22 body['#name_field'].attributes['value'].should.equal '(your name)'
23 body['#name_field']['value'].should.equal '(your name)'
24
25 You can also use @response.body['blah'].
26
27 The nice part about this is that test failures will print out only
28 the HTML you're trying to match.
29
30 For use with test/spec/rails, which provides the `body' method. Also
31 requires Hpricot. Enjoy.
32
33 * Chris Wanstrath [ chris@ozmm.org ]
Something went wrong with that request. Please try again.