Skip to content

Commit

Permalink
Allow for a trailing x on width-only geometry strings per spec
Browse files Browse the repository at this point in the history
  • Loading branch information
gtd committed Aug 28, 2008
1 parent a74ea92 commit 9056517
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/geometry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize(width=nil, height=nil, x=nil, y=nil, flag=nil)
end

# Construct an object from a geometry string
RE = /\A(\d*)(?:x(\d+))?([-+]\d+)?([-+]\d+)?([%!<>@]?)\Z/
RE = /\A(\d*)(?:x(\d+)?)?([-+]\d+)?([-+]\d+)?([%!<>@]?)\Z/

def self.from_s(str)
raise(ArgumentError, "no geometry string specified") unless str
Expand Down
7 changes: 7 additions & 0 deletions test/geometry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def test_should_resize_no_height
"100" => [100, 128]
end

def test_should_resize_no_height_with_x
assert_geometry 50, 64,
"50x" => [50, 64],
"60x" => [60, 77],
"100x" => [100, 128]
end

def test_should_resize_with_percent
assert_geometry 50, 64,
"50x50%" => [25, 32],
Expand Down

0 comments on commit 9056517

Please sign in to comment.