Skip to content

Commit 45c8aac

Browse files
committed
Make svg comparable
1 parent 2beea69 commit 45c8aac

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

lib/geo_pattern/svg.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module GeoPattern
22
class SVG
3+
include Comparable
4+
35
def initialize
46
@width = 100
57
@height = 100
@@ -67,5 +69,9 @@ def write_args(args)
6769
def self.as_comment(str)
6870
"<!-- #{str} -->"
6971
end
72+
73+
def <=>(other)
74+
to_s <=> other.to_s
75+
end
7076
end
7177
end

spec/spec_helper.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@
1414
# Loading support files
1515
Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
1616
Dir.glob(::File.expand_path('../shared_examples/*.rb', __FILE__)).each { |f| require_relative f }
17+
18+
# No need to add the namespace to every class tested
19+
include GeoPattern

spec/svg_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'spec_helper'
2+
3+
RSpec.describe SVG do
4+
context '#<=>' do
5+
it 'is comparable' do
6+
svg1 = SVG.new
7+
svg2 = SVG.new
8+
9+
expect(svg1).to eq svg2
10+
end
11+
end
12+
end

0 commit comments

Comments
 (0)