Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor page test

  • Loading branch information...
commit ac2c6124847a21bf67eae436a8c7b993763783d7 1 parent d0be540
Martin authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 test/page_test.rb
10 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
Please sign in to comment.
Something went wrong with that request. Please try again.