Skip to content

Commit

Permalink
[BUGFIX] Don't include the terminator in the buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
benlangfeld committed Mar 16, 2012
1 parent 6f8971d commit b8cc313
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/adhearsion/menu_dsl/menu.rb
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/adhearsion/menu_dsl/menu_spec.rb
Expand Up @@ -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

Expand Down

0 comments on commit b8cc313

Please sign in to comment.