Sha256: d0653a8d12beee21dea3538d6cdec3188e144907cc45c9e06d8dfc40b298acd8

Contents?: true

Size: 2 KB

Versions: 2

Compression:

Stored size: 2 KB

Contents

require 'spec_helper'

describe 'dirc' do
  
  before(:all) do
    setup_mygame
  end
  
  after(:all) do
    teardown_mygame
  end
  
  it 'should be game dir' do
    Entityjs::Dirc.game?.should == true
  end
  
  it 'should not be game dir' do
    Dir.chdir(Dir.pwd+'/..')
    Entityjs::Dirc.game?.should == false
  end
  
  it 'should return script urls' do
    Entityjs::Dirc.stub(:find_scripts).and_return(['asdfsdf/scripts/asdf.js', 'sfhs/scripts/sdf.js'])
    
    Entityjs::Dirc.find_scripts_url.should be_instance_of Array
  end
  
  it 'should ignore and order game scripts' do
    Entityjs::Dirc.stub(:find_scripts).and_return(['asdfsdf/scripts/second.js', 'sfhs/scripts/first.js', 
      'sdf/scripts/kill.js','sdf/scripts/kill2.js'])
    
    out = Entityjs::Dirc.find_scripts_url(['kill'], ['first'])
    
    out.first.should match /first/
    out.each do |i|
      i.should_not match /kill|kill2/
    end
    
  end
  
  it 'should return entity src urls' do
    Entityjs::Dirc.stub(:find_entity_src).and_return(['asdfsdf/src/asdf.js', 'sfhs/src/sdf.js'])
    
    u = Entityjs::Dirc.find_entity_src_url
    
    u.size.should == 2
    
  end
  
  it 'should be alpha ordered' do
    s = Entityjs::Dirc.find_entity_src
    
    s[1].should_not match /socket\.js/
    
  end
  
  it 'should ignore entity scripts' do
    Entityjs::Dirc.stub(:find_entity_src).and_return(['asdfsdf/src/first.js', 'sfhs/src/ignore.js', 'sdfds/src/ignore2.js'])
    
    out = Entityjs::Dirc.find_entity_src_url(['ignore', 'ignore2'])
    
    out.each do |i|
      i.should_not match /ignore|ignore2/
    end
  end
  
  it 'should return tests' do
    Dir.stub(:'[]').and_return(['C:/asdfsdf/tests/asdf.js', 'C:/sfhs/tests/sdf.js'])
    
    Entityjs::Dirc.find_tests_url.first.should_not match /C:/
    
  end
  
  it 'should ignore tests' do
    Dir.stub(:'[]').and_return(['C:/asdfsdf/tests/asdf.js', 'C:/sfhs/tests/sdf.js'])
    
    Entityjs::Dirc.find_tests_url(['asdf']).each do |i|
      i.should_not match(/asdf/)
    end
    
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
entityjs-0.3.1 spec/lib/entityjs/dirc_spec.rb
entityjs-0.3.0 spec/lib/entityjs/dirc_spec.rb