require 'maven/model/dependencies'
class A < Maven::Model::Tag
include Maven::Model::Dependencies
end
describe Maven::Model::Dependencies do
before :each do
@a = A.new
end
it 'should have empty dependencies' do
@a.dependencies.empty?.should be_true
@a.to_xml.should == <<-XML
XML
end
it 'should allow gem dependencies with default version' do
@a.gem 'rubyforge'
@a.dependencies.empty?.should be_false
@a.gem?("rubyforge").should be_true
@a.to_xml.should == <<-XML
rubygems
rubyforge
[0,)
gem
XML
end
it 'should allow gem dependencies with version' do
@a.gem 'rubyforge', '> 0.1.0', '<=2.0'
@a.dependencies.empty?.should be_false
@a.gem?("rubyforge").should be_true
@a.to_xml.should == <<-XML
rubygems
rubyforge
(0.1.0,2.0]
gem
XML
end
it 'should allow gem dependencies with exclusions' do
@a.gem 'rubyforge', ['> 0.1.0', '<=2.0'] do |g|
g.exclude "rake"
g.exclude "spork"
end
@a.dependencies.empty?.should be_false
@a.gem?("rubyforge").should be_true
@a.to_xml.should == <<-XML
rubygems
rubyforge
(0.1.0,2.0]
gem
rubygems
rake
rubygems
spork
XML
end
it 'should allow jar dependencies without version' do
@a.jar 'org.jruby', 'jruby-core'
@a.dependencies.empty?.should be_false
@a.jar?("org.jruby:jruby-core").should be_true
@a.to_xml.should == <<-XML
org.jruby
jruby-core
jar
XML
end
it 'should allow jar dependencies with version' do
@a.jar 'org.jruby:jruby-core', '~> 1.6.0'
@a.dependencies.empty?.should be_false
@a.jar?("org.jruby", "jruby-core").should be_true
@a.to_xml.should == <<-XML
org.jruby
jruby-core
[1.6.0,1.6.99999]
jar
XML
end
it 'should allow jar dependencies with exclusions' do
@a.jar 'org.jruby', 'jruby-core', '>1.6.0' do |j|
j.exclusions << "joda:joda-time"
end
@a.dependencies.empty?.should be_false
@a.jar?("org.jruby:jruby-core").should be_true
@a.to_xml.should == <<-XML
org.jruby
jruby-core
(1.6.0,)
jar
joda
joda-time
XML
end
it 'should allow test_jar dependencies with exclusions' do
@a.test_jar 'org.jruby', 'jruby-stdlib', '1.6.0' do |j|
j.exclusions << ["joda", "joda-time"]
j.exclusions << "rubyzip2"
end
@a.dependencies.empty?.should be_false
@a.test_jar?("org.jruby:jruby-stdlib").should be_true
@a.to_xml.should == <<-XML
org.jruby
jruby-stdlib
1.6.0
jar
test
joda
joda-time
rubygems
rubyzip2
XML
end
it 'should allow pom dependencies with exclusions' do
@a.pom 'org.jruby:jruby-stdlib', '>= 1.6.0' do |j|
j.exclusions << ["joda", "joda-time"]
j.exclusions << "rubyzip2"
end
@a.dependencies.empty?.should be_false
@a.jar?("org.jruby:jruby-stdlib").should be_false
@a.pom?("org.jruby:jruby-stdlib").should be_true
@a.to_xml.should == <<-XML
org.jruby
jruby-stdlib
[1.6.0,)
pom
joda
joda-time
rubygems
rubyzip2
XML
end
it 'should have only one instance of jar dependency' do
r1 = @a.jar 'org.jruby:jruby-core', ['1.6.0']
r2 = @a.jar 'org.jruby:jruby-core'
@a.jar?('org.jruby', 'jruby-core').should be_true
@a.dependencies.size.should == 1
r1.should == r2
@a.to_xml.should == <<-XML
org.jruby
jruby-core
1.6.0
jar
XML
end
it 'should have only one instance of gem dependency' do
r1 = @a.gem 'rubyforge', ['> 0.1.0', '<=2.0']
r2 = @a.gem 'rubyforge'
@a.gem?("rubyforge").should be_true
@a.dependencies.size.should == 1
r1.should == r2
@a.to_xml.should == <<-XML
rubygems
rubyforge
(0.1.0,2.0]
gem
XML
end
end