1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Bundling DSL" do
it "allows specifying the path to bundle gems to" do
build_manifest.gem_path.should == tmp_file("vendor", "gems")
end
it "allows specifying sources" do
manifest = build_manifest <<-DSL
source "http://gems.github.com"
DSL
manifest.sources.first.should == URI.parse("http://gems.rubyforge.org")
manifest.sources.last.should == URI.parse("http://gems.github.com")
end
it "allows specifying gems" do
manifest = build_manifest <<-DSL
gem "rails"
DSL
manifest.dependencies.first.name.should == "rails"
end
it "allows specifying gem versions" do
manifest = build_manifest <<-DSL
gem "rails", ">= 2.0.0"
DSL
manifest.dependencies.first.version.should == ">= 2.0.0"
end
it "allows specifying how to require the gem" do
manifest = build_manifest <<-DSL
gem "actionpack", :require_as => "action_controller"
DSL
manifest.dependencies.first.require_as.should == ["action_controller"]
end
it "allows specifying 'only' restrictions on the environment" do
manifest = build_manifest <<-DSL
gem "ruby-debug", :only => "development"
DSL
manifest.dependencies.first.only.should == ["development"]
end
it "allows specifying 'except' restrictions on the environment" do
manifest = build_manifest <<-DSL
gem "newrelic_rpm", :except => "staging"
DSL
manifest.dependencies.first.except.should == ["staging"]
end
it "loads the manifest from a file" do
manifest = build_manifest(tmp_file("manifest.rb"), <<-DSL)
gem "rails"
DSL
manifest.dependencies.first.name.should == "rails"
end
it "allows specifying an arbitrary number of sources and gems" do
manifest = build_manifest <<-DSL
gem "thor"
source "http://gems.github.com"
gem "wycats-merb-core"
gem "mislav-will_paginate"
source "http://gems.example.org"
gem "uuidtools"
DSL
manifest.sources.should == [
URI.parse("http://gems.rubyforge.org"),
URI.parse("http://gems.github.com"),
URI.parse("http://gems.example.org")
]
manifest.dependencies.map { |d| d.name }.should == %w(
thor
wycats-merb-core
mislav-will_paginate
uuidtools
)
end
it "can bundle gems in a manifest defined through the DSL" do
manifest = build_manifest <<-DSL
sources.clear
source "file://#{gem_repo1}"
source "file://#{gem_repo2}"
gem "merb-core", "= 1.0.12"
gem "activerecord", "> 2.2"
DSL
gems = %w(
abstract-1.0.0 activerecord-2.3.2 activesupport-2.3.2 erubis-2.6.4
extlib-0.9.12 json_pure-1.1.7 merb-core-1.0.12 mime-types-1.16
rack-1.0.0 rake-0.8.7 rspec-1.2.8 thor-0.9.9)
manifest.install
tmp_gem_path.should have_cached_gems(*gems)
tmp_gem_path.should have_installed_gems(*gems)
load_paths = {}
gems.each { |g| load_paths[g] = %w(bin lib) }
tmp_gem_path('environments', 'default.rb').should have_load_paths(tmp_gem_path, load_paths)
end
it "outputs a pretty error when an environment is named rubygems" do
lambda do
build_manifest <<-DSL
sources.clear
gem "extlib", :only => "rubygems"
DSL
end.should raise_error(Bundler::InvalidEnvironmentName)
end
end
|