Skip to content

Commit 3dd76f4

Browse files
committed
Added the tests in
1 parent 9bf3f42 commit 3dd76f4

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

Rakefile

+9
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
require 'bundler'
22
Bundler::GemHelper.install_tasks
3+
4+
require 'rake/testtask'
5+
Rake::TestTask.new(:test) do |test|
6+
test.libs << 'lib' << 'test'
7+
test.pattern = 'test/**/*_test.rb'
8+
test.verbose = true
9+
end
10+
11+
task :default => :test

test/oldstyle.webloc

85 Bytes
Binary file not shown.

test/pliststyle.webloc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>URL</key>
6+
<string>https://github.com/peterc/webloc</string>
7+
</dict>
8+
</plist>

test/webloc_test.rb

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'test/unit'
2+
require 'webloc'
3+
4+
class WeblocTest < Test::Unit::TestCase
5+
def test_webloc_object_requires_url
6+
assert_raise(ArgumentError) { Webloc.new }
7+
end
8+
9+
def test_webloc_object_created_with_url
10+
assert_equal 'http://example.com', Webloc.new('http://example.com').url
11+
end
12+
13+
def test_webloc_object_loaded_from_old_style_file
14+
assert_equal 'https://github.com/peterc/webloc', Webloc.load(File.dirname(__FILE__) + '/oldstyle.webloc').url
15+
end
16+
17+
def test_webloc_object_loaded_from_plist_file
18+
assert_equal 'https://github.com/peterc/webloc', Webloc.load(File.dirname(__FILE__) + '/pliststyle.webloc').url
19+
end
20+
21+
def test_webloc_generates_valid_data
22+
data = File.read(File.dirname(__FILE__) + '/oldstyle.webloc')
23+
data = data.force_encoding('binary') rescue data
24+
assert_equal data, Webloc.new('https://github.com/peterc/webloc').data
25+
end
26+
end

0 commit comments

Comments
 (0)