test/spec_helper.rb in less-rails-2.0.3 vs test/spec_helper.rb in less-rails-2.1.0
- old
+ new
@@ -10,22 +10,35 @@
module Less
module Rails
class Spec < MiniTest::Spec
-
+
+ include FileUtils
+
+ class << self
+
+ def dummy_app
+ Dummy::Application
+ end
+
+ def dummy_tmp
+ "#{dummy_app.root}/tmp"
+ end
+
+ end
+
before do
+ prepare_cache_dir
reset_config_options
reset_caches
end
protected
- def dummy_app
- Dummy::Application
- end
-
+ delegate :dummy_app, :dummy_tmp, :to => :'self.class'
+
def dummy_config
dummy_app.config
end
def dummy_assets
@@ -44,34 +57,32 @@
def reset_caches
dummy_assets.version = SecureRandom.hex(32)
dummy_assets.cache.clear
end
+ def prepare_cache_dir
+ mkdir_p "#{dummy_tmp}/cache/assets"
+ end
+
end
# Heavily inspired by Rails::Generators::TestCase.
class GeneratorSpec < Spec
- include FileUtils
-
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
delegate :destination_root, :current_path, :generator_class, :default_arguments, :to => :'self.class'
self.current_path = File.expand_path(Dir.pwd)
self.default_arguments = []
- self.destination_root = "#{Dummy::Application.root}/tmp"
+ self.destination_root = "#{dummy_tmp}/destination_root"
- before { destination_root_is_set? ; ensure_current_path ; prepare_destination ; no_color! ; setup_generator_class }
+ before { ensure_current_path ; prepare_destination ; no_color! ; setup_generator_class }
after { remove_destination ; ensure_current_path }
protected
def no_color!
Thor::Base.shell = Thor::Shell::Basic
- end
-
- def destination_root_is_set?
- raise "You need to configure your Less::Rails::GeneratorSpec destination root." unless destination_root
end
def ensure_current_path
cd current_path
end