Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ tmtags
coverage
rdoc
pkg
tags
*.gem

## PROJECT::SPECIFIC
.specjour
spec/spec.opts
.bundle
Gemfile.lock
bin/stubs
13 changes: 11 additions & 2 deletions lib/specjour/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions spec/specjour/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions specjour.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down