Skip to content
Browse files

[BUGFIX] Don't include the terminator in the buffer

  • Loading branch information...
1 parent 6f8971d commit b8cc313810a95c500b7e5128784684d542efa098 @benlangfeld benlangfeld committed Mar 16, 2012
Showing with 8 additions and 3 deletions.
  1. +7 −2 lib/adhearsion/menu_dsl/menu.rb
  2. +1 −1 spec/adhearsion/menu_dsl/menu_spec.rb
View
9 lib/adhearsion/menu_dsl/menu.rb
@@ -20,6 +20,7 @@ def initialize(options = {}, &block)
@limit = options[:limit]
@interruptible = options.has_key?(:interruptible) ? options[:interruptible] : true
@builder = MenuDSL::MenuBuilder.new
+ @terminated = false
@builder.build(&block) if block
@@ -31,7 +32,11 @@ def validate
end
def <<(other)
- digit_buffer << other
+ if other == terminator
+ @terminated = true
+ else
+ digit_buffer << other
+ end
end
def digit_buffer
@@ -50,7 +55,7 @@ def digit_buffer_empty?
def continue
return get_another_digit_or_timeout! if digit_buffer_empty?
- return menu_terminated! if digit_buffer.last == terminator
+ return menu_terminated! if @terminated
return menu_limit_reached! if limit && digit_buffer.size >= limit
calculated_matches = builder.calculate_matches_for digit_buffer_string
View
2 spec/adhearsion/menu_dsl/menu_spec.rb
@@ -285,7 +285,7 @@ class MockControllerC; end
menu_instance.continue.should be_a Menu::MenuTerminated
menu_instance.continue.should be_a Menu::MenuResultDone
menu_instance.status.should be == :terminated
- menu_instance.result.should be == '24#'
+ menu_instance.result.should be == '24'
end
end

0 comments on commit b8cc313

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