63 __HURGADURGA__ |
62 __HURGADURGA__ |
64 #{HURGADURGA} |
63 #{HURGADURGA} |
65 EO_FILE_TEXT |
64 EO_FILE_TEXT |
66 |
65 |
67 |
66 |
68 describe Chunker::DataParser do |
67 describe Chunker do |
69 |
68 |
70 it "doesn't include content above the __END__ token" do |
69 describe Chunker::DataParser do |
71 klass = Class.new |
70 |
72 dp = Chunker::DataParser.new( klass, StringIO.new( FILE_TEXT_MULTIPLE )) |
71 it "doesn't include content above the __END__ token" do |
73 dp.instance_variable_get( :@scanner ).string. |
72 klass = Class.new |
74 should_not =~ /This is stuff we shouldn't see/ |
73 dp = Chunker::DataParser.new( klass, StringIO.new( FILE_TEXT_MULTIPLE )) |
|
74 dp.instance_variable_get( :@scanner ).string. |
|
75 should_not =~ /This is stuff we shouldn't see/ |
|
76 end |
|
77 |
|
78 it "doesn't contain the __END__ token itself" do |
|
79 klass = Class.new |
|
80 dp = Chunker::DataParser.new( klass, StringIO.new( FILE_TEXT )) |
|
81 dp.instance_variable_get( :@scanner ).string.should_not =~ /^__END__/ |
|
82 end |
75 end |
83 end |
76 |
84 |
77 it "doesn't contain the __END__ token itself" do |
85 |
78 klass = Class.new |
86 context 'when included from another class' do |
79 dp = Chunker::DataParser.new( klass, StringIO.new( FILE_TEXT )) |
87 |
80 dp.instance_variable_get( :@scanner ).string.should_not =~ /^__END__/ |
88 it "has all content in DATA_END if there are no sub blocks" do |
|
89 File.stub!( :open ).and_return( StringIO.new( FILE_TEXT )) |
|
90 klass = Class.new { include Chunker } |
|
91 |
|
92 klass.constants.should_not include( 'DATA_POOP' ) |
|
93 klass.constants.should_not include( 'DATA_HURRRRG' ) |
|
94 klass.constants.should_not include( 'DATA_HURGADURGA' ) |
|
95 klass.constants.should include( 'DATA_END' ) |
|
96 end |
|
97 |
|
98 it "separates data sub blocks into individual constants" do |
|
99 File.stub!( :open ).and_return( StringIO.new( FILE_TEXT_MULTIPLE )) |
|
100 klass = Class.new { include Chunker } |
|
101 |
|
102 klass.constants.should include( 'DATA_END' ) |
|
103 klass.constants.should include( 'DATA_POOP' ) |
|
104 klass.constants.should include( 'DATA_HURRRRG' ) |
|
105 klass.constants.should include( 'DATA_HURGADURGA' ) |
|
106 end |
|
107 |
|
108 it "has IO constants that contain the data block contents" do |
|
109 File.stub!( :open ).and_return( StringIO.new( FILE_TEXT_MULTIPLE )) |
|
110 klass = Class.new { include Chunker } |
|
111 |
|
112 klass.const_get( :DATA_END ).read.chomp.should == ENDSTUFF |
|
113 klass.const_get( :DATA_POOP ).read.chomp.should == POOP |
|
114 klass.const_get( :DATA_HURRRRG ).read.chomp.should == HURRRRG |
|
115 klass.const_get( :DATA_HURGADURGA ).read.chomp.should == HURGADURGA |
|
116 end |
81 end |
117 end |
82 end |
118 end |
83 |
|
84 |
|
85 describe 'A class that includes Chunker' do |
|
86 |
|
87 it "has all content in DATA_END if there are no sub blocks" do |
|
88 File.stub!( :open ).and_return( StringIO.new( FILE_TEXT )) |
|
89 klass = Class.new { include Chunker } |
|
90 |
|
91 klass.constants.should_not include( 'DATA_POOP' ) |
|
92 klass.constants.should_not include( 'DATA_HURRRRG' ) |
|
93 klass.constants.should_not include( 'DATA_HURGADURGA' ) |
|
94 klass.constants.should include( 'DATA_END' ) |
|
95 end |
|
96 |
|
97 it "separates data sub blocks into individual constants" do |
|
98 File.stub!( :open ).and_return( StringIO.new( FILE_TEXT_MULTIPLE )) |
|
99 klass = Class.new { include Chunker } |
|
100 |
|
101 klass.constants.should include( 'DATA_END' ) |
|
102 klass.constants.should include( 'DATA_POOP' ) |
|
103 klass.constants.should include( 'DATA_HURRRRG' ) |
|
104 klass.constants.should include( 'DATA_HURGADURGA' ) |
|
105 end |
|
106 |
|
107 it "has IO constants that contain the data block contents" do |
|
108 File.stub!( :open ).and_return( StringIO.new( FILE_TEXT_MULTIPLE )) |
|
109 klass = Class.new { include Chunker } |
|
110 |
|
111 klass.const_get( :DATA_END ).read.chomp.should == ENDSTUFF |
|
112 klass.const_get( :DATA_POOP ).read.chomp.should == POOP |
|
113 klass.const_get( :DATA_HURRRRG ).read.chomp.should == HURRRRG |
|
114 klass.const_get( :DATA_HURGADURGA ).read.chomp.should == HURGADURGA |
|
115 end |
|
116 end |
|
117 |
|