Sha256: 6f7ed93e0a8c4bf860a5940c88f005a7c8cd2d84eec593486066402e16cd46f5

Contents?: true

Size: 1.68 KB

Versions: 65

Compression:

Stored size: 1.68 KB

Contents

require "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

65 entries across 65 versions & 1 rubygems

Version Path
sproutcore-1.11.0 spec/lib/models/target/target_for_spec.rb
sproutcore-1.11.0.rc3 spec/lib/models/target/target_for_spec.rb
sproutcore-1.11.0.rc2 spec/lib/models/target/target_for_spec.rb
sproutcore-1.11.0.rc1 spec/lib/models/target/target_for_spec.rb
sproutcore-1.10.3.1 spec/lib/models/target/target_for_spec.rb
sproutcore-1.10.2 spec/lib/models/target/target_for_spec.rb
sproutcore-1.10.1 spec/lib/models/target/target_for_spec.rb
sproutcore-1.10.0 spec/lib/models/target/target_for_spec.rb
sproutcore-1.10.0.rc.3 spec/lib/models/target/target_for_spec.rb
sproutcore-1.10.0.rc.2 spec/lib/models/target/target_for_spec.rb
sproutcore-1.10.0.rc.1 spec/lib/models/target/target_for_spec.rb
sproutcore-1.9.2 spec/lib/models/target/target_for_spec.rb
sproutcore-1.9.1 spec/lib/models/target/target_for_spec.rb
sproutcore-1.9.0 spec/lib/models/target/target_for_spec.rb
sproutcore-1.8.2.1 spec/lib/models/target/target_for_spec.rb
sproutcore-1.8.1 spec/lib/models/target/target_for_spec.rb
sproutcore-1.8.0 spec/lib/models/target/target_for_spec.rb
sproutcore-1.7.1.beta-java spec/lib/models/target/target_for_spec.rb
sproutcore-1.7.1.beta spec/lib/models/target/target_for_spec.rb
sproutcore-1.6.0.1-java spec/lib/models/target/target_for_spec.rb