Browse files

Fix deleting an item from a list with the same name

  • Loading branch information...
1 parent c13fe05 commit 5a384dd9343a2c43e43a81638e8149df597a87be @eugeneius eugeneius committed Jan 8, 2012
Showing with 12 additions and 2 deletions.
  1. +2 −2 lib/boom/command.rb
  2. +10 −0 test/test_command.rb
View
4 lib/boom/command.rb
@@ -108,12 +108,12 @@ def delegate(command, major, minor)
end
end
- return search_items(command) if storage.item_exists?(command)
-
if minor == 'delete' and storage.item_exists?(major)
return delete_item(command, major)
end
+ return search_items(command) if storage.item_exists?(command)
+
return create_list(command, major, stdin.read) if !minor && stdin.stat.size > 0
return create_list(command, major, minor)
end
View
10 test/test_command.rb
@@ -220,4 +220,14 @@ def test_delete_item_wrong_list
assert_match /github not found in urlz/, command('urlz github delete')
end
+ def test_delete_item_different_name
+ command('foo bar baz')
+ assert_match /bar is gone forever/, command('foo bar delete')
+ end
+
+ def test_delete_item_same_name
+ command('duck duck goose')
+ assert_match /duck is gone forever/, command('duck duck delete')
+ end
+
end

0 comments on commit 5a384dd

Please sign in to comment.