From a535857aaa293e1a6621eccdefad0b4e7e13fc9a Mon Sep 17 00:00:00 2001 From: Nathaniel Bibler Date: Tue, 3 May 2011 22:44:37 -0400 Subject: [PATCH] Create spec/support to hold custom spec modules --- spec/spec_helper.rb | 33 ++++----------------------------- spec/support/configuration.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 spec/support/configuration.rb diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9391c5f..53123b3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,37 +8,12 @@ # Load the HireFire Ruby library require File.join(LIB_PATH, 'hirefire') -module ConfigurationHelper - - def configure(&block) - HireFire.configure(&block) - end - - def with_configuration(&block) - old_configuration = HireFire.configuration - HireFire.configuration = HireFire::Configuration.new - yield(HireFire.configuration) - HireFire.configuration = old_configuration - end - - def with_max_workers(workers, &block) - with_configuration do |config| - config.max_workers = workers - yield - end - end - - def with_min_workers(workers, &block) - with_configuration do |config| - config.min_workers = workers - yield - end - end -end +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[File.join(File.expand_path('../support', __FILE__), '**/*.rb')].each {|f| require f} ## # Use Mocha to mock with RSpec RSpec.configure do |config| config.mock_with :mocha - config.include ConfigurationHelper -end \ No newline at end of file +end diff --git a/spec/support/configuration.rb b/spec/support/configuration.rb new file mode 100644 index 0000000..32188ee --- /dev/null +++ b/spec/support/configuration.rb @@ -0,0 +1,30 @@ +module ConfigurationHelper + def configure(&block) + HireFire.configure(&block) + end + + def with_configuration(&block) + old_configuration = HireFire.configuration + HireFire.configuration = HireFire::Configuration.new + yield(HireFire.configuration) + HireFire.configuration = old_configuration + end + + def with_max_workers(workers, &block) + with_configuration do |config| + config.max_workers = workers + yield + end + end + + def with_min_workers(workers, &block) + with_configuration do |config| + config.min_workers = workers + yield + end + end +end + +RSpec.configure do |config| + config.include ConfigurationHelper +end