1
1
require File . expand_path ( '../../spec_helper' , __FILE__ )
2
2
3
- module Xcodeproj
4
- class Command
5
- class Create < Command
6
- self . arguments = [
7
- CLAide ::Argument . new ( 'PROJECT' , true ) ,
8
- ]
9
-
10
- def initialize ( argv )
11
- self . xcodeproj_path = argv . shift_argument
12
- super
13
- end
14
-
15
- def validate!
16
- super
17
- help! "Project file not specified" if self . xcodeproj_path . nil?
18
- end
19
- end
20
- end
21
- end
22
-
3
+ require 'fileutils'
23
4
24
5
describe Xcodeproj ::Command ::Create do
25
6
it 'errors if a project file has not been provided' do
@@ -30,7 +11,39 @@ def validate!
30
11
end
31
12
end
32
13
33
- it 'errors if the specified project file already exists'
14
+ it 'errors if the specified project already exists' do
15
+ project_dir = 'FooBar.xcodeproj'
16
+ FileUtils . mkdir ( project_dir )
17
+
18
+ argv = CLAide ::ARGV . new ( [ project_dir ] )
19
+ create = Xcodeproj ::Command ::Create . new ( argv )
20
+ should_raise_help 'Project already exists' do
21
+ create . validate!
22
+ end
23
+ ensure
24
+ FileUtils . rm_r ( project_dir )
25
+ end
26
+
27
+ it 'creates a project file' do
28
+ project_dir = 'FooBar.xcodeproj'
29
+ argv = CLAide ::ARGV . new ( [ project_dir ] )
30
+ create = Xcodeproj ::Command ::Create . new ( argv )
31
+ create . run
32
+
33
+ File . exist? ( project_dir ) . should . be . true
34
+ ensure
35
+ FileUtils . rm_r ( project_dir )
36
+ end
37
+
38
+ it 'adds the suffix if one is not provided' do
39
+ project_name = 'FooBar'
40
+ project_dir = 'FooBar.xcodeproj'
41
+ argv = CLAide ::ARGV . new ( [ project_name ] )
42
+ create = Xcodeproj ::Command ::Create . new ( argv )
43
+ create . run
34
44
35
- it 'creates a project file'
45
+ File . exist? ( project_dir ) . should . be . true
46
+ ensure
47
+ FileUtils . rm_r ( project_dir )
48
+ end
36
49
end
0 commit comments