diff --git a/lib/saga/tokenizer.rb b/lib/saga/tokenizer.rb index 1b2419b..edd2ba7 100644 --- a/lib/saga/tokenizer.rb +++ b/lib/saga/tokenizer.rb @@ -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 diff --git a/test/saga_parser_spec.rb b/test/saga_parser_spec.rb index cd7ec86..1f4b499 100644 --- a/test/saga_parser_spec.rb +++ b/test/saga_parser_spec.rb @@ -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 \ No newline at end of file diff --git a/test/saga_tokenizer_spec.rb b/test/saga_tokenizer_spec.rb index 5c5fee4..137eb6f 100644 --- a/test/saga_tokenizer_spec.rb +++ b/test/saga_tokenizer_spec.rb @@ -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