require "#{File.expand_path(File.dirname(__FILE__))}/helper" require 'crystal/environment' require 'crystal/spec/environment' describe "Environment basic spec" do inject :environment => :environment with_environment :test before :all do Env = Crystal::Environment ::SpecResult = [] @dir = File.expand_path(File.dirname(__FILE__)) @app_original_dir = "#{@dir}/standard_app_spec_data" $APP_DIR = "#{@dir}/standard_app_spec" FileUtils.rm_r $APP_DIR if File.exist? $APP_DIR FileUtils.cp_r @app_original_dir, $APP_DIR load "#{$APP_DIR}/config/init.rb" end after :all do remove_constants %w(SpecResult) $LOAD_PATH.delete $APP_DIR $LOAD_PATH.delete "#{$APP_DIR}/plugin_a" $LOAD_PATH.delete "#{$APP_DIR}/plugin_b" FileUtils.rm_r $APP_DIR if File.exist? $APP_DIR $APP_DIR = nil end before :each do SpecResult.clear end it "core components" do crystal[:logger].should_not be_nil crystal[:environment].should_not be_nil crystal[:config].should_not be_nil end it "app and plugin callbacks" do crystal[:environment] crystal.register :custom_component crystal[:custom_component] SpecResult.should == ["before", "plugin before", "after", "plugin after", "custom event"] end it "load path" do $LOAD_PATH.should_not include($APP_DIR) $LOAD_PATH.should include("#{$APP_DIR}/plugin_a") $LOAD_PATH.should include("#{$APP_DIR}/plugin_b") end it "application root" do environment.config.root!.should == $APP_DIR end end