Created
January 26, 2009 21:31
-
-
Save haikuwebdev/52976 to your computer and use it in GitHub Desktop.
Revisions
-
tjstankus revised this gist
Jan 27, 2009 . 2 changed files with 8 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,12 @@ class MyHelperTest < ActionView::TestCase test "title" do assert_select_in '<h1>My Awesome App</h1>', 'h1' end test "nav" do html = '<div id="nav"><a href="/">Home</a></div>' assert_select_in html, 'div' do assert_select 'a', /home/i 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,10 @@ # Add this to the bottom of your test_helper.rb module HelpersSelectorAsssertions def assert_select_in(html, *args, &block) node = HTML::Document.new(html).root assert_select(*args.unshift(node), &block) end end ActionView::TestCase.send(:include, HelpersSelectorAsssertions) -
tjstankus revised this gist
Jan 26, 2009 . 3 changed files with 12 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +0,0 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -13,5 +13,5 @@ class MyHelperTest < ActionView::TestCase end end # A more flexible and elegant solution can be found here: # http://github.com/vigetlabs/helper_me_test/tree/master 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ # ... ENV, requires, etc. class String def to_node HTML::Document.new(self).root end end class ActiveSupport::TestCase # ... end -
tjstankus revised this gist
Jan 26, 2009 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ 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 -
tjstankus created this gist
Jan 26, 2009 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ # Put this in test_helper.rb class String def to_node HTML::Document.new(self).root end end