Skip to content

Commit

Permalink
Adding duck typing methods to NodeAttribute#to_s
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyf committed Apr 16, 2012
1 parent a5fa29b commit b29163d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/diaspora-cluster-creator/node_attribute.rb
Expand Up @@ -27,6 +27,10 @@ def value=(new_value)
def to_i
value
end

def to_s
"#{super}#{to_i}"
end
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/diaspora-cluster-creator/node_attribute_spec.rb
Expand Up @@ -6,6 +6,14 @@
let(:node) { Object.new }
let(:attribute) { Object.new }

describe '#to_s' do
it 'should incorporate attribute' do
with_loaded_dice(-4, subject) do
subject.to_s.must_equal "#{attribute}-4"
end
end
end

describe '#to_i' do
it 'should be the value' do
with_loaded_dice(4, subject) do
Expand Down

0 comments on commit b29163d

Please sign in to comment.