Created
January 26, 2009 21:31
-
-
Save haikuwebdev/52976 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Put this in test_helper.rb | |
| class String | |
| def to_node | |
| HTML::Document.new(self).root | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'test_helper' | |
| class MyHelperTest < ActionView::TestCase | |
| test "title" do | |
| assert_select '<h1>My Awesome App</h1>'.to_node, 'h1' | |
| end | |
| test "nav" do | |
| html = '<div id="nav"><a href="/">Home</a></div>' | |
| assert_select html.to_node, 'div' do | |
| assert_select 'a', /home/i | |
| end | |
| end | |
| end | |
| # This is probably a more flexible and elegant solution | |
| # http://github.com/vigetlabs/helper_me_test/tree/master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment