Sha256: 10331de9ed94a1b34c0a1aef209afafb4ad6149cd6d2048c93d7544ac28937da

Contents?: true

Size: 1.74 KB

Versions: 20

Compression:

Stored size: 1.74 KB

Contents

require File.join(File.dirname(__FILE__), %w[.. .. .. spec_helper])

describe SC::Target, 'target_for' do

  include SC::SpecHelpers

  before do
    @project = fixture_project(:real_world)
    @target = @project.target_for(:sproutcore)
  end
  
  it "should lookup absolute target names (/foo) from the top" do
    target = @target.target_for('/contacts')
    target.should_not be_nil
    target.target_name.to_s.should eql('/contacts')
  end
  
  it "should look for relative names in children first" do
    # note: uploader should exist both in /apps and /sproutcore/frameworks
    target = @target.target_for(:uploader)
    target.should_not be_nil
    target.target_name.to_s.should eql('/sproutcore/uploader')
  end

  it "should look for relative names in sibling after children" do
    target = @target.target_for(:core_photos)
    target.should_not be_nil
    target.target_name.to_s.should eql('/core_photos')
  end

  it "should look for relative names in parents after siblings" do
    @target = @project.target_for('sproutcore/costello')
    target = @target.target_for(:contacts)
    target.should_not be_nil
    target.target_name.to_s.should eql('/contacts')
  end

  it "should not find nested targets without naming parents" do
    @target = @project.target_for(:contacts)
    target = @target.target_for(:costello)
    target.should be_nil
  end

  it "should be able to handle multiple/relative/names" do
    @target = @project.target_for(:contacts)
    target = @target.target_for('sproutcore/costello')
    target.should_not be_nil
    target.target_name.to_s.should eql('/sproutcore/costello')
  end
  
  it "should return nil if no matching target could be found" do
    target = @target.target_for(:does_not_exist)
    target.should be_nil
  end
  
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090407205609 spec/lib/models/target/target_for_spec.rb
sproutit-sproutcore-1.0.0.20090408130025 spec/lib/models/target/target_for_spec.rb
sproutit-sproutcore-1.0.0.20090416161445 spec/lib/models/target/target_for_spec.rb
sproutit-sproutcore-1.0.20090721145236 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1046 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1043 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1042 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1037 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1035 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1031 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1030 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1029 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1027 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1028 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1026 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1025 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1024 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1009 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1008 spec/lib/models/target/target_for_spec.rb
sproutcore-1.0.1003 spec/lib/models/target/target_for_spec.rb