Skip to content
This repository
Browse code

[Specs] Added specifications for more concrete subclasses.

  • Loading branch information...
commit 5f195204a4a215bc6d592133a90266263dbb4b99 1 parent 2af78a0
Fabio Pelosin authored October 16, 2012
3  .kick
@@ -9,7 +9,8 @@ process do |files|
9 9
       execute 'rake ext:cleanbuild'
10 10
       'spec/xcodeproj_ext_spec.rb'
11 11
     when %r{lib/xcodeproj/(.+?)\.rb$}
12  
-      s = Dir.glob("spec/**/#{$1}_spec.rb")
  12
+      s = Dir.glob("spec/**#{$1}_spec.rb")
  13
+      puts
13 14
       s unless s.empty?
14 15
     end
15 16
   end
14  spec/project/object/build_configuration_spec.rb
@@ -7,15 +7,21 @@ module ProjectSpecs
7 7
       @configuration = @project.new(XCBuildConfiguration)
8 8
     end
9 9
 
10  
-    it "returns the xcconfig that this configuration is based on" do
11  
-      xcconfig = @project.new_file('file.xcconfig')
12  
-      @configuration.base_configuration_reference = xcconfig
13  
-      @configuration.base_configuration_reference.should.be.not.nil
  10
+    it "returns its name" do
  11
+      @configuration.name = "a_name"
  12
+      @configuration.name.should == "a_name"
14 13
     end
15 14
 
16 15
     it "returns the empty hash as default build settings" do
17 16
       @configuration.build_settings.should == {}
18 17
     end
19 18
 
  19
+    it "returns the xcconfig that this configuration is based on" do
  20
+      xcconfig = @project.new_file('file.xcconfig')
  21
+      @configuration.base_configuration_reference = xcconfig
  22
+      @configuration.base_configuration_reference.should.be.not.nil
  23
+    end
  24
+
20 25
   end
21 26
 end
  27
+
26  spec/project/object/build_file_spec.rb
... ...
@@ -0,0 +1,26 @@
  1
+require File.expand_path('../../../spec_helper', __FILE__)
  2
+
  3
+module ProjectSpecs
  4
+  describe PBXBuildFile do
  5
+
  6
+    before do
  7
+      @file = @project.new(PBXBuildFile)
  8
+    end
  9
+
  10
+    it "defaults the settings to the empty hash" do
  11
+      @file.settings.should == {}
  12
+    end
  13
+
  14
+    it "returns the file reference" do
  15
+      @file.file_ref = @project.new(PBXFileReference)
  16
+      @file.file_ref.class.should == PBXFileReference
  17
+    end
  18
+
  19
+    it "accepts a variant group and a version group as a reference" do
  20
+      lambda { @file.file_ref = @project.new(PBXVariantGroup) }.should.not.raise
  21
+      lambda { @file.file_ref = @project.new(XCVersionGroup) }.should.not.raise
  22
+    end
  23
+
  24
+  end
  25
+end
  26
+
45  spec/project/object/build_rule_spec.rb
... ...
@@ -0,0 +1,45 @@
  1
+require File.expand_path('../../../spec_helper', __FILE__)
  2
+
  3
+module ProjectSpecs
  4
+  describe PBXBuildRule do
  5
+
  6
+    before do
  7
+      @rule = @project.new(PBXBuildRule)
  8
+    end
  9
+
  10
+    it "returns the name" do
  11
+      @rule.name = "myRule"
  12
+      @rule.name.should == "myRule"
  13
+    end
  14
+
  15
+    it "returns the compiler spec" do
  16
+      @rule.compiler_spec = "com.apple.compilers.proxy.script"
  17
+      @rule.compiler_spec.should == "com.apple.compilers.proxy.script"
  18
+    end
  19
+
  20
+    it "returns the file type of the rule" do
  21
+      @rule.file_type = "pattern.proxy"
  22
+      @rule.file_type.should == "pattern.proxy"
  23
+    end
  24
+
  25
+    it "returns whether the rule is editable" do
  26
+      @rule.is_editable = '1'
  27
+      @rule.is_editable.should == '1'
  28
+    end
  29
+
  30
+    it "returns the output files of the rule" do
  31
+      f = @project.new(PBXFileReference)
  32
+      @rule.output_files << f
  33
+      @rule.output_files.count.should == 1
  34
+      @rule.output_files.should.include?(f)
  35
+    end
  36
+
  37
+    it "returns the script of the rule" do
  38
+      @rule.script = 'echo "BABY COOL"'
  39
+      @rule.script.should == 'echo "BABY COOL"'
  40
+    end
  41
+
  42
+  end
  43
+end
  44
+
  45
+
38  spec/project/object/configuration_list_spec.rb
... ...
@@ -0,0 +1,38 @@
  1
+require File.expand_path('../../../spec_helper', __FILE__)
  2
+
  3
+module ProjectSpecs
  4
+  describe XCBuildConfiguration do
  5
+
  6
+    before do
  7
+      @list = @project.new(XCConfigurationList)
  8
+    end
  9
+
  10
+    it "by the default the default configutation is not visible" do
  11
+      @list.default_configuration_is_visible.should == '0'
  12
+    end
  13
+
  14
+    it "returns the default configuration name" do
  15
+      @list.default_configuration_name = 'Release'
  16
+      @list.default_configuration_name.should == 'Release'
  17
+    end
  18
+
  19
+    it "returns the configurations" do
  20
+      configuration = @project.new(XCBuildConfiguration)
  21
+      @list.build_configurations.to_a.should == []
  22
+      @list.build_configurations << configuration
  23
+      @list.build_configurations.count.should == 1
  24
+      @list.build_configurations.should.include?(configuration)
  25
+    end
  26
+
  27
+    it "returns the build settings of a configuration given its name" do
  28
+      settings = { 'GCC_VERSION' => 'com.apple.compilers.llvm.clang.1_0'}
  29
+      configuration = @project.new(XCBuildConfiguration)
  30
+      configuration.name = 'Debug'
  31
+      configuration.build_settings =  settings
  32
+      @list.build_configurations << configuration
  33
+      @list.build_settings('Debug').should == settings
  34
+    end
  35
+
  36
+  end
  37
+end
  38
+
21  spec/project/object/configuration_spec.rb
... ...
@@ -1,21 +0,0 @@
1  
-require File.expand_path('../../../spec_helper', __FILE__)
2  
-
3  
-module ProjectSpecs
4  
-  describe "Xcodeproj::Project::Object::XCBuildConfiguration" do
5  
-
6  
-    before do
7  
-      @configuration = @project.new(XCBuildConfiguration)
8  
-    end
9  
-
10  
-    it "returns the xcconfig that this configuration is based on (baseConfigurationReference)" do
11  
-      xcconfig = @project.new_file(nil)
12  
-      @configuration.base_configuration_reference = xcconfig
13  
-      @configuration.base_configuration_reference.should.be.not.nil
14  
-    end
15  
-
16  
-    it "defaults the build settings to the empty hash" do
17  
-      @configuration.build_settings.should == {}
18  
-    end
19  
-
20  
-  end
21  
-end
33  spec/project/object/container_item_proxy_spec.rb
... ...
@@ -0,0 +1,33 @@
  1
+require File.expand_path('../../../spec_helper', __FILE__)
  2
+
  3
+module ProjectSpecs
  4
+  describe PBXContainerItemProxy do
  5
+
  6
+    before do
  7
+      @proxy = @project.new(PBXContainerItemProxy)
  8
+    end
  9
+
  10
+    it "returns the container portal" do
  11
+      @proxy.container_portal = @project.root_object
  12
+      @proxy.container_portal.should == @project.root_object
  13
+    end
  14
+
  15
+    it "returns the type of the proxy" do
  16
+      @proxy.proxy_type = "1"
  17
+      @proxy.proxy_type.should == "1"
  18
+    end
  19
+
  20
+    it "returns the remote global id string" do
  21
+      target = @project.new_target(:static, "Pods", :ios)
  22
+      @proxy.remote_global_id_string = target.uuid
  23
+      @proxy.remote_global_id_string.should == target.uuid
  24
+    end
  25
+
  26
+    it "returns the remote info" do
  27
+      @proxy.remote_info = "Pods"
  28
+      @proxy.remote_info.should == "Pods"
  29
+    end
  30
+
  31
+  end
  32
+end
  33
+
60  spec/project/object/root_object_spec.rb
... ...
@@ -0,0 +1,60 @@
  1
+require File.expand_path('../../../spec_helper', __FILE__)
  2
+
  3
+module ProjectSpecs
  4
+  describe PBXProject do
  5
+
  6
+    before do
  7
+      @project.new_target(:static, "Pods", :ios)
  8
+      @root_object = @project.root_object
  9
+    end
  10
+
  11
+    it "returns the targets" do
  12
+      @root_object.targets.map(&:name).should == ["Pods"]
  13
+    end
  14
+
  15
+    it "returns the attributes" do
  16
+      @root_object.attributes["LastUpgradeCheck"].should.not.be.nil
  17
+    end
  18
+
  19
+    it "returns the build configuration list" do
  20
+      @root_object.build_configuration_list.class.should == XCConfigurationList
  21
+    end
  22
+
  23
+    it "returns the compatibility version" do
  24
+      @root_object.compatibility_version.should.include("Xcode")
  25
+    end
  26
+
  27
+    it "returns the development region" do
  28
+      @root_object.development_region.should == "English"
  29
+    end
  30
+
  31
+    it "returns whether has scanned for encodings" do
  32
+      @root_object.has_scanned_for_encodings.should == '0'
  33
+    end
  34
+
  35
+    it "returns the known regions" do
  36
+      @root_object.known_regions.should == %w[en]
  37
+    end
  38
+
  39
+    it "returns the main group" do
  40
+      @root_object.main_group.class.should == PBXGroup
  41
+    end
  42
+
  43
+    it "returns the products group" do
  44
+      @root_object.product_ref_group.class.should == PBXGroup
  45
+    end
  46
+
  47
+    it "returns the project dir path" do
  48
+      @root_object.project_dir_path = "some/path"
  49
+      @root_object.project_dir_path.should == "some/path"
  50
+    end
  51
+
  52
+    it "returns the project root" do
  53
+      @root_object.project_root = "some/path"
  54
+      @root_object.project_root.should == "some/path"
  55
+    end
  56
+
  57
+  end
  58
+end
  59
+
  60
+
33  spec/project/object/target_dependency_spec.rb
... ...
@@ -0,0 +1,33 @@
  1
+require File.expand_path('../../../spec_helper', __FILE__)
  2
+
  3
+module ProjectSpecs
  4
+  describe PBXTargetDependency do
  5
+
  6
+    before do
  7
+      @dep = @project.new(PBXTargetDependency)
  8
+    end
  9
+
  10
+    it "returns the target on which this dependency is based" do
  11
+      @dep.target = @project.new_target(:static, "Pods", :ios)
  12
+      @dep.target.name.should == "Pods"
  13
+    end
  14
+
  15
+    it "returns the proxy of the target on which this dependency is based" do
  16
+      target = @project.new_target(:static, "Pods", :ios)
  17
+
  18
+      proxy = @project.new(PBXContainerItemProxy)
  19
+      proxy.container_portal = @project.root_object
  20
+      proxy.remote_info = "Pods"
  21
+      proxy.proxy_type = "1"
  22
+      proxy.remote_global_id_string = target.uuid
  23
+
  24
+      @dep.targetProxy = proxy
  25
+      @dep.targetProxy.remote_info.should == "Pods"
  26
+    end
  27
+
  28
+
  29
+  end
  30
+end
  31
+
  32
+
  33
+

0 notes on commit 5f19520

Please sign in to comment.
Something went wrong with that request. Please try again.