test/webloc_test.rb in webloc-0.0.1 vs test/webloc_test.rb in webloc-0.1.0

- old
+ new

@@ -1,7 +1,8 @@ require 'test/unit' require 'webloc' +require 'tempfile' class WeblocTest < Test::Unit::TestCase def test_webloc_object_requires_url assert_raise(ArgumentError) { Webloc.new } end @@ -18,9 +19,19 @@ assert_equal 'https://github.com/peterc/webloc', Webloc.load(File.dirname(__FILE__) + '/pliststyle.webloc').url end def test_webloc_generates_valid_data data = File.read(File.dirname(__FILE__) + '/oldstyle.webloc') - data = data.force_encoding('binary') rescue data assert_equal data, Webloc.new('https://github.com/peterc/webloc').data + end + + def test_webloc_can_write_file + file = Tempfile.new('test-webloc') + begin + Webloc.new('https://github.com/peterc/webloc').save(file.path) + assert_equal Webloc.new('https://github.com/peterc/webloc').data, File.read(file.path) + ensure + file.close + file.unlink + end end end \ No newline at end of file