Directory structure reorganization.
This commit is contained in:
parent
7e90ac186f
commit
34e5047476
6 changed files with 0 additions and 0 deletions
|
|
@ -1,118 +0,0 @@
|
|||
# vim: set nosta noet ts=4 sw=4 ft=rspec:
|
||||
|
||||
BEGIN {
|
||||
require 'pathname'
|
||||
basedir = Pathname.new( __FILE__ ).dirname.parent
|
||||
libdir = basedir + "lib"
|
||||
|
||||
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
||||
}
|
||||
|
||||
require 'rspec'
|
||||
require 'chunker'
|
||||
|
||||
ENDSTUFF = <<ENDSTUFF
|
||||
Stuff within the end block.
|
||||
|
||||
Content of the END block
|
||||
Content of the END block
|
||||
Content of the END block
|
||||
Content of the END block
|
||||
ENDSTUFF
|
||||
|
||||
HURGADURGA = <<HURGADURGA
|
||||
|
||||
Content of the HURGADURGA block
|
||||
Content of the HURGADURGA block
|
||||
Content of the HURGADURGA block
|
||||
Content of the HURGADURGA block
|
||||
|
||||
HURGADURGA
|
||||
|
||||
HURRRRG = <<HURRRRG
|
||||
123123123 123123123 123123123
|
||||
123123123 123123123 123123123
|
||||
123123123 123123123 123123123
|
||||
HURRRRG
|
||||
|
||||
POOP = <<POOP
|
||||
Content of the POOP block
|
||||
POOP
|
||||
|
||||
FILE_TEXT = <<EO_FILE_TEXT
|
||||
|
||||
This is stuff we shouldn't see or care about.
|
||||
You know, stuff like code, presumably.
|
||||
|
||||
__END__
|
||||
#{ENDSTUFF}
|
||||
EO_FILE_TEXT
|
||||
|
||||
FILE_TEXT_MULTIPLE = <<EO_FILE_TEXT
|
||||
|
||||
This is stuff we shouldn't see or care about.
|
||||
You know, stuff like code, presumably.
|
||||
|
||||
__END__
|
||||
#{ENDSTUFF}
|
||||
__POOP__
|
||||
#{POOP}
|
||||
__HURRRRG__
|
||||
#{HURRRRG}
|
||||
__HURGADURGA__
|
||||
#{HURGADURGA}
|
||||
EO_FILE_TEXT
|
||||
|
||||
|
||||
describe Chunker do
|
||||
|
||||
describe Chunker::DataParser do
|
||||
|
||||
it "doesn't include content above the __END__ token" do
|
||||
klass = Class.new
|
||||
dp = Chunker::DataParser.new( klass, StringIO.new( FILE_TEXT_MULTIPLE ))
|
||||
dp.instance_variable_get( :@scanner ).string.
|
||||
should_not =~ /This is stuff we shouldn't see/
|
||||
end
|
||||
|
||||
it "doesn't contain the __END__ token itself" do
|
||||
klass = Class.new
|
||||
dp = Chunker::DataParser.new( klass, StringIO.new( FILE_TEXT ))
|
||||
dp.instance_variable_get( :@scanner ).string.should_not =~ /^__END__/
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'when included from another class' do
|
||||
|
||||
it "has all content in DATA_END if there are no sub blocks" do
|
||||
File.stub!( :open ).and_return( StringIO.new( FILE_TEXT ))
|
||||
klass = Class.new { include Chunker }
|
||||
|
||||
klass.constants.should_not include( 'DATA_POOP' )
|
||||
klass.constants.should_not include( 'DATA_HURRRRG' )
|
||||
klass.constants.should_not include( 'DATA_HURGADURGA' )
|
||||
klass.constants.should include( 'DATA_END' )
|
||||
end
|
||||
|
||||
it "separates data sub blocks into individual constants" do
|
||||
File.stub!( :open ).and_return( StringIO.new( FILE_TEXT_MULTIPLE ))
|
||||
klass = Class.new { include Chunker }
|
||||
|
||||
klass.constants.should include( 'DATA_END' )
|
||||
klass.constants.should include( 'DATA_POOP' )
|
||||
klass.constants.should include( 'DATA_HURRRRG' )
|
||||
klass.constants.should include( 'DATA_HURGADURGA' )
|
||||
end
|
||||
|
||||
it "has IO constants that contain the data block contents" do
|
||||
File.stub!( :open ).and_return( StringIO.new( FILE_TEXT_MULTIPLE ))
|
||||
klass = Class.new { include Chunker }
|
||||
|
||||
klass.const_get( :DATA_END ).read.chomp.should == ENDSTUFF
|
||||
klass.const_get( :DATA_POOP ).read.chomp.should == POOP
|
||||
klass.const_get( :DATA_HURRRRG ).read.chomp.should == HURRRRG
|
||||
klass.const_get( :DATA_HURGADURGA ).read.chomp.should == HURGADURGA
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue