Permalink
Browse files

[Specs] Added specifications for more concrete subclasses.

  • Loading branch information...
fabiopelosin committed Oct 15, 2012
1 parent 2af78a0 commit 5f195204a4a215bc6d592133a90266263dbb4b99
View
3 .kick
@@ -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
@@ -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
+
@@ -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
+
@@ -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
+
+
@@ -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
+
@@ -1,21 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-
-module ProjectSpecs
- describe "Xcodeproj::Project::Object::XCBuildConfiguration" do
-
- before do
- @configuration = @project.new(XCBuildConfiguration)
- end
-
- it "returns the xcconfig that this configuration is based on (baseConfigurationReference)" do
- xcconfig = @project.new_file(nil)
- @configuration.base_configuration_reference = xcconfig
- @configuration.base_configuration_reference.should.be.not.nil
- end
-
- it "defaults the build settings to the empty hash" do
- @configuration.build_settings.should == {}
- end
-
- end
-end
@@ -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
+
@@ -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
+
+
@@ -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.