Sha256: b83fcccbe82b91b26210b3a8a18d8e73570e3b9de8a56e272ca45d014eabc2ff

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crystal_ext-0.0.11 spec/environment/standard_app_spec.rb