more tests

parslet
Jordan Orelli 9 years ago
parent 4b785b6034
commit bb0084e198

@ -29,7 +29,7 @@ module Bristlecode
rule(:tag_delim) { tag_open | tag_close }
rule(:text) { (tag_delim.absent? >> any).repeat(1).as(:text) }
rule(:children) { space? >> elem.repeat(1) }
rule(:children) { space? >> elem.repeat }
rule(:doc) { space? >> elem.repeat.as(:doc) }
root(:doc)
end

@ -10,6 +10,10 @@ module Bristlecode
expect(parser).to parse('')
end
it 'can parse whitespace' do
expect(parser).to parse(' ')
end
it 'can parse plain text' do
expect(parser).to parse('this is some plain text')
end
@ -23,6 +27,15 @@ module Bristlecode
expect(parser.bold).to parse('[B]bolded contents here[/B]')
end
it 'can parse an empty bold tag' do
expect(parser.bold).to parse('[b][/b]')
end
it 'can parse nested tags' do
expect(parser.bold).to parse('[b] one [b] two [/b] three [/b]')
expect(parser.bold).to parse('[b] one [i] two [/i] three [/b]')
end
it 'can parse an unclosed tag' do
expect(parser.bold).to parse('[b]bolded contents here')
expect(parser.bold).to parse('[B]bolded contents here')
@ -49,6 +62,15 @@ module Bristlecode
expect(parser.italic).to parse('[I]italiced contents here[/I]')
end
it 'can parse an empty italic tag' do
expect(parser.italic).to parse('[i][/i]')
end
it 'can parse nested tags' do
expect(parser.italic).to parse('[i] one [i] two [/i] three [/i]')
expect(parser.italic).to parse('[i] one [b] two [/b] three [/i]')
end
it 'can parse an unclosed tag' do
expect(parser.italic).to parse('[i]italiced contents here')
expect(parser.italic).to parse('[I]italiced contents here')

Loading…
Cancel
Save