Sha256: d5e05faebb85ea406d3644488be152221ccb8facdca2df2d87a511f6a4680cf5

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module RSpec::Generator  
  def self.configure &block
    conf = RSpec::Generator::Configure
    if block
      block.arity < 1 ? conf.instance_eval(&block) : block.call(conf, self)  
    end      
  end
  
  module Configure
    class << self
      def remove_temp_dir= bool
        RSpec::Generator.remove_temp_dir = bool
      end  
      
      def debug= bool
        RSpec::Generator.debug = bool
      end

      def default_rails_root path, options = {} 
        configure_root_dir path, options
      end

      def rails_root= path, options = {} 
        configure_root_dir path, :custom
      end

      def lib= path
        RSpec::Generator::Require.lib = path
      end

      protected

      def configure_root_dir path, options = {}
        ::Rails.application.configure do
          config.root_dir = options == :custom ? TmpRails.root_dir(File.dirname(path) + '/../tmp', :custom) : TmpRails.root_dir(path)          
        end

        gen = RSpec::Generator

        ::RSpec.configure do |config|
          config.after(:suite) do
            gen.remove_rails_dir! if gen.remove_temp_dir
          end
        end        

        ::RSpec::Generator::TestCase.destination ::Rails.root      
        ::Rails::Generators.configure!         
      end
    end
  end  # Configure  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
generator-spec-0.4.4 lib/generator_spec/rspec_generator/configure.rb