Skip to content

Commit

Permalink
Fix a tokenizer problem with dashes in the story description.
Browse files Browse the repository at this point in the history
  • Loading branch information
Manfred committed Jul 4, 2011
1 parent 97aa9ee commit 1067a7a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/saga/tokenizer.rb
Expand Up @@ -59,7 +59,7 @@ def self.tokenize_story_attributes(input)
end

def self.tokenize_story(input)
parts = input.split('-')
parts = input.split(' - ')
if parts.length > 1
story = tokenize_story_attributes(parts[-1])
story[:description] = parts[0..-2].join('-').strip
Expand Down
8 changes: 8 additions & 0 deletions test/saga_parser_spec.rb
Expand Up @@ -124,4 +124,12 @@ def parse_definition
parser.document.definitions['Storage'].length.should == 1
parser.document.definitions['Storage'].first[:title].should == 'Other'
end

it "properly parses hard cases" do
parse_story_marker
parser.parse('As a member I would like the app to keep the information it got from Twitter up-to-date so that changes I make on Twitter get propagated to my listing.')

story = parser.document.stories[''].first
story[:description].should == 'As a member I would like the app to keep the information it got from Twitter up-to-date so that changes I make on Twitter get propagated to my listing.'
end
end
6 changes: 6 additions & 0 deletions test/saga_tokenizer_spec.rb
Expand Up @@ -34,6 +34,12 @@ def each_case(path)
end
end

it "tokenizes hard stories" do
Saga::Tokenizer.tokenize_story('As a member I would like the app to keep the information it got from Twitter up-to-date so that changes I make on Twitter get propagated to my listing.').should == {
:description => 'As a member I would like the app to keep the information it got from Twitter up-to-date so that changes I make on Twitter get propagated to my listing.'
}
end

it "tokenizes definition input" do
each_case('definition') do |input, expected|
Saga::Tokenizer.tokenize_definition(input).should == expected
Expand Down

0 comments on commit 1067a7a

Please sign in to comment.