bundler_ext 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +50 -52
- data/lib/bundler_ext.rb +36 -1
- data/lib/bundler_ext/gemfile.rb +50 -0
- data/lib/bundler_ext/output.rb +16 -0
- data/lib/bundler_ext/runtime.rb +66 -0
- data/lib/bundler_ext/setup.rb +2 -0
- data/lib/bundler_ext/system.rb +61 -0
- data/lib/bundler_ext/version.rb +1 -1
- data/spec/bundler_ext/bundler_ext_spec.rb +80 -128
- data/spec/bundler_ext/gemfile_spec.rb +191 -0
- data/spec/bundler_ext/integration_spec.rb +146 -0
- data/spec/bundler_ext/runtime_spec.rb +178 -0
- data/spec/bundler_ext/system_spec.rb +138 -0
- data/spec/spec_helper.rb +1 -1
- metadata +21 -8
- data/lib/bundler_ext/bundler_ext.rb +0 -100
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 909210bc887e62015bf713baa415cd3570274817
|
4
|
+
data.tar.gz: 8b4e28226559a24052a0d0b8b4ad372d9beede2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0595bc52ef0163d7517c185775696ebdb65e1baa056ec0ae1b4bb99690f3cd3f4231729558d94d75ffa53fc309f64370d9cdbfb3dac869ec0b8057e2acbf6e8
|
7
|
+
data.tar.gz: 471f6ed58e11b9aa49c025a62ff14bb48ac8797a32ce61079960cf7c75fab2a037665549d96909ce7ed5984aa841e62a12f081fea0c7f5b2c0fecef3d44f23a2
|
data/README.md
CHANGED
@@ -2,75 +2,73 @@ bundler_ext
|
|
2
2
|
===========
|
3
3
|
|
4
4
|
Simple library leveraging the Bundler Gemfile DSL to load gems already
|
5
|
-
on the system and managed by the systems package manager
|
6
|
-
(like yum/apt).
|
5
|
+
on the system and those managed by the systems package manager
|
6
|
+
(like yum/apt/homebrew/other).
|
7
7
|
|
8
|
-
|
9
|
-
manage the dependencies for a project, and simply reuse the Gemfile
|
10
|
-
to get the list of directly required gems for (in initial use case) a
|
11
|
-
Rails 3.x application. It would be useful in such cases for there to
|
12
|
-
be a big switch in Bundler that would allow the user to tell it 'You
|
13
|
-
are allevaiated of the responsibility of resolving dependencies, that
|
14
|
-
has been taken care of for you. Understandably, since Bundler's
|
15
|
-
primary goal is exactly to resolve those dependencies, that project
|
16
|
-
has to date not been interested in supporting such functionality.
|
17
|
-
However, this is the use case for many linux systems, and this library
|
18
|
-
is an initial attempt to get the two approaches to not step on each
|
19
|
-
other.
|
8
|
+
### API ###
|
20
9
|
|
21
|
-
|
10
|
+
- BundlerExt#system_require is analogous to
|
11
|
+
[Bundler#require](http://rubydoc.info/github/bundler/bundler/Bundler#require-class_method)
|
12
|
+
and will auto-require the gems loaded in the Gemfile wherever they
|
13
|
+
are installed / can be found.
|
14
|
+
|
15
|
+
|
16
|
+
- BundlerExt#system_setup is analogous to
|
17
|
+
[Bundler#setup](http://bundler.io/v1.5/bundler_setup.html)
|
18
|
+
and will setup the Ruby LOAD_PATH to only incorporate the gemfile
|
19
|
+
dependency include paths wherever they are installed.
|
20
|
+
|
22
21
|
|
23
|
-
If
|
22
|
+
- If either case if the BEXT_ACTIVATE_VERSIONS env var is set true,
|
23
|
+
the specific versions of the gem installed via yum/apt/other will be
|
24
|
+
detected and activated.
|
24
25
|
|
25
|
-
|
26
|
+
- Specify the BEXT_GROUPS env var to insert additional groups to be loaded
|
27
|
+
(separated by whitespace, eg BEXT_GROUPS='group1 group2 ...')
|
26
28
|
|
27
|
-
|
29
|
+
- Specify BEXT_NOSTRICT to disable fail-on-error, otherwise BundlerExt will
|
30
|
+
raise a critical error if a dependency fails to load. If set true, BundlerExt
|
31
|
+
will simply print the msg to stdout and continue on.
|
28
32
|
|
29
|
-
|
33
|
+
### Show Me The Code! ##
|
30
34
|
|
31
|
-
|
32
|
-
of course. Finally, you will be likely requiring default group and
|
33
|
-
group named as the current Rails environment; use this:
|
34
|
-
|
35
|
-
BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :default, Rails.env)
|
35
|
+
Assuming gemfile_in is defined as
|
36
36
|
|
37
|
-
|
38
|
-
non-platform users (ie, mac, or any developer not installing as a
|
39
|
-
sysadmin) to still use bundler if they want to. One example would be
|
40
|
-
to simply change the name of the Gemfile for rpm setups, something
|
41
|
-
like:
|
37
|
+
gemfile_in = File.expand_path('../../Gemfile.in', __FILE__)
|
42
38
|
|
43
|
-
|
39
|
+
To load & require ALL Gemfile groups, use the following statement:
|
40
|
+
|
41
|
+
BundlerExt.system_require(gemfile_in, :all)
|
44
42
|
|
45
|
-
|
46
|
-
Gemfile.in/BundlerExt.
|
43
|
+
To load only the default one, use:
|
47
44
|
|
48
|
-
|
49
|
-
Some libraries, like Rspec, Cucumber, and Rails, try to be smart and
|
50
|
-
load up dependencies via Bundler themselves if they see a Gemfile in
|
51
|
-
the working directory. In some cases this can be overriden, but not
|
52
|
-
all, so for now at least, it is safer to just look for a different
|
53
|
-
file (and this is easily scripted as well) In the linux deployment
|
54
|
-
case, this is not the desired behavior, we explicitly want to say
|
55
|
-
'just use what the package manager has installed'.
|
45
|
+
BundlerExt.system_require(gemfile_in, :default)
|
56
46
|
|
57
|
-
|
47
|
+
BundlerExt#system_require function takes a list of parameters corresponding to all the
|
48
|
+
environments the invoker intends to use.
|
49
|
+
|
50
|
+
To require the default group and the group specified
|
51
|
+
by the Rails environment, use:
|
52
|
+
|
53
|
+
BundlerExt.system_require(gemfile_in, :default, Rails.env)
|
58
54
|
|
59
|
-
|
60
|
-
insert additional groups to be required, e.g. when developing and you
|
61
|
-
want to restart the system in development mode once. Use
|
62
|
-
BEXT_GROUPS variable (separate with whitespace):
|
55
|
+
To setup the LOAD_PATH to only reference the default Gemfile deps:
|
63
56
|
|
64
|
-
|
57
|
+
BundlerExt.system_setup(gemfile_in, :default)
|
65
58
|
|
66
|
-
|
67
|
-
be loaded. You can turn off this behavior (e.g. for installers when
|
68
|
-
you want to do rake db:migrate) with setting BEXT_NOSTRICT:
|
59
|
+
And so on....
|
69
60
|
|
70
|
-
|
61
|
+
### Other Considerations ###
|
62
|
+
|
63
|
+
You may want to wrap your call in some kind of check, to allow
|
64
|
+
non-platform users to still use bundler if they want to.
|
65
|
+
|
66
|
+
One way to accomplish this would be to simply change the name of
|
67
|
+
the Gemfile for native package system scenarios, eg
|
68
|
+
|
69
|
+
mv Gemfile Gemfile.in
|
71
70
|
|
72
|
-
|
73
|
-
but does not terminate the process.
|
71
|
+
Then, just look for a Gemfile, otherwise, load deps via Gemfile.in/BundlerExt.
|
74
72
|
|
75
73
|
Some rubygems require HOME environment variable to be set, threfore
|
76
74
|
not running daemonized. For this purposes there is BEXT_HOME
|
data/lib/bundler_ext.rb
CHANGED
@@ -1 +1,36 @@
|
|
1
|
-
require '
|
1
|
+
require 'pathname'
|
2
|
+
require 'bundler_ext/runtime'
|
3
|
+
require 'bundler_ext/gemfile'
|
4
|
+
require 'bundler_ext/system'
|
5
|
+
|
6
|
+
module BundlerExt
|
7
|
+
def self.runtime
|
8
|
+
@runtime ||= BundlerExt::Runtime.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.system_require(gemfile, *groups)
|
12
|
+
runtime.setup_env
|
13
|
+
|
14
|
+
Gemfile.parse(gemfile, *groups).each do |name, gem_dep|
|
15
|
+
if System.activate?
|
16
|
+
System.activate!(name)
|
17
|
+
end
|
18
|
+
|
19
|
+
runtime.system_require(gem_dep[:files])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.system_setup(gemfile, *groups)
|
24
|
+
Gemfile.setup_env(gemfile)
|
25
|
+
runtime.gemfile(Pathname.new(gemfile))
|
26
|
+
runtime.setup_env
|
27
|
+
runtime.clear
|
28
|
+
Gemfile.parse(gemfile, *groups).each do |name, gem_dep|
|
29
|
+
if System.activate?
|
30
|
+
System.activate!(name)
|
31
|
+
end
|
32
|
+
|
33
|
+
runtime.add_spec(gem_dep[:dep].to_spec())
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "bundler"
|
2
|
+
|
3
|
+
module BundlerExt
|
4
|
+
class Gemfile
|
5
|
+
def self.setup_env(gemfile)
|
6
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.parse_env(groups)
|
10
|
+
extra_groups = ENV['BEXT_GROUPS'] ||
|
11
|
+
ENV['BUNDLER_EXT_GROUPS']
|
12
|
+
extra_groups.split(/\s/).each {|g| groups << g.to_sym} if extra_groups
|
13
|
+
all_groups = groups.size == 1 && groups.first == :all && (!extra_groups || extra_groups.empty?)
|
14
|
+
{:groups => groups.map { |g| g.to_sym},
|
15
|
+
:extra_groups => extra_groups,
|
16
|
+
:all_groups => all_groups}
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.dependency_in_env?(dep, env)
|
20
|
+
in_group = (env[:groups] & dep.groups).any? || env[:all_groups]
|
21
|
+
in_group && dep.current_platform?
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.files_for_dependency(dep, env)
|
25
|
+
files = []
|
26
|
+
if self.dependency_in_env?(dep, env)
|
27
|
+
Array(dep.autorequire || dep.name).each do |file|
|
28
|
+
files << file
|
29
|
+
end
|
30
|
+
end
|
31
|
+
files
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.process(bundler_gemfile, env)
|
35
|
+
deps = {}
|
36
|
+
bundler_gemfile.dependencies.each do |dep|
|
37
|
+
files = self.files_for_dependency(dep, env)
|
38
|
+
deps[dep.name] = {:dep => dep, :files => files} unless files.empty?
|
39
|
+
end
|
40
|
+
deps
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.parse(gemfile, *groups)
|
44
|
+
setup_env(gemfile)
|
45
|
+
env = parse_env(groups)
|
46
|
+
gemfile = Bundler::Dsl.evaluate(gemfile, nil, true)
|
47
|
+
process(gemfile, env)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "bundler_ext/output"
|
2
|
+
|
3
|
+
module BundlerExt
|
4
|
+
class Runtime
|
5
|
+
def gemfile(new_val = nil)
|
6
|
+
@bext_gemfile ||= Bundler.default_gemfile
|
7
|
+
@bext_gemfile = new_val unless new_val.nil?
|
8
|
+
@bext_gemfile
|
9
|
+
end
|
10
|
+
|
11
|
+
def root
|
12
|
+
gemfile.dirname.expand_path
|
13
|
+
end
|
14
|
+
|
15
|
+
def bundler
|
16
|
+
@bundler_runtime ||= Bundler::Runtime.new(root, gemfile)
|
17
|
+
end
|
18
|
+
|
19
|
+
def rubygems
|
20
|
+
@bundler_rubygems ||= Bundler::RubygemsIntegration.new
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def setup_env
|
25
|
+
# some rubygems do not play well with daemonized processes ($HOME is empty)
|
26
|
+
ENV['HOME'] = ENV['BEXT_HOME'] if ENV['BEXT_HOME']
|
27
|
+
ENV['HOME'] = ENV['BUNDLER_EXT_HOME'] if ENV['BUNDLER_EXT_HOME']
|
28
|
+
end
|
29
|
+
|
30
|
+
# Helper to generate, taken from bundler_ext
|
31
|
+
def self.namespaced_file(file)
|
32
|
+
return nil unless file.to_s.include?('-')
|
33
|
+
file.respond_to?(:name) ? file.name.gsub('-', '/') : file.to_s.gsub('-', '/')
|
34
|
+
end
|
35
|
+
|
36
|
+
def system_require(files)
|
37
|
+
files.each do |dep|
|
38
|
+
# this part also take from lib/bundler/runtime.rb (github/master)
|
39
|
+
begin
|
40
|
+
#puts "Attempting to require #{dep}"
|
41
|
+
require dep
|
42
|
+
rescue LoadError => e
|
43
|
+
namespaced_file = self.class.namespaced_file(dep)
|
44
|
+
begin
|
45
|
+
require namespaced_file unless namespaced_file.nil?
|
46
|
+
rescue LoadError => e2
|
47
|
+
e = e2
|
48
|
+
end
|
49
|
+
|
50
|
+
Output.strict_err "Gem loading error: #{e.message}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def clear
|
56
|
+
bundler.send :clean_load_path
|
57
|
+
end
|
58
|
+
|
59
|
+
def add_spec(spec)
|
60
|
+
# copied from Bundler::Runtime#setup
|
61
|
+
rubygems.mark_loaded spec
|
62
|
+
load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)}
|
63
|
+
$LOAD_PATH.unshift(*load_paths)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rubygems/requirement'
|
2
|
+
|
3
|
+
# ruby compat fix
|
4
|
+
Gem::Requirement::BadRequirementError = ArgumentError if RUBY_VERSION < '2'
|
5
|
+
|
6
|
+
module BundlerExt
|
7
|
+
class System
|
8
|
+
class << self
|
9
|
+
attr_accessor :pkg_prefix
|
10
|
+
attr_accessor :activate_versions
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.parse_env
|
14
|
+
@pkg_prefix = ENV['BEXT_PKG_PREFIX'] || ''
|
15
|
+
@activate_versions = ENV['BEXT_ACTIVATE_VERSIONS']
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.activate?
|
19
|
+
parse_env
|
20
|
+
# TODO support other package system activations, eg deb, homebrew, etc
|
21
|
+
@activate_versions && self.is_rpm_system?
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.system_name_for(name)
|
25
|
+
parse_env
|
26
|
+
"#{@pkg_prefix}#{name}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.is_rpm_system?
|
30
|
+
File.executable?(self.rpm_cmd)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.rpm_cmd(new_val=nil)
|
34
|
+
@rpm_cmd ||= '/usr/bin/rpm'
|
35
|
+
@rpm_cmd = new_val unless new_val.nil?
|
36
|
+
@rpm_cmd
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.system_version_for(name)
|
40
|
+
if is_rpm_system?
|
41
|
+
out = `#{rpm_cmd} -qi #{name}`
|
42
|
+
version = out =~ /.*Version\s*:\s*([^\s]*)\s+.*/ ?
|
43
|
+
$1 : nil
|
44
|
+
else
|
45
|
+
# TODO support debian, other platforms
|
46
|
+
version = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
version
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.activate!(name)
|
53
|
+
begin
|
54
|
+
sys_name = system_name_for(name)
|
55
|
+
version = system_version_for(sys_name)
|
56
|
+
gem name, "=#{version}"
|
57
|
+
rescue LoadError, Gem::Requirement::BadRequirementError
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/bundler_ext/version.rb
CHANGED
@@ -1,146 +1,98 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'bundler_ext'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
skip_system = true
|
9
|
-
end
|
10
|
-
|
11
|
-
describe BundlerExt do
|
12
|
-
before(:each) do
|
13
|
-
@gemfile = 'spec/fixtures/Gemfile.in'
|
4
|
+
describe BundlerExt do
|
5
|
+
describe "#runtime" do
|
6
|
+
it "returns handle to runtime instance" do
|
7
|
+
described_class.runtime.should be_an_instance_of(BundlerExt::Runtime)
|
8
|
+
described_class.runtime.should == described_class.runtime
|
14
9
|
end
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#system_require" do
|
13
|
+
it "sets up runtime env" do
|
14
|
+
described_class.runtime.should_receive(:setup_env)
|
15
|
+
described_class.system_require('spec/fixtures/Gemfile.in')
|
21
16
|
end
|
22
17
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
libs.keys.should_not include('deltacloud-client')
|
29
|
-
libs.keys.should_not include('vcr')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
describe "with :all passed in" do
|
33
|
-
it "should return the list of system libraries in all groups to require" do
|
34
|
-
libs = BundlerExt.parse_from_gemfile(@gemfile, :all)
|
35
|
-
libs.should be_an(Hash)
|
36
|
-
libs.keys.should include('deltacloud-client')
|
37
|
-
libs['deltacloud-client'][:files].should == ['deltacloud']
|
38
|
-
libs.keys.should include('vcr')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
describe "with group passed in" do
|
42
|
-
it "should not return any deps that are not in the 'development' group" do
|
43
|
-
libs = BundlerExt.parse_from_gemfile(@gemfile,'development')
|
44
|
-
libs.should be_an(Hash)
|
45
|
-
libs.keys.should_not include('deltacloud-client')
|
46
|
-
end
|
47
|
-
it "should return only deps that are in the :test group" do
|
48
|
-
libs = BundlerExt.parse_from_gemfile(@gemfile, :test)
|
49
|
-
libs.should be_an(Hash)
|
50
|
-
libs.keys.should_not include('deltacloud-client')
|
51
|
-
libs.keys.should include('vcr')
|
52
|
-
end
|
53
|
-
it "should return deps from both the :default and :test groups" do
|
54
|
-
libs = BundlerExt.parse_from_gemfile(@gemfile, :default, :test)
|
55
|
-
libs.should be_an(Hash)
|
56
|
-
libs.keys.should include('deltacloud-client')
|
57
|
-
libs.keys.should include('vcr')
|
58
|
-
end
|
59
|
-
end
|
60
|
-
it "should only return deps for the current platform" do
|
61
|
-
libs = BundlerExt.parse_from_gemfile(@gemfile)
|
62
|
-
libs.should be_an(Hash)
|
63
|
-
if RUBY_VERSION < "1.9"
|
64
|
-
libs.keys.should_not include('cinch')
|
65
|
-
else
|
66
|
-
libs.keys.should_not include('fastercsv')
|
67
|
-
end
|
68
|
-
end
|
18
|
+
it "parses specified gemfile" do
|
19
|
+
BundlerExt::Gemfile.should_receive(:parse).
|
20
|
+
with('spec/fixtures/Gemfile.in', *['mygroups']).
|
21
|
+
and_call_original
|
22
|
+
described_class.system_require('spec/fixtures/Gemfile.in', 'mygroups')
|
69
23
|
end
|
70
|
-
describe "#system_require" do
|
71
|
-
it "strict mode should fail loading non existing gem" do
|
72
|
-
expect { BundlerExt.system_require(@gemfile, :fail) }.to raise_error
|
73
|
-
end
|
74
24
|
|
75
|
-
|
76
|
-
|
77
|
-
BundlerExt.
|
78
|
-
|
25
|
+
context "System.activate? is true" do
|
26
|
+
it "activates system dependencies" do
|
27
|
+
BundlerExt::Gemfile.should_receive(:parse).
|
28
|
+
and_return({'rails' => {:files => []}})
|
29
|
+
BundlerExt::System.should_receive(:activate?).and_return(true)
|
30
|
+
BundlerExt::System.should_receive(:activate!).with('rails')
|
31
|
+
described_class.system_require('my_gemfile')
|
79
32
|
end
|
33
|
+
end
|
80
34
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
35
|
+
it "requires dependency files" do
|
36
|
+
files = ['rails-includes']
|
37
|
+
BundlerExt::Gemfile.should_receive(:parse).
|
38
|
+
and_return({'rails' => {:files => files}})
|
39
|
+
described_class.runtime.should_receive(:system_require).with(files)
|
40
|
+
described_class.system_require('my_gemfile')
|
41
|
+
end
|
42
|
+
end
|
86
43
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
44
|
+
describe "#system_setup" do
|
45
|
+
it "sets up gemfile env" do
|
46
|
+
BundlerExt::Gemfile.should_receive(:setup_env).
|
47
|
+
with('spec/fixtures/Gemfile.in').at_least(:once)
|
48
|
+
described_class.runtime.should_receive(:clear) # stub out clear
|
49
|
+
described_class.system_setup('spec/fixtures/Gemfile.in')
|
50
|
+
end
|
92
51
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
it "non-strict mode should load the libraries using env var list" do
|
99
|
-
ENV['BEXT_GROUPS'] = 'test development blah'
|
100
|
-
ENV['BEXT_NOSTRICT'] = 'true'
|
101
|
-
BundlerExt.system_require(@gemfile)
|
102
|
-
defined?(Gem::Command).should be_true
|
103
|
-
end
|
52
|
+
it "sets runtime gemfile" do
|
53
|
+
described_class.runtime.should_receive(:clear) # stub out clear
|
54
|
+
described_class.system_setup('spec/fixtures/Gemfile.in')
|
55
|
+
described_class.runtime.gemfile.to_s.should == 'spec/fixtures/Gemfile.in'
|
56
|
+
end
|
104
57
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
58
|
+
it "sets up runtime env" do
|
59
|
+
described_class.runtime.should_receive(:clear) # stub out clear
|
60
|
+
described_class.runtime.should_receive(:setup_env)
|
61
|
+
described_class.system_setup('spec/fixtures/Gemfile.in')
|
62
|
+
end
|
111
63
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
64
|
+
it "clears runtime" do
|
65
|
+
described_class.runtime.should_receive(:clear) # stub out clear
|
66
|
+
described_class.runtime.should_receive(:setup_env)
|
67
|
+
described_class.system_setup('spec/fixtures/Gemfile.in')
|
68
|
+
end
|
118
69
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
and_return(version)
|
127
|
-
BundlerExt.should_receive(:gem).with(gem, "=#{version}")
|
128
|
-
}
|
129
|
-
BundlerExt.system_require(@gemfile, :all)
|
130
|
-
end
|
70
|
+
it "parses specified gemfile" do
|
71
|
+
described_class.runtime.should_receive(:clear) # stub out clear
|
72
|
+
BundlerExt::Gemfile.should_receive(:parse).
|
73
|
+
with('spec/fixtures/Gemfile.in', *['mygroups']).
|
74
|
+
and_call_original
|
75
|
+
described_class.system_setup('spec/fixtures/Gemfile.in', 'mygroups')
|
76
|
+
end
|
131
77
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
BundlerExt.system_require(@gemfile, :all)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
78
|
+
context "System.activate? is true" do
|
79
|
+
it "activates system dependencies" do
|
80
|
+
described_class.runtime.should_receive(:clear) # stub out clear
|
81
|
+
BundlerExt::Gemfile.should_receive(:parse).
|
82
|
+
and_return({'rails' => {:dep => ::Gem::Dependency.new('rails')}})
|
83
|
+
BundlerExt::System.should_receive(:activate?).and_return(true)
|
84
|
+
BundlerExt::System.should_receive(:activate!).with('rails')
|
85
|
+
described_class.system_setup('spec/fixtures/Gemfile.in')
|
144
86
|
end
|
145
87
|
end
|
88
|
+
|
89
|
+
it "adds dependency specs to runtime" do
|
90
|
+
dep = ::Gem::Dependency.new('rails')
|
91
|
+
described_class.runtime.should_receive(:clear) # stub out clear
|
92
|
+
BundlerExt::Gemfile.should_receive(:parse).
|
93
|
+
and_return({'rails' => {:dep => dep}})
|
94
|
+
described_class.runtime.should_receive(:add_spec).with(dep.to_spec())
|
95
|
+
described_class.system_setup('spec/fixtures/Gemfile.in')
|
96
|
+
end
|
146
97
|
end
|
98
|
+
end
|