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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18929e0e577a996fe29aab583a44ff3dc47f70ee
4
- data.tar.gz: 8b5fc498ef3304ec5370c3a79226e764514a6f9c
3
+ metadata.gz: 909210bc887e62015bf713baa415cd3570274817
4
+ data.tar.gz: 8b4e28226559a24052a0d0b8b4ad372d9beede2a
5
5
  SHA512:
6
- metadata.gz: 6947df0c40f5c52fe75e5fc194b40278449485255205e6961a1d09026693c166b7d88e3ac877d7ac9cf276287c78d0e0279600439909db26b868da7d261d23d8
7
- data.tar.gz: 171b367e5382260a075546f96ce30cf600fa67b6981013a21dff99a7e1326fd173e5dcc62db343b901eff484eef12fdfe355e115c438300efb362613c423b239
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
- The purpose of this library is to allow, for instance, yum and rpm to
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
- ### Example usage ###
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 you want to load ALL Gemfile groups, use the following statement:
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
- BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :all)
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
- When you want to load only the default one, use:
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
- BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :default)
33
+ ### Show Me The Code! ##
30
34
 
31
- You can provide multiple parameters to the system_require function
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
- You may also want to wrap your call in some kind of check, to allow
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
- mv Gemfile Gemfile.in
39
+ To load & require ALL Gemfile groups, use the following statement:
40
+
41
+ BundlerExt.system_require(gemfile_in, :all)
44
42
 
45
- Then, just look for a Gemfile, otherwise, load deps via
46
- Gemfile.in/BundlerExt.
43
+ To load only the default one, use:
47
44
 
48
- Note there is a reason for the 2 files names (for now at least) -
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
- ### Additional configuration ###
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
- There are special environment variables you can use. You may need to
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
- BEXT_GROUPS="group1 group2 group3" rails server ...
57
+ BundlerExt.system_setup(gemfile_in, :default)
65
58
 
66
- Also, by default bundler_ext raises an error when dependency cannot
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
- BEXT_NOSTRICT=1 rake db:migrate ...
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
- In this mode bundler_ext prints out error messages on the stdout,
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 'bundler_ext/bundler_ext'
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,16 @@
1
+ module BundlerExt
2
+ class Output
3
+ def self.parse_env
4
+ @nostrict = ENV['BEXT_NOSTRICT'] || ENV['BUNDLER_EXT_NOSTRICT']
5
+ end
6
+
7
+ def self.strict_err(msg)
8
+ parse_env
9
+ if @nostrict
10
+ puts msg
11
+ else
12
+ raise msg
13
+ end
14
+ end
15
+ end
16
+ 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,2 @@
1
+ gemfile = ENV['BEXT_GEMFILE'] || 'Gemfile.in'
2
+ BundlerExt.system_setup gemfile, :all
@@ -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
@@ -1,3 +1,3 @@
1
1
  module BundlerExt
2
- VERSION = '0.3.2'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -1,146 +1,98 @@
1
1
  require 'spec_helper'
2
+ require 'bundler_ext'
2
3
 
3
- # skip system specs unless we can load linux_admin
4
- skip_system = false
5
- begin
6
- require 'linux_admin'
7
- rescue LoadError
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
- after(:each) do
16
- ENV['BUNDLER_PKG_PREFIX'] = nil
17
- ENV['BEXT_ACTIVATE_VERSIONS'] = nil
18
- ENV['BEXT_PKG_PREFIX'] = nil
19
- ENV['BEXT_NOSTRICT'] = nil
20
- ENV['BEXT_GROUPS'] = nil
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
- describe "#parse_from_gemfile" do
24
- describe "with no group passed in" do
25
- it "should return nothing to require" do
26
- libs = BundlerExt.parse_from_gemfile(@gemfile)
27
- libs.should be_an(Hash)
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
- it "non-strict mode should load the libraries in the gemfile" do
76
- ENV['BEXT_NOSTRICT'] = 'true'
77
- BundlerExt.system_require(@gemfile)
78
- defined?(Gem).should be_true
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
- it "non-strict mode should load the libraries in the gemfile" do
82
- ENV['BUNDLER_EXT_NOSTRICT'] = 'true'
83
- BundlerExt.system_require(@gemfile)
84
- defined?(Gem).should be_true
85
- end
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
- it "non-strict mode should load the libraries in the gemfile" do
88
- ENV['BEXT_NOSTRICT'] = 'true'
89
- BundlerExt.system_require(@gemfile, :fail)
90
- defined?(Gem).should be_true
91
- end
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
- it "non-strict mode should load the libraries in the gemfile" do
94
- ENV['BUNDLER_EXT_NOSTRICT'] = 'true'
95
- BundlerExt.system_require(@gemfile, :fail)
96
- defined?(Gem).should be_true
97
- end
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
- it "non-strict mode should load the libraries using env var list" do
106
- ENV['BUNLDER_EXT_GROUPS'] = 'test development blah'
107
- ENV['BEXT_NOSTRICT'] = 'true'
108
- BundlerExt.system_require(@gemfile)
109
- defined?(Gem::Command).should be_true
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
- unless skip_system
113
- context "ENV['BEXT_ACTIVATE_VERSIONS'] is true" do
114
- before(:each) do
115
- ENV['BUNDLER_EXT_NOSTRICT'] = 'true'
116
- ENV['BEXT_ACTIVATE_VERSIONS'] = 'true'
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
- it "activates the version of the system installed package" do
120
- gems = BundlerExt.parse_from_gemfile(@gemfile, :all)
121
- gems.each { |gem,gdep|
122
- version = rand(100)
123
- BundlerExt.should_receive(:system_gem_name_for).with(gem).
124
- and_return(gem)
125
- BundlerExt.should_receive(:system_gem_version_for).with(gem).
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
- context "ENV['BEXT_PKG_PREFIX'] is specified" do
133
- it "prepends bundler pkg prefix onto system package name to load" do
134
- ENV['BEXT_PKG_PREFIX'] = 'rubygem-'
135
- gems = BundlerExt.parse_from_gemfile(@gemfile, :all)
136
- gems.each { |gem,gdep|
137
- BundlerExt.should_receive(:system_gem_version_for).with("rubygem-#{gem}").
138
- and_return('0')
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