Skip to content

Commit

Permalink
fix issue with regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Aug 16, 2012
1 parent 7068b82 commit 19d1e58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/guillotine/service.rb
Expand Up @@ -7,7 +7,7 @@ class Options < Struct.new(:required_host, :strip_query, :strip_anchor)
def self.from(value)
case value
when nil, "" then new
when String then new(value)
when String, Regexp then new(value)
when Hash then
opt = new
value.each do |key, value|
Expand Down
8 changes: 8 additions & 0 deletions test/options_test.rb
Expand Up @@ -6,13 +6,21 @@ 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)
Expand Down

0 comments on commit 19d1e58

Please sign in to comment.