Bump Chunker to 1.0.0 (release), updates for rspec 2.

This commit is contained in:
Mahlon E. Smith 2011-01-21 19:41:16 -08:00
parent 935090c21b
commit 6667792230
5 changed files with 94 additions and 93 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env ruby
# vim: set nosta noet ts=4 sw=4 ft=rspec:
BEGIN {
require 'pathname'
@ -8,9 +8,8 @@ BEGIN {
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
}
require 'rspec'
require 'chunker'
require 'rubygems'
require 'spec'
ENDSTUFF = <<ENDSTUFF
Stuff within the end block.
@ -65,53 +64,55 @@ __HURGADURGA__
EO_FILE_TEXT
describe Chunker::DataParser do
describe Chunker 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/
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
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__/
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
describe 'A class that includes Chunker' 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