Skip to content

Commit

Permalink
Implementation for single digit, test for 2 digits
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonynavarre committed Feb 11, 2012
1 parent 2545cb3 commit 5c4ba6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/string_counter.rb
@@ -1,5 +1,5 @@
class String
def add
0 if empty?
to_i
end
end
12 changes: 9 additions & 3 deletions spec/string_counter/string_counter_spec.rb
Expand Up @@ -11,12 +11,18 @@
context "a string with a single number" do

it "returns the number" do
3.times do |i|
i.to_s.add.should == i
end
'1'.add.should == 1
end
end

context 'when dealing with more than 1 digit' do

it 'returns the sum of its parts' do
'1,2'.add.should == 3
end

end

end
end

0 comments on commit 5c4ba6b

Please sign in to comment.