1 require File.dirname(__FILE__) + '/../spec_helper'
4 describe Lyrix::LyricParser do
6 @parser = Lyrix::LyricParser.new("")
9 it "should split slides by blank lines" do
10 @parser.lyrics = <<-LYRICS
11 This is a test of the lyrics
12 Hopefully this will get split up appropriately
14 This text should be on slide 2
17 Here comes slide three
20 @parser.to_slides.size.should == 3
23 it "should allow spaces in blank lines of lyrics" do
24 @parser.lyrics = <<-LYRICS
25 This is a test of the lyrics
26 Hopefully this will get split up appropriately
28 This text should be on slide 2
31 Here comes slide three
34 @parser.to_slides.size.should == 3
37 it "should not include blank slides" do
38 @parser.lyrics = <<-LYRICS
39 This is a test of the lyrics
40 Hopefully this will get split up appropriately
44 This text should be on slide 2
48 Here comes slide three
53 @parser.to_slides.size.should == 3
54 @parser.to_slides.each { |s| s.should_not == "" }
57 it "should substitute a chorus in if given" do
58 @parser.lyrics = <<-LYRICS
59 This is a test of the lyrics
60 Hopefully this will get split up appropriately
63 This text should be on slide 2
66 Here comes slide three
71 @parser.to_slides.size.should == 4
72 @parser.to_slides[3].should == "This text should be on slide 2\nAs should this"
75 it "should substitute a bridge in if given" do
76 @parser.lyrics = <<-LYRICS
77 This is a test of the lyrics
78 Hopefully this will get split up appropriately
81 This text should be on slide 2
84 Here comes slide three
89 @parser.to_slides.size.should == 4
90 @parser.to_slides[3].should == "This text should be on slide 2\nAs should this"
93 it "should substitute a chorus and bridge in if both are given" do
94 @parser.lyrics = <<-LYRICS
95 This is a test of the lyrics
96 Hopefully this will get split up appropriately
99 This text should be on slide 2
103 Here comes slide three
112 @parser.to_slides.size.should == 6
113 @parser.to_slides[3].should == "This text should be on slide 2\nAs should this"
114 @parser.to_slides[1].should == @parser.to_slides[3]
115 @parser.to_slides[2].should == @parser.to_slides[5]
118 it "should repeat whole slides if asked" do
119 @parser.lyrics = <<-LYRICS
120 This is a test of the lyrics
121 Hopefully this will get split up appropriately
124 This text should be on slide 2
128 Here comes slide three
131 @parser.to_slides.size.should == 6
134 it "should repeat single lines if asked" do
135 @parser.lyrics = <<-LYRICS
136 This is a test of the lyrics [2x]
137 Hopefully this will get split up appropriately
139 This text should be on slide 2
142 Here comes slide three
145 @parser.to_slides.size.should == 3
146 @parser.to_slides[0].split("\n").size.should == 3