Permalink
Browse files

Refactor page test

  • Loading branch information...
1 parent d0be540 commit ac2c6124847a21bf67eae436a8c7b993763783d7 @mynyml committed Feb 8, 2010
Showing with 8 additions and 2 deletions.
  1. +8 −2 test/page_test.rb
View
@@ -42,10 +42,10 @@ class PageTest < MiniTest::Unit::TestCase
end
test "fetches remote document" do
- Tempfile.open('testdoc') {|f| f << <<-HTML; @path = f.path }
+ path = tempfile(<<-HTML)
<html><head><title>foo</title></head><body></body></html>
HTML
- page = Page.fetch("file://#{@path}")
+ page = Page.fetch("file://#{path}")
assert_equal 'foo', page.document.title
end
@@ -56,4 +56,10 @@ class PageTest < MiniTest::Unit::TestCase
test "casting to string" do
assert_equal "<html><head><title></title></head><body></body></html>", Page.new.to_s
end
+
+ private
+ def tempfile(content)
+ Tempfile.open('abc') {|f| f << content; @__path = f.path }
+ @__path
+ end
end

0 comments on commit ac2c612

Please sign in to comment.