Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Require an index for remove

  • Loading branch information...
commit 5215e52796b6042daf040ab6a91c8b33ea3f67fc 1 parent eab9d83
Jacob Dunphy authored

Showing 2 changed files with 12 additions and 2 deletions. Show diff stats Hide diff stats

  1. +6 2 lib/qer/todo.rb
  2. +6 0 test/test_qer.rb
8 lib/qer/todo.rb
@@ -24,7 +24,11 @@ def add(item)
24 24 end
25 25
26 26 def remove(index)
27   - if item = self.queue.delete_at(index)
  27 + if index.nil?
  28 + print "Remove must have an index: ex. 'qer remove 3'"
  29 + return
  30 + end
  31 + if item = self.queue.delete_at(index.to_i)
28 32 self.history << [Time.now.to_s, item[0], item[1]]
29 33 write_history
30 34 write
@@ -171,7 +175,7 @@ def command(args)
171 175 when "add", "a"
172 176 self.add(args.join(" ")) # qer add Some task 1
173 177 when "remove", "r"
174   - self.remove(args.shift.to_i) # qer remove 0
  178 + self.remove(args.shift) # qer remove 0
175 179 when "push", "pu"
176 180 self.push(args.join(" ")) # qer push Some task 2
177 181 when "pop", "po"
6 test/test_qer.rb
@@ -195,6 +195,12 @@ def setup
195 195 assert_output "Provided index does not exist."
196 196 end
197 197
  198 + should "not remove anything with nil index" do
  199 + @todo.command(%w(remove))
  200 + assert_output /Remove must have an index:/
  201 + assert_equal 1, @todo.queue.size
  202 + end
  203 +
198 204 should "push" do
199 205 @todo.command(%w(push some stuff))
200 206 assert_equal 2, @todo.queue.size

0 comments on commit 5215e52

Please sign in to comment.
Something went wrong with that request. Please try again.