diff --git a/.gitignore b/.gitignore index b6894c4..e5c4c1a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ tmtags coverage rdoc pkg +tags *.gem ## PROJECT::SPECIFIC @@ -24,3 +25,4 @@ pkg spec/spec.opts .bundle Gemfile.lock +bin/stubs diff --git a/lib/specjour/configuration.rb b/lib/specjour/configuration.rb index bcaf5a0..ed36752 100644 --- a/lib/specjour/configuration.rb +++ b/lib/specjour/configuration.rb @@ -2,7 +2,7 @@ module Specjour module Configuration extend self - attr_writer :before_fork, :after_fork, :after_load, :prepare, :rspec_formatter, :rsync_options + attr_writer :before_fork, :after_fork, :after_load, :bundler_options, :prepare, :rspec_formatter, :rsync_options # This block is run by each worker before they begin running tests. # The default action is to migrate the database, and clear it of any old @@ -24,6 +24,10 @@ def before_fork @before_fork ||= default_before_fork end + def bundler_options + @bundler_options ||= '' + end + # This block is run on all workers when invoking `specjour prepare` # Defaults to dropping the worker's database and recreating it. This # is especially useful when two teams are sharing workers and writing @@ -36,6 +40,7 @@ def reset @before_fork = nil @after_fork = nil @after_load = nil + @bundler_options = nil @prepare = nil @rsync_options = nil @rspec_formatter = nil @@ -51,7 +56,7 @@ def rsync_options def bundle_install if system('which bundle') - system('bundle check') || system('bundle install') + system('bundle check') || system(bundle_command) end end @@ -94,6 +99,10 @@ def default_rsync_options protected + def bundle_command + "bundle install #{bundler_options}".strip + end + def rails_with_ar? defined?(Rails) && defined?(ActiveRecord::Base) end diff --git a/spec/specjour/configuration_spec.rb b/spec/specjour/configuration_spec.rb index a553f2f..e91a771 100644 --- a/spec/specjour/configuration_spec.rb +++ b/spec/specjour/configuration_spec.rb @@ -46,6 +46,17 @@ def self.version mock(subject).system('bundle install') subject.before_fork.call end + + context "and bundler options set" do + before do + subject.bundler_options = "--binstubs" + end + + it "runs 'bundle install' with the given options" do + mock(subject).system('bundle install --binstubs') + subject.before_fork.call + end + end end context "when gems are satisfied" do @@ -127,6 +138,17 @@ def self.version end end + describe "#bundler_options" do + it "allows custom bundler_options to be set" do + subject.bundler_options = '--binstubs=bin/stubs' + subject.bundler_options.should == '--binstubs=bin/stubs' + end + + it "defaults to no bundler options" do + subject.bundler_options.should == "" + end + end + describe "#rsync_options" do it "allows custom rsync_options to be set" do subject.rsync_options = '-a' diff --git a/specjour.gemspec b/specjour.gemspec index 65943fe..1e796d4 100644 --- a/specjour.gemspec +++ b/specjour.gemspec @@ -28,6 +28,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency('dnssd', ['= 2.0.0']) s.add_runtime_dependency('thor', ['>= 0.14.0']) + s.add_development_dependency('rake') s.add_development_dependency('rspec', ['= 2.12']) s.add_development_dependency('rr') s.add_development_dependency('cucumber', ['>= 1.2.1'])