Skip to content

Commit

Permalink
fix font switch
Browse files Browse the repository at this point in the history
  • Loading branch information
dj2 committed Feb 21, 2011
1 parent 2bcb1de commit 772c28e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions spec/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@

describe RubyRTF::Parser do
it 'parses hello world' do
src = '{\rtf1\ansi\deff0 {\fonttbl {\f0 Times New Roman;}}\f \fs60 Hello, World!}'
src = '{\rtf1\ansi\deff0 {\fonttbl {\f0 Times New Roman;}}\f0 \fs60 Hello, World!}'
lambda { RubyRTF::Parser.parse(src) }.should_not raise_error
end

it 'returns a RTF::Document' do
src = '{\rtf1\ansi\deff0 {\fonttbl {\f0 Times New Roman;}}\f \fs60 Hello, World!}'
src = '{\rtf1\ansi\deff0 {\fonttbl {\f0 Times New Roman;}}\f0 \fs60 Hello, World!}'
doc = RubyRTF::Parser.parse(src)
doc.is_a?(RubyRTF::Document).should be_true
end

it 'parses a default font (\deffN)' do
src = '{\rtf1\ansi\deff10 {\fonttbl {\f10 Times New Roman;}}\f \fs60 Hello, World!}'
src = '{\rtf1\ansi\deff10 {\fonttbl {\f10 Times New Roman;}}\f0 \fs60 Hello, World!}'
doc = RubyRTF::Parser.parse(src)
doc.default_font.should == 10
end

context 'invalid document' do
it 'raises exception if \rtf is missing' do
src = '{\ansi\deff0 {\fonttbl {\f0 Times New Roman;}}\f \fs60 Hello, World!}'
src = '{\ansi\deff0 {\fonttbl {\f0 Times New Roman;}}\f0 \fs60 Hello, World!}'
lambda { RubyRTF::Parser.parse(src) }.should raise_error(RubyRTF::InvalidDocument)
end

it 'raises exception if the document does not start with \rtf' do
src = '{\ansi\deff0\rtf1 {\fonttbl {\f0 Times New Roman;}}\f \fs60 Hello, World!}'
src = '{\ansi\deff0\rtf1 {\fonttbl {\f0 Times New Roman;}}\f0 \fs60 Hello, World!}'
lambda { RubyRTF::Parser.parse(src) }.should raise_error(RubyRTF::InvalidDocument)
end

it 'raises exception if the {}s are unbalanced' do
src = '{\rtf1\ansi\deff0 {\fonttbl {\f0 Times New Roman;}\f \fs60 Hello, World!}'
src = '{\rtf1\ansi\deff0 {\fonttbl {\f0 Times New Roman;}\f0 \fs60 Hello, World!}'
lambda { RubyRTF::Parser.parse(src) }.should raise_error(RubyRTF::InvalidDocument)
end
end
Expand Down

0 comments on commit 772c28e

Please sign in to comment.