spec/warbler/task_spec.rb in warbler-1.0.2 vs spec/warbler/task_spec.rb in warbler-1.0.3
- old
+ new
@@ -26,11 +26,12 @@
after(:each) do
Rake::Task["warble:clean"].invoke
rm_rf "log"
rm_f FileList["config.ru", "*web.xml", "config/web.xml*", "config/warble.rb",
- "tmp/gems.jar", "file.txt", 'manifest', 'Gemfile']
+ "config/special.txt", "config/link.txt", "tmp/gems.jar",
+ "file.txt", 'Gemfile', 'lib/rakelib']
Dir.chdir(@pwd)
end
it "should define a clean task for removing the war file" do
war_file = "#{@config.war_name}.war"
@@ -61,9 +62,41 @@
File.exist?("#{@config.war_name}.war").should == true
end
it "should be able to define all tasks successfully" do
Warbler::Task.new "warble", @config
+ end
+
+ it "should process symlinks by storing a file in the archive that has the same contents as the source" do
+ File.open("config/special.txt", "wb") {|f| f << "special"}
+ Dir.chdir("config") { ln_s "special.txt", "link.txt" }
+ silence { Rake::Task["warble"].invoke }
+ Zip::ZipFile.open("#{@config.war_name}.war") do |zf|
+ special = zf.get_input_stream('WEB-INF/config/special.txt') {|io| io.read }
+ link = zf.get_input_stream('WEB-INF/config/link.txt') {|io| io.read }
+ link.should == special
+ end
+ end
+
+ it "should process directory symlinks by copying the whole subdirectory" do
+ Dir.chdir("lib") { ln_s "tasks", "rakelib" }
+ silence { Rake::Task["warble"].invoke }
+ Zip::ZipFile.open("#{@config.war_name}.war") do |zf|
+ zf.find_entry("WEB-INF/lib/tasks/utils.rake").should_not be_nil
+ zf.find_entry("WEB-INF/lib/rakelib/").should_not be_nil
+ zf.find_entry("WEB-INF/lib/rakelib/utils.rake").should_not be_nil if defined?(JRUBY_VERSION)
+ end
+ end
+
+ it "should use a Bundler Gemfile to include gems" do
+ File.open("Gemfile", "w") {|f| f << "gem 'rspec'"}
+ @config.bundler = true
+ @config.send(:detect_bundler_gems)
+ silence { Rake::Task["warble"].invoke }
+ Zip::ZipFile.open("#{@config.war_name}.war") do |zf|
+ rspec_version = @config.gems.keys.detect {|k| k.name == 'rspec'}.version
+ zf.find_entry("WEB-INF/gems/specifications/rspec-#{rspec_version}.gemspec").should_not be_nil
+ end
end
end
describe "Debug targets" do
before(:each) do