Skip to content

Commit

Permalink
[Specs] Added specifications for more concrete subclasses.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopelosin committed Oct 15, 2012
1 parent 2af78a0 commit 5f19520
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .kick
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ process do |files|
execute 'rake ext:cleanbuild'
'spec/xcodeproj_ext_spec.rb'
when %r{lib/xcodeproj/(.+?)\.rb$}
s = Dir.glob("spec/**/#{$1}_spec.rb")
s = Dir.glob("spec/**#{$1}_spec.rb")
puts
s unless s.empty?
end
end
Expand Down
14 changes: 10 additions & 4 deletions spec/project/object/build_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ module ProjectSpecs
@configuration = @project.new(XCBuildConfiguration)
end

it "returns the xcconfig that this configuration is based on" do
xcconfig = @project.new_file('file.xcconfig')
@configuration.base_configuration_reference = xcconfig
@configuration.base_configuration_reference.should.be.not.nil
it "returns its name" do
@configuration.name = "a_name"
@configuration.name.should == "a_name"
end

it "returns the empty hash as default build settings" do
@configuration.build_settings.should == {}
end

it "returns the xcconfig that this configuration is based on" do
xcconfig = @project.new_file('file.xcconfig')
@configuration.base_configuration_reference = xcconfig
@configuration.base_configuration_reference.should.be.not.nil
end

end
end

26 changes: 26 additions & 0 deletions spec/project/object/build_file_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require File.expand_path('../../../spec_helper', __FILE__)

module ProjectSpecs
describe PBXBuildFile do

before do
@file = @project.new(PBXBuildFile)
end

it "defaults the settings to the empty hash" do
@file.settings.should == {}
end

it "returns the file reference" do
@file.file_ref = @project.new(PBXFileReference)
@file.file_ref.class.should == PBXFileReference
end

it "accepts a variant group and a version group as a reference" do
lambda { @file.file_ref = @project.new(PBXVariantGroup) }.should.not.raise
lambda { @file.file_ref = @project.new(XCVersionGroup) }.should.not.raise
end

end
end

45 changes: 45 additions & 0 deletions spec/project/object/build_rule_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require File.expand_path('../../../spec_helper', __FILE__)

module ProjectSpecs
describe PBXBuildRule do

before do
@rule = @project.new(PBXBuildRule)
end

it "returns the name" do
@rule.name = "myRule"
@rule.name.should == "myRule"
end

it "returns the compiler spec" do
@rule.compiler_spec = "com.apple.compilers.proxy.script"
@rule.compiler_spec.should == "com.apple.compilers.proxy.script"
end

it "returns the file type of the rule" do
@rule.file_type = "pattern.proxy"
@rule.file_type.should == "pattern.proxy"
end

it "returns whether the rule is editable" do
@rule.is_editable = '1'
@rule.is_editable.should == '1'
end

it "returns the output files of the rule" do
f = @project.new(PBXFileReference)
@rule.output_files << f
@rule.output_files.count.should == 1
@rule.output_files.should.include?(f)
end

it "returns the script of the rule" do
@rule.script = 'echo "BABY COOL"'
@rule.script.should == 'echo "BABY COOL"'
end

end
end


38 changes: 38 additions & 0 deletions spec/project/object/configuration_list_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require File.expand_path('../../../spec_helper', __FILE__)

module ProjectSpecs
describe XCBuildConfiguration do

before do
@list = @project.new(XCConfigurationList)
end

it "by the default the default configutation is not visible" do
@list.default_configuration_is_visible.should == '0'
end

it "returns the default configuration name" do
@list.default_configuration_name = 'Release'
@list.default_configuration_name.should == 'Release'
end

it "returns the configurations" do
configuration = @project.new(XCBuildConfiguration)
@list.build_configurations.to_a.should == []
@list.build_configurations << configuration
@list.build_configurations.count.should == 1
@list.build_configurations.should.include?(configuration)
end

it "returns the build settings of a configuration given its name" do
settings = { 'GCC_VERSION' => 'com.apple.compilers.llvm.clang.1_0'}
configuration = @project.new(XCBuildConfiguration)
configuration.name = 'Debug'
configuration.build_settings = settings
@list.build_configurations << configuration
@list.build_settings('Debug').should == settings
end

end
end

21 changes: 0 additions & 21 deletions spec/project/object/configuration_spec.rb

This file was deleted.

33 changes: 33 additions & 0 deletions spec/project/object/container_item_proxy_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require File.expand_path('../../../spec_helper', __FILE__)

module ProjectSpecs
describe PBXContainerItemProxy do

before do
@proxy = @project.new(PBXContainerItemProxy)
end

it "returns the container portal" do
@proxy.container_portal = @project.root_object
@proxy.container_portal.should == @project.root_object
end

it "returns the type of the proxy" do
@proxy.proxy_type = "1"
@proxy.proxy_type.should == "1"
end

it "returns the remote global id string" do
target = @project.new_target(:static, "Pods", :ios)
@proxy.remote_global_id_string = target.uuid
@proxy.remote_global_id_string.should == target.uuid
end

it "returns the remote info" do
@proxy.remote_info = "Pods"
@proxy.remote_info.should == "Pods"
end

end
end

60 changes: 60 additions & 0 deletions spec/project/object/root_object_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
require File.expand_path('../../../spec_helper', __FILE__)

module ProjectSpecs
describe PBXProject do

before do
@project.new_target(:static, "Pods", :ios)
@root_object = @project.root_object
end

it "returns the targets" do
@root_object.targets.map(&:name).should == ["Pods"]
end

it "returns the attributes" do
@root_object.attributes["LastUpgradeCheck"].should.not.be.nil
end

it "returns the build configuration list" do
@root_object.build_configuration_list.class.should == XCConfigurationList
end

it "returns the compatibility version" do
@root_object.compatibility_version.should.include("Xcode")
end

it "returns the development region" do
@root_object.development_region.should == "English"
end

it "returns whether has scanned for encodings" do
@root_object.has_scanned_for_encodings.should == '0'
end

it "returns the known regions" do
@root_object.known_regions.should == %w[en]
end

it "returns the main group" do
@root_object.main_group.class.should == PBXGroup
end

it "returns the products group" do
@root_object.product_ref_group.class.should == PBXGroup
end

it "returns the project dir path" do
@root_object.project_dir_path = "some/path"
@root_object.project_dir_path.should == "some/path"
end

it "returns the project root" do
@root_object.project_root = "some/path"
@root_object.project_root.should == "some/path"
end

end
end


33 changes: 33 additions & 0 deletions spec/project/object/target_dependency_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require File.expand_path('../../../spec_helper', __FILE__)

module ProjectSpecs
describe PBXTargetDependency do

before do
@dep = @project.new(PBXTargetDependency)
end

it "returns the target on which this dependency is based" do
@dep.target = @project.new_target(:static, "Pods", :ios)
@dep.target.name.should == "Pods"
end

it "returns the proxy of the target on which this dependency is based" do
target = @project.new_target(:static, "Pods", :ios)

proxy = @project.new(PBXContainerItemProxy)
proxy.container_portal = @project.root_object
proxy.remote_info = "Pods"
proxy.proxy_type = "1"
proxy.remote_global_id_string = target.uuid

@dep.targetProxy = proxy
@dep.targetProxy.remote_info.should == "Pods"
end


end
end



0 comments on commit 5f19520

Please sign in to comment.