forked from technoweenie/guillotine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions_test.rb
59 lines (50 loc) · 1.51 KB
/
options_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require File.expand_path('../helper', __FILE__)
module Guillotine
class OptionsTest < TestCase
def test_parses_from_options
options = Service::Options.new
assert_equal options.object_id, Service::Options.from(options).object_id
end
def test_parses_from_string
options = Service::Options.from('abc')
assert_equal 'abc', options.required_host
assert options.strip_query?
assert options.strip_anchor?
end
def test_parses_from_regex
options = Service::Options.from(/abc/)
assert_equal /abc/, options.required_host
assert options.strip_query?
assert options.strip_anchor?
end
def test_parses_from_hash
options = Service::Options.from(:strip_query => true,
:strip_anchor => false)
assert_nil options.required_host
assert options.strip_query?
assert !options.strip_anchor?
end
def test_parses_from_bad_hash
assert_raises NameError do
Service::Options.from :foo => 1
end
end
def test_parses_from_unknown
assert_raises ArgumentError do
Service::Options.from 123
end
end
def test_parses_from_empty_string
options = Service::Options.from('')
assert_nil options.required_host
assert options.strip_query?
assert options.strip_anchor?
end
def test_parses_from_nil
options = Service::Options.from(nil)
assert_nil options.required_host
assert options.strip_query?
assert options.strip_anchor?
end
end
end