spec/sprinkle/package_spec.rb in sprinkle-0.1.4 vs spec/sprinkle/package_spec.rb in sprinkle-0.1.5
- old
+ new
@@ -6,10 +6,28 @@
before do
@name = :package_name
@empty = Proc.new { }
@opts = { }
end
+
+ # Kind of a messy way to do this but it works and DRYs out
+ # the specs. Checks to make sure an installer is receiving
+ # the block passed to it throught the package block.
+ def check_block_forwarding_on(installer)
+ eval(<<CODE)
+ pre_count = 0
+ lambda {
+ pkg = package @name do
+ #{installer} 'archive' do
+ pre :install, 'preOp'
+ end
+ end
+
+ pre_count = pkg.installer.instance_variable_get(:@pre)[:install].length
+ }.should change { pre_count }.by(1)
+CODE
+ end
describe 'when created' do
it 'should be invalid without a block descriptor' do
lambda { package @name }.should raise_error
@@ -124,26 +142,46 @@
source 'archive' do; end
end
pkg.should respond_to(:source)
pkg.installer.class.should == Sprinkle::Installers::Source
end
+
+ it 'should forward block to installer superclass' do
+ check_block_forwarding_on(:source)
+ end
it 'should automatically add a build essential recommendation' do
pkg = package @name do
source 'archive'
end
pkg.recommends.should include(:build_essential)
end
end
+
+ describe 'with an apt installer' do
+ it 'should forward block to installer superclass' do
+ check_block_forwarding_on(:apt)
+ end
+ end
+
+ describe 'with an rpm installer' do
+ it 'should forward block to installer superclass' do
+ check_block_forwarding_on(:rpm)
+ end
+ end
describe 'with an gem installer' do
it 'should automatically add a rubygems recommendation' do
pkg = package @name do
gem 'gem'
end
pkg.recommends.should include(:rubygems)
+ end
+
+ it 'should forward block to installer superclass' do
+ check_block_forwarding_on(:gem)
end
end
describe 'when processing' do