yolo 1.1.11 → 1.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  yolo
2
2
  ====
3
3
 
4
+ [![Code Climate](https://codeclimate.com/github/alexefish/yolo.png)](https://codeclimate.com/github/alexefish/yolo)
5
+ [![Coverage Status](https://coveralls.io/repos/alexefish/yolo/badge.png?branch=master)](https://coveralls.io/r/alexefish/yolo)
6
+ [![Build Status](https://travis-ci.org/alexefish/yolo.png)](https://travis-ci.org/alexefish/yolo)
7
+
4
8
  yolo is a RubyGem which provides a Ruby interface to Continuous Integration build tools. yolo is currently geared towards the Xcode toolchain and iOS development.
5
9
 
6
10
  yolo allows you to run a number of continuous integration tasks and is best implemented with an installation of [Jenkins](http://jenkins-ci.org/).
data/Rakefile CHANGED
@@ -5,6 +5,6 @@ namespace :gem do
5
5
  desc "Builds and then installs the gem"
6
6
  task :buildinstall do
7
7
  system 'gem build yolo.gemspec'
8
- system 'gem install yolo-1.1.9.pre.gem'
8
+ system 'gem install yolo-1.1.12.pre.gem'
9
9
  end
10
10
  end
@@ -21,6 +21,12 @@ module Yolo
21
21
  @error = Yolo::Formatters::ErrorFormatter.new
22
22
  check_config
23
23
  update_config
24
+ end
25
+
26
+ #
27
+ # Loads the @yaml instance var
28
+ #
29
+ def load_yaml
24
30
  @yaml = YAML::load_file yaml_path
25
31
  end
26
32
 
@@ -35,6 +41,40 @@ module Yolo
35
41
  end
36
42
  end
37
43
 
44
+ #
45
+ # Checks for the existance of the config directory in the users home directory and creates it if not present
46
+ #
47
+ def check_config
48
+ unless File.directory?(yolo_dir) and File.exist?(yaml_path)
49
+ @error.run_setup
50
+ load_config
51
+ @formatter.setup_complete
52
+ end
53
+ end
54
+
55
+ #
56
+ # Checks the config file is update to the latest and adds any options that are missing
57
+ #
58
+ def update_config
59
+ if File.directory?(yolo_dir) and File.exist?(yaml_path)
60
+ @yaml = YAML::load_file yaml_path
61
+ unless @yaml["deployment"]["api_token"]
62
+ @yaml["deployment"]["api_token"] = "example"
63
+ File.open(yaml_path, 'w') {|f|
64
+ f.write(@yaml.to_yaml)
65
+ }
66
+ @formatter.config_updated(yaml_path)
67
+ end
68
+ unless @yaml["deployment"]["team_token"]
69
+ @yaml["deployment"]["team_token"] = "example"
70
+ File.open(yaml_path, 'w') {|f|
71
+ f.write(@yaml.to_yaml)
72
+ }
73
+ @formatter.config_updated(yaml_path)
74
+ end
75
+ end
76
+ end
77
+
38
78
  #
39
79
  # The bundle_directory option is the directory which applications are bundled too
40
80
  #
@@ -107,46 +147,12 @@ module Yolo
107
147
  @yaml["mail"]["from"] if @yaml["mail"]["from"] and @yaml["mail"]["from"] != "example@example.com"
108
148
  end
109
149
 
110
- #
111
- # Checks for the existance of the config directory in the users home directory and creates it if not present
112
- #
113
- def check_config
114
- unless File.directory?(yolo_dir) and File.exist?(yaml_path)
115
- @error.run_setup
116
- load_config
117
- @formatter.setup_complete
118
- end
119
- end
120
-
121
- #
122
- # Checks the config file is update to the latest and adds any options that are missing
123
- #
124
- def update_config
125
- if File.directory?(yolo_dir) and File.exist?(yaml_path)
126
- @yaml = YAML::load_file yaml_path
127
- unless @yaml["deployment"]["api_token"]
128
- @yaml["deployment"]["api_token"] = "example"
129
- File.open(yaml_path, 'w') {|f|
130
- f.write(@yaml.to_yaml)
131
- }
132
- @formatter.config_updated(yaml_path)
133
- end
134
- unless @yaml["deployment"]["team_token"]
135
- @yaml["deployment"]["team_token"] = "example"
136
- File.open(yaml_path, 'w') {|f|
137
- f.write(@yaml.to_yaml)
138
- }
139
- @formatter.config_updated(yaml_path)
140
- end
141
- end
142
- end
143
-
144
150
  #
145
151
  # The path to the users home directory, same as ~
146
152
  #
147
153
  # @return [String] The full path to the current users home directory
148
154
  def user_directory
149
- File.expand_path('~')
155
+ Dir.pwd
150
156
  end
151
157
 
152
158
  #
@@ -1,4 +1,4 @@
1
- opts={}, module Yolo
1
+ module Yolo
2
2
  module Deployment
3
3
 
4
4
  #
@@ -58,17 +58,13 @@ module Yolo
58
58
  IO.popen("curl #{self.url} -X POST -# -F fileContent=@\"#{self.package_path}\" -F params='#{package}'") do |io|
59
59
  begin
60
60
  while line = io.readline
61
- begin
62
- response << line
63
- rescue StandardError => e
64
- @error_formatter.deploy_failed("ParserError: #{e}")
65
- end
61
+ response << line
66
62
  end
67
63
  rescue EOFError
68
- #@error_formatter.deploy_failed("ParserError")
69
- end
64
+ @error_formatter.deploy_failed("Upload error")
65
+ end
70
66
  end
71
- upload_complete(response)
67
+ upload_complete(response) if response.length > 0
72
68
  end
73
69
 
74
70
  #
@@ -7,6 +7,23 @@ module Yolo
7
7
  # @author [Alex Fish]
8
8
  #
9
9
  class Build < Yolo::Tasks::BaseTask
10
+
11
+ #
12
+ # Overrides the superclass build_opts_string method and appends skip code sign command
13
+ # if debug confid is defined
14
+ #
15
+ # @param additional_opts [Array] an array of additional options for the build command
16
+ #
17
+ # @return [String] the option string with additional options and test output
18
+ # pipe appended if defined
19
+ def build_opts_string(*additional_opts)
20
+ options = build_opts + additional_opts
21
+ if configuration == "Debug" or configuration.nil?
22
+ options = options << "CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO"
23
+ end
24
+ return options.compact.join(" ")
25
+ end
26
+
10
27
  #
11
28
  # Defines rake tasks available to the Build class
12
29
  #
@@ -32,12 +32,10 @@ module Yolo
32
32
  commit = latest_commit
33
33
  if yaml_commit == commit
34
34
  @formatter.no_new_commit
35
- @commit = nil
36
35
  false
37
36
  else
38
37
  @formatter.new_commit(commit)
39
38
  update_commit(commit)
40
- @commit = commit
41
39
  true
42
40
  end
43
41
  end
@@ -52,12 +50,10 @@ module Yolo
52
50
  tag = latest_tag
53
51
  if yaml_tag == tag
54
52
  @formatter.no_new_tag
55
- @tag = nil
56
53
  false
57
54
  else
58
55
  @formatter.new_tag(tag)
59
56
  update_tag(tag)
60
- @tag = tag
61
57
  true
62
58
  end
63
59
  end
@@ -86,6 +82,7 @@ module Yolo
86
82
  # @param new_tag [String] The new tag to store as the latest
87
83
  #
88
84
  def update_tag(new_tag)
85
+ @tag = new_tag
89
86
  if @yaml[project_name]
90
87
  @yaml[project_name]["tag"] = new_tag
91
88
  else
@@ -99,6 +96,7 @@ module Yolo
99
96
  # @param new_commit [String] The new commit hash to store as the latest
100
97
  #
101
98
  def update_commit(new_commit)
99
+ @commit = new_commit
102
100
  if @yaml[project_name]
103
101
  @yaml[project_name]["commit"] = new_commit
104
102
  else
@@ -122,11 +120,11 @@ module Yolo
122
120
  #
123
121
  # @return [String] The tag
124
122
  def latest_tag
125
- match = log.scan(/tag:\sv?[0-9]*\.[0-9]*\.[0-9]*[a-zA-Z]*?/).first
123
+ match = log.scan(/tag:\s(.+?),\s/).first
126
124
  if match.nil?
127
125
  ""
128
126
  else
129
- match
127
+ match.first
130
128
  end
131
129
  end
132
130
 
@@ -20,7 +20,7 @@ module Yolo
20
20
  begin
21
21
  while line = io.readline
22
22
  begin
23
- STDOUT << line
23
+ puts line
24
24
  rescue StandardError => e
25
25
  puts "Error from output buffer: #{e.inspect}"
26
26
  puts e.backtrace
@@ -29,7 +29,7 @@ module Yolo
29
29
  rescue EOFError
30
30
  end
31
31
  end
32
- $?.exitstatus
32
+ $?.exitstatus if $?
33
33
  end
34
34
  end
35
35
  end
@@ -23,17 +23,13 @@ module Yolo
23
23
  IO.popen("cd #{build_path} && gcovr --xml > #{output_dir}/coverage.xml") do |io|
24
24
  begin
25
25
  while line = io.readline
26
- begin
27
- STDOUT << line
28
- rescue StandardError => e
29
- puts "Error from output buffer: #{e.inspect}"
30
- puts e.backtrace
31
- end
26
+ puts line
32
27
  end
33
28
  rescue EOFError
29
+ puts "Error while executing"
34
30
  end
35
31
  end
36
- $?.exitstatus
32
+ $?.exitstatus if $?
37
33
  end
38
34
  end
39
35
  end
@@ -17,24 +17,64 @@ module Yolo
17
17
  def self.generate(app_path,dsym_path,output_directory, &block)
18
18
  formatter = Yolo::Formatters::ProgressFormatter.new
19
19
  formatter.generating_ipa
20
- ipa_name = app_path.split("/").last.split(".").first
20
+ name = self.app_name(app_path)
21
+ # create directory
22
+ self.create_directory(output_directory)
23
+ # make ipa
24
+ `/usr/bin/xcrun -sdk iphoneos PackageApplication -v #{app_path} -o #{output_directory}/#{name}.ipa`
25
+ # move files
26
+ self.move_file(dsym_path,output_directory)
27
+ self.move_release_notes(output_directory)
28
+
29
+ formatter.ipa_generated("#{output_directory}/#{name}.ipa")
30
+
31
+ block.call("#{output_directory}/#{name}.ipa") if block
32
+ end
33
+
34
+ private
35
+
36
+ #
37
+ # Calculates the application name form the .app path
38
+ #
39
+ # @param app_path [String] The full path to the .app file
40
+ # @return [String] The name of the app
41
+ def self.app_name(app_path)
42
+ app_path.split("/").last.split(".").first
43
+ end
21
44
 
22
- unless File.directory?(output_directory)
23
- FileUtils.mkdir_p(output_directory)
45
+ #
46
+ # Creates a directory if missing
47
+ # @param directory [String] The path to the directory to create
48
+ #
49
+ def self.create_directory(directory)
50
+ unless File.directory?(directory)
51
+ FileUtils.mkdir_p(directory)
24
52
  end
53
+ end
25
54
 
26
- # make ipa
27
- `/usr/bin/xcrun -sdk iphoneos PackageApplication -v #{app_path} -o #{output_directory}/#{ipa_name}.ipa`
55
+ #
56
+ # Moves a file to a location
57
+ # @param file [String] The path to the file to move
58
+ # @param directory [String] The path to the directory to move the file to
59
+ #
60
+ def self.move_file(file, directory)
28
61
  # move dsym
29
- FileUtils.cp_r(dsym_path, output_directory) if dsym_path
62
+ FileUtils.cp_r(file, directory) if file
63
+ end
64
+
65
+ #
66
+ # Moves the projects releas notes file to a location
67
+ # @param output_directory [type] [description]
68
+ #
69
+ # @return [type] [description]
70
+ def self.move_release_notes(directory)
30
71
  # move release notes
31
72
  release_path = "#{Dir.pwd}/release_notes.md"
32
- FileUtils.cp_r(release_path, output_directory) if File.exist?(release_path)
33
-
34
- formatter.ipa_generated("#{output_directory}/#{ipa_name}.ipa")
35
-
36
- block.call("#{output_directory}/#{ipa_name}.ipa") if block
73
+ if File.exist?(directory) and File.exist?(release_path)
74
+ FileUtils.cp_r(release_path, directory)
75
+ end
37
76
  end
77
+
38
78
  end
39
79
  end
40
80
  end
@@ -1,4 +1,4 @@
1
- require 'Redcarpet'
1
+ require 'redcarpet'
2
2
 
3
3
  module Yolo
4
4
  module Tools
@@ -1,4 +1,4 @@
1
- require 'CFPropertyList'
1
+ require 'cfpropertylist'
2
2
 
3
3
  module Yolo
4
4
  module Tools
@@ -17,17 +17,11 @@ module Yolo
17
17
  #
18
18
  # Creates a new instance of Xcode with the default preferences p list location loaded
19
19
  #
20
+ # @param info_plist_path [String] The full path to an xcode projects info_plist
20
21
  # @return [Xcode] An Xcode instance
21
- def initialize
22
- self.prefs_plist_path = "#{user_directory}/Library/Preferences/com.apple.dt.Xcode.plist"
23
- end
24
-
25
- #
26
- # The current users home directory path
27
- #
28
- # @return [String] The path to the current users home directory, same as ~
29
- def user_directory
30
- File.expand_path('~')
22
+ def initialize(info_plist_path = "")
23
+ self.prefs_plist_path = "#{Dir.pwd}/Library/Preferences/com.apple.dt.Xcode.plist"
24
+ self.info_plist_path = info_plist_path
31
25
  end
32
26
 
33
27
  #
@@ -45,7 +39,7 @@ module Yolo
45
39
  # @return [String] The full path to Xcode's build location
46
40
  def build_path
47
41
  path = prefs["IDECustomDerivedDataLocation"]
48
- path = "#{user_directory}/Library/Developer/Xcode/DerivedData" unless path
42
+ path = "#{Dir.pwd}/Library/Developer/Xcode/DerivedData" unless path
49
43
  path
50
44
  end
51
45
 
@@ -54,7 +48,7 @@ module Yolo
54
48
  #
55
49
  # @return [Hash] A hash representation of the instances info.plist
56
50
  def info_plist
57
- if info_plist_path.length > 0
51
+ if info_plist_path
58
52
  plist = CFPropertyList::List.new(:file => info_plist_path)
59
53
  CFPropertyList.native_types(plist.value)
60
54
  else
@@ -0,0 +1,128 @@
1
+ require 'spec_helper'
2
+ require "yolo/config/settings"
3
+ require 'yolo/formatters'
4
+
5
+ describe Yolo::Config::Settings do
6
+
7
+ before do
8
+ Yolo::Config::Settings.instance.stub(:yolo_dir){"test_dir"}
9
+ FileUtils.stub(:cp_r)
10
+ FileUtils.stub(:mkdir_p)
11
+ Yolo::Formatters::ProgressFormatter.any_instance.stub(:puts)
12
+ Yolo::Formatters::ErrorFormatter.any_instance.stub(:puts)
13
+ end
14
+
15
+ it "should be a singleton" do
16
+ Yolo::Config::Settings.instance.should_not eq(nil)
17
+ end
18
+
19
+ describe "when loading the config" do
20
+ it "should not load if already loaded" do
21
+ File.stub(:exist?){true}
22
+ File.stub(:directory?){true}
23
+ Yolo::Config::Settings.instance.should_not_receive(:load_config)
24
+ Yolo::Config::Settings.instance.check_config
25
+ end
26
+
27
+ it "should load if not loaded" do
28
+ File.stub(:exist?){false}
29
+ File.stub(:directory?){false}
30
+ Yolo::Config::Settings.instance.should_receive(:load_config)
31
+ Yolo::Config::Settings.instance.check_config
32
+ end
33
+
34
+ it "should create the yolo directory" do
35
+ File.stub(:directory?){false}
36
+ FileUtils.should_receive(:mkdir_p).with("test_dir")
37
+ Yolo::Config::Settings.instance.create_yolo_dir
38
+ end
39
+
40
+ it "should not create the yolo directory if it exists" do
41
+ File.stub(:directory?){true}
42
+ FileUtils.should_not_receive(:mkdir_p).with("test_dir")
43
+ Yolo::Config::Settings.instance.create_yolo_dir
44
+ end
45
+ end
46
+
47
+ describe "when updating the config" do
48
+ before do
49
+ File.stub(:open)
50
+ File.stub(:exist?){true}
51
+ File.stub(:directory?){true}
52
+ end
53
+
54
+ it "should add an api token if missing" do
55
+ @yaml = {"deployment" => {"api_token" => nil}}
56
+ YAML.stub(:load_file){@yaml}
57
+ Yolo::Config::Settings.instance.update_config
58
+ @yaml["deployment"]["api_token"].should eq("example")
59
+ end
60
+
61
+ it "should add an team token if missing" do
62
+ @yaml = {"deployment" => {"team_token" => nil}}
63
+ YAML.stub(:load_file){@yaml}
64
+ Yolo::Config::Settings.instance.update_config
65
+ @yaml["deployment"]["team_token"].should eq("example")
66
+ end
67
+ end
68
+
69
+ describe "when asked for settings" do
70
+ before do
71
+ @yaml = {
72
+ "paths" => {
73
+ "bundle_directory" => "test_directory"
74
+ },
75
+ "deployment" => {
76
+ "url" => "test_url",
77
+ "api_token" => "test_token",
78
+ "team_token" => "test_team_token",
79
+ },
80
+ "mail" => {
81
+ "account" => "test_account",
82
+ "password" => "test_password",
83
+ "port" => "test_port",
84
+ "host" => "test_host",
85
+ "from" => "test_from"
86
+ }
87
+ }
88
+ YAML.stub(:load_file){@yaml}
89
+ Yolo::Config::Settings.instance.load_yaml
90
+ end
91
+
92
+ it "should hold a bundle directory" do
93
+ Yolo::Config::Settings.instance.bundle_directory.should eq("test_directory")
94
+ end
95
+
96
+ it "should hold a deploy url" do
97
+ Yolo::Config::Settings.instance.deploy_url.should eq("test_url")
98
+ end
99
+
100
+ it "should hold a deploy token" do
101
+ Yolo::Config::Settings.instance.api_token.should eq("test_token")
102
+ end
103
+
104
+ it "should hold a deploy team token" do
105
+ Yolo::Config::Settings.instance.team_token.should eq("test_team_token")
106
+ end
107
+
108
+ it "should hold a mail account" do
109
+ Yolo::Config::Settings.instance.mail_account.should eq("test_account")
110
+ end
111
+
112
+ it "should hold a mail password" do
113
+ Yolo::Config::Settings.instance.mail_password.should eq("test_password")
114
+ end
115
+
116
+ it "should hold a mail port" do
117
+ Yolo::Config::Settings.instance.mail_port.should eq("test_port")
118
+ end
119
+
120
+ it "should hold a mail host" do
121
+ Yolo::Config::Settings.instance.mail_host.should eq("test_host")
122
+ end
123
+
124
+ it "should hold a mail from" do
125
+ Yolo::Config::Settings.instance.mail_from.should eq("test_from")
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'yolo/deployment'
3
+ require 'yolo/formatters'
4
+ require 'yolo/config'
5
+
6
+ describe Yolo::Deployment::BaseDeployer do
7
+
8
+ describe "when initilized" do
9
+ it "should load a deploy url from settings" do
10
+ Yolo::Config::Settings.instance.stub(:deploy_url){"test_url"}
11
+ @deployer = Yolo::Deployment::BaseDeployer.new
12
+ @deployer.url.should eq("test_url")
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,109 @@
1
+ require 'spec_helper'
2
+ require 'yolo/deployment'
3
+ require 'yolo/formatters'
4
+ require 'yolo/config'
5
+ require 'json'
6
+
7
+ describe Yolo::Deployment::OTA do
8
+
9
+ before do
10
+ @error_formatter = Yolo::Formatters::ErrorFormatter.new
11
+ Yolo::Formatters::ErrorFormatter.stub(:new){@error_formatter}
12
+
13
+ Yolo::Formatters::ErrorFormatter.any_instance.stub(:puts)
14
+ Yolo::Formatters::ProgressFormatter.any_instance.stub(:puts)
15
+ Yolo::Formatters::ProgressFormatter.any_instance.stub(:deploying_ipa)
16
+
17
+ @ota = Yolo::Deployment::OTA.new
18
+ end
19
+
20
+ describe "when deploying" do
21
+
22
+ before do
23
+ @ota.stub(:upload)
24
+ end
25
+
26
+ after do
27
+ @ota = Yolo::Deployment::OTA.new
28
+ end
29
+
30
+ it "should deploy a package" do
31
+ @ota.should_receive(:upload)
32
+ @ota.url = "test"
33
+ @ota.deploy("test_path")
34
+ @ota.package_path.should eq("test_path")
35
+ end
36
+
37
+ it "should not deploy without a deploy url" do
38
+ @ota.should_not_receive(:upload)
39
+ @ota.url = nil
40
+ @ota.deploy("test_path")
41
+ end
42
+ end
43
+
44
+ describe "when packaging" do
45
+ it "should get the file name from the path" do
46
+ @ota.package_path = "path/to/filename.app"
47
+ @ota.package.should match(/\"fileName\": \"filename.app\"/)
48
+ end
49
+
50
+ it "should set an expiry date" do
51
+ @ota.package_path = "path/to/filename.app"
52
+ @ota.package.should match(/\"validUntil\"/)
53
+ end
54
+ end
55
+
56
+ describe "when uploading" do
57
+ before do
58
+ @io = mock(IO)
59
+ @io.stub(:readline)
60
+ @ota.stub(:package)
61
+ IO.stub(:popen).and_yield(@io)
62
+ end
63
+
64
+ it "should curl to the correct url" do
65
+ @ota.url = "test.com"
66
+ IO.should_receive(:popen).with(/curl test.com/)
67
+ @ota.upload
68
+ end
69
+
70
+ it "should catch EOFError exceptions" do
71
+ @io.stub(:readline).and_raise(EOFError)
72
+ @error_formatter.should_receive(:deploy_failed).at_least(1).times
73
+ @ota.upload
74
+ end
75
+
76
+ it "should parse the response" do
77
+ @io.stub(:readline).and_return("response string", nil)
78
+ @ota.should_receive(:upload_complete).with("response string")
79
+ @ota.upload
80
+ end
81
+
82
+ it "should not complete with a nil response" do
83
+ @io.should_not_receive(:upload_complete)
84
+ @ota.upload
85
+ end
86
+ end
87
+
88
+ describe "on completion" do
89
+
90
+ before do
91
+ @ota.stub(:upload)
92
+ @json = "{'link':'test_link','password','test_password'}"
93
+ end
94
+
95
+ it "should catch json parse errors" do
96
+ @error_formatter.should_receive(:deploy_failed)
97
+ @ota.upload_complete("json")
98
+ end
99
+
100
+ it "should parse the response" do
101
+ @ota.upload_complete(@json)
102
+ @ota.deploy("test", nil) do |url, password|
103
+ password.should eq("test_password")
104
+ url.should eq("test_link")
105
+ end
106
+ end
107
+
108
+ end
109
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'yolo/deployment'
3
+ require 'yolo/formatters'
4
+
5
+ describe Yolo::Deployment::TestFlight do
6
+ pending "all tests" do
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'yolo/notify/email'
3
+ require 'yolo/formatters'
4
+
5
+ describe Yolo::Notify::Email do
6
+ pending "all tests" do
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+ require 'yolo/notify/email'
3
+ require 'yolo/notify/ios'
4
+ require 'yolo/formatters'
5
+
6
+ describe Yolo::Notify::Ios::OTAEmail do
7
+ pending "all tests" do
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ RSpec.configure do |config|
5
+ # Use color in STDOUT
6
+ config.color_enabled = true
7
+
8
+ # Use color not only in STDOUT but also in pagers and files
9
+ config.tty = true
10
+
11
+ # Use the specified formatter
12
+ config.formatter = :documentation # :progress, :html, :textmate
13
+ end
@@ -0,0 +1,123 @@
1
+ require 'spec_helper'
2
+ require 'yolo/tools/git'
3
+ require 'yolo/formatters'
4
+
5
+ describe Yolo::Tools::Git do
6
+
7
+ before do
8
+ @git = Yolo::Tools::Git.new
9
+ @git.project_name = "test"
10
+ YAML.stub!(:load_file){{}}
11
+ Yolo::Formatters::ProgressFormatter.any_instance.stub(:puts)
12
+ end
13
+
14
+ describe "when checking for new commits" do
15
+ before do
16
+ @git.stub(:update_commit)
17
+ end
18
+
19
+ it "should recognise new commits" do
20
+ Yolo::Tools::Git.any_instance.stub(:yaml_commit){"new"}
21
+ Yolo::Tools::Git.any_instance.stub(:latest_commit){"old"}
22
+ @git.has_new_commit("").should eq(true)
23
+ end
24
+
25
+ it "should recognise existing commits" do
26
+ Yolo::Tools::Git.any_instance.stub(:yaml_commit){"old"}
27
+ Yolo::Tools::Git.any_instance.stub(:latest_commit){"old"}
28
+ @git.has_new_commit("").should eq(false)
29
+ end
30
+ end
31
+
32
+ describe "when checking for new tags" do
33
+ before do
34
+ @git.stub(:update_tag)
35
+ end
36
+
37
+ it "should recognise new tags" do
38
+ Yolo::Tools::Git.any_instance.stub(:yaml_tag){"old"}
39
+ Yolo::Tools::Git.any_instance.stub(:latest_tag){"new"}
40
+ @git.has_new_tag("").should eq(true)
41
+ end
42
+
43
+ it "should recognise existing tags" do
44
+ Yolo::Tools::Git.any_instance.stub(:yaml_tag){"old"}
45
+ Yolo::Tools::Git.any_instance.stub(:latest_tag){"old"}
46
+ @git.has_new_tag("").should eq(false)
47
+ end
48
+ end
49
+
50
+ describe "when updating tags and commits" do
51
+
52
+ before do
53
+ @git.stub(:save_yaml)
54
+ end
55
+
56
+ it "should keep track of the latest tag" do
57
+ @git.instance_eval{update_tag("new tag")}
58
+ @git.tag.should match("new tag")
59
+ end
60
+
61
+ it "should keep track of the latest commit" do
62
+ @git.instance_eval{update_commit("new commit")}
63
+ @git.commit.should match("new commit")
64
+ end
65
+
66
+ it "should store the latest tag" do
67
+ @git.instance_eval{update_tag("new tag")}
68
+ @git.instance_eval{yaml_tag}.should match("new tag")
69
+ end
70
+
71
+ it "should store the latest commit" do
72
+ @git.instance_eval{update_commit("new commit")}
73
+ @git.instance_eval{yaml_commit}.should match("new commit")
74
+ end
75
+
76
+ end
77
+
78
+ describe "when saving data" do
79
+ it "should save data to disk" do
80
+ test_file = mock(File)
81
+ test_file.stub(:write)
82
+ File.stub(:open).and_yield(test_file)
83
+ test_file.should_receive(:write)
84
+
85
+ @git.instance_eval{save_yaml}
86
+ end
87
+ end
88
+
89
+ describe "when checking for new data" do
90
+
91
+ it "should use git log" do
92
+ @git.should_receive(:`).with(/git log/)
93
+ @git.instance_eval{log}
94
+ end
95
+
96
+ it "should get the latest tag" do
97
+ @git.stub(:log){"tag: v1.0, head, tag: v1.3.1"}
98
+ @git.instance_eval{latest_tag}.should eq("v1.0")
99
+ end
100
+
101
+ it "should recognise invalid tags" do
102
+ @git.stub(:log){"junk"}
103
+ @git.instance_eval{latest_tag}.should eq("")
104
+ end
105
+
106
+ it "should get the latest commit" do
107
+ @git.stub(:log){"0e4672b678"}
108
+ @git.instance_eval{latest_commit}.should eq("0e4672b678")
109
+ end
110
+
111
+ it "should recognise invalid commits" do
112
+ @git.stub(:log){"junk"}
113
+ @git.instance_eval{latest_commit}.should eq("")
114
+ end
115
+
116
+ it "should get the current branch" do
117
+ @git.stub(:`){
118
+ "branch\n* activebranch"
119
+ }
120
+ @git.instance_eval{current_branch}.should eq("activebranch")
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'yolo/tools/ios/calabash'
3
+
4
+ describe Yolo::Tools::Ios::Calabash do
5
+
6
+ before do
7
+ IO.stub(:popen)
8
+ end
9
+
10
+ describe "when running " do
11
+
12
+ it "should execute the cucumber command" do
13
+ IO.should_receive(:popen).with(/cucumber/)
14
+ Yolo::Tools::Ios::Calabash.run()
15
+ end
16
+
17
+ it "should pass junit as the default format" do
18
+ IO.should_receive(:popen).with(/--format junit/)
19
+ Yolo::Tools::Ios::Calabash.run()
20
+ end
21
+
22
+ it "pass test-reports/cucumber as the default output directory" do
23
+ IO.should_receive(:popen).with(/--out test-reports\/cucumber/)
24
+ Yolo::Tools::Ios::Calabash.run()
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'yolo/tools/ios/coverage'
3
+ require 'yolo/formatters'
4
+
5
+ describe Yolo::Tools::Ios::Coverage do
6
+
7
+ before do
8
+ Yolo::Formatters::ErrorFormatter.any_instance.stub(:puts)
9
+ IO.stub(:popen)
10
+ end
11
+
12
+ describe "when calculating coverage" do
13
+ it "should require a build path" do
14
+ IO.should_not_receive(:popen)
15
+ Yolo::Tools::Ios::Coverage.calculate("","test")
16
+ end
17
+
18
+ it "should require a output path" do
19
+ IO.should_not_receive(:popen)
20
+ Yolo::Tools::Ios::Coverage.calculate("test","")
21
+ end
22
+
23
+ it "should execute gcovr" do
24
+ IO.should_receive(:popen).with(/gcovr/)
25
+ Yolo::Tools::Ios::Coverage.calculate("test","test")
26
+ end
27
+
28
+ it "should execute at the build path" do
29
+ IO.should_receive(:popen).with(/cd test/)
30
+ Yolo::Tools::Ios::Coverage.calculate("test","test")
31
+ end
32
+
33
+ it "should output xml to the output path" do
34
+ IO.should_receive(:popen).with(/--xml > test\/coverage.xml/)
35
+ Yolo::Tools::Ios::Coverage.calculate("test","test")
36
+ end
37
+ end
38
+
39
+ describe "when calculating coverage fails" do
40
+
41
+ before do
42
+ @io = mock(IO)
43
+ IO.stub(:popen).and_yield(@io)
44
+ end
45
+
46
+ it "should catch EOFError exceptions" do
47
+ @io.stub(:readline).and_raise(EOFError)
48
+ Yolo::Tools::Ios::Coverage.should_receive(:puts)
49
+ Yolo::Tools::Ios::Coverage.calculate("test","test")
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,107 @@
1
+ require 'spec_helper'
2
+ require 'yolo/tools/ios/ipa'
3
+ require 'yolo/formatters'
4
+
5
+ describe Yolo::Tools::Ios::IPA do
6
+
7
+ before do
8
+ @ipa = Yolo::Tools::Ios::IPA
9
+ Yolo::Formatters::ProgressFormatter.any_instance.stub(:puts)
10
+ end
11
+
12
+ describe "when generating an ipa" do
13
+ before do
14
+ @ipa.stub(:`)
15
+ @ipa.stub(:move_file)
16
+ @ipa.stub(:move_release_notes)
17
+ FileUtils.stub(:mkdir_p)
18
+ end
19
+
20
+ it "should return the ipa path" do
21
+ @ipa.stub(:app_name){"name"}
22
+ @ipa.generate("","","output") do |ipa|
23
+ ipa.should eq("output/name.ipa")
24
+ end
25
+ end
26
+
27
+ it "should calculate the name from the app path" do
28
+ @ipa.app_name("/path/to/app/test.app").should eq("test")
29
+ end
30
+
31
+ describe "and executing" do
32
+ it "should execute xcrun" do
33
+ @ipa.stub(:app_name)
34
+ @ipa.should_receive(:`).with(/\/usr\/bin\/xcrun/)
35
+ @ipa.generate("","","")
36
+ end
37
+
38
+ it "should pacakge the app" do
39
+ @ipa.stub(:app_name)
40
+ @ipa.should_receive(:`).with(/PackageApplication -v app\/path/)
41
+ @ipa.generate("app/path","","")
42
+ end
43
+
44
+ it "should set the sdk to iphoneos" do
45
+ @ipa.stub(:app_name)
46
+ @ipa.should_receive(:`).with(/-sdk iphoneos/)
47
+ @ipa.generate("","","")
48
+ end
49
+ end
50
+
51
+ describe "and outputting the ipa" do
52
+ before do
53
+ @ipa.stub(:app_name)
54
+ end
55
+
56
+ it "should create an output directory if missing" do
57
+ File.stub(:directory?){false}
58
+ FileUtils.should_receive(:mkdir_p).with("output/path")
59
+ @ipa.create_directory("output/path")
60
+ end
61
+
62
+ it "should output to the output directory" do
63
+ @ipa.stub(:create_directory)
64
+ @ipa.stub(:app_name){"test"}
65
+ @ipa.should_receive(:`).with(/-o output\/path\/test.ipa/)
66
+ @ipa.generate("","","output/path")
67
+ end
68
+
69
+ it "should move files into place" do
70
+ @ipa.should_receive(:move_file)
71
+ @ipa.generate("","","")
72
+ end
73
+
74
+ it "should move release notes into place" do
75
+ @ipa.should_receive(:move_release_notes)
76
+ @ipa.generate("","","")
77
+ end
78
+ end
79
+ end
80
+
81
+ describe "when moving files" do
82
+ it "should move them" do
83
+ FileUtils.stub(:cp_r)
84
+ FileUtils.should_receive(:cp_r).with("file","dir")
85
+ @ipa.move_file("file","dir")
86
+ end
87
+
88
+ it "should not attempt to move nil files" do
89
+ FileUtils.should_not_receive(:cp_r)
90
+ @ipa.move_file(nil,"dir")
91
+ end
92
+
93
+ it "should move release notes" do
94
+ Dir.stub(:pwd){"path"}
95
+ File.stub("exist?"){true}
96
+ FileUtils.should_receive(:cp_r).with("path/release_notes.md", "dir")
97
+ @ipa.move_release_notes("dir")
98
+ end
99
+
100
+ it "should not attempt to move nil" do
101
+ File.stub("exist?"){false}
102
+ Dir.stub(:pwd){"path"}
103
+ FileUtils.should_not_receive(:cp_r)
104
+ @ipa.move_release_notes("dir")
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,100 @@
1
+ require 'spec_helper'
2
+ require 'yolo/tools/ios/xcode'
3
+ require 'yolo/tools/ios/release_notes'
4
+ require 'yolo/formatters'
5
+
6
+ describe Yolo::Tools::Ios::ReleaseNotes do
7
+
8
+ before do
9
+ @xcode = Yolo::Tools::Ios::Xcode.new
10
+ Yolo::Tools::Ios::Xcode.stub(:new){@xcode}
11
+ @xcode.stub(:info_plist_path)
12
+ @xcode.stub(:version_number)
13
+ @xcode.stub(:build_number)
14
+ @release_notes = Yolo::Tools::Ios::ReleaseNotes
15
+ Yolo::Formatters::ErrorFormatter.any_instance.stub(:puts)
16
+ Yolo::Formatters::ProgressFormatter.any_instance.stub(:puts)
17
+ end
18
+
19
+ describe "When generating release notes" do
20
+
21
+ before do
22
+ Dir.stub(:pwd){"current_path"}
23
+ @file = mock(File)
24
+ @file.stub(:write)
25
+ File.stub(:open).and_yield(@file)
26
+ @release_notes.stub(:`)
27
+ end
28
+
29
+ it "should pass a plist path to xcode" do
30
+ @xcode.should_receive(:info_plist_path=).with("path")
31
+ @release_notes.generate("path")
32
+ end
33
+
34
+ it "should use the current directory" do
35
+ Dir.should_receive(:pwd)
36
+ @release_notes.generate("path")
37
+ end
38
+
39
+ it "should use the builds version number" do
40
+ @xcode.should_receive(:version_number)
41
+ @release_notes.generate("path")
42
+ end
43
+
44
+ it "should use the builds build number" do
45
+ @xcode.should_receive(:build_number)
46
+ @release_notes.generate("path")
47
+ end
48
+
49
+ it "should use the current time" do
50
+ @time = Time.new
51
+ Time.stub(:new){@time}
52
+ @time.should_receive(:day)
53
+ @time.should_receive(:month)
54
+ @time.should_receive(:year)
55
+ @time.should_receive(:hour)
56
+ @time.should_receive(:min)
57
+ @release_notes.generate("path")
58
+ end
59
+
60
+ it "should open the release notes after writting" do
61
+ @release_notes.should_receive(:`).with(/open current_path\/release_notes.md/)
62
+ @release_notes.generate("path")
63
+ end
64
+ end
65
+
66
+ describe "when parsing release notes to plain text" do
67
+ before do
68
+ Dir.stub(:pwd){"current_path"}
69
+ end
70
+
71
+ it "should not attempt to parse a nil file" do
72
+ File.stub(:exist?){false}
73
+ @release_notes.plaintext.should eq("")
74
+ end
75
+
76
+ it "should return the notes in plaintext" do
77
+ File.stub(:exist?){true}
78
+ @file = mock(File)
79
+ File.stub(:open){@file}
80
+ @file.stub(:read){"plaintext"}
81
+ @release_notes.plaintext.should eq("plaintext")
82
+ end
83
+ end
84
+
85
+ describe "when parsing release notes to html" do
86
+
87
+ it "should not attempt to parse a nil file" do
88
+ File.stub(:exist?){false}
89
+ @release_notes.plaintext.should eq("")
90
+ end
91
+
92
+ it "should return release notes in html format" do
93
+ File.stub(:exist?){true}
94
+ @file = mock(File)
95
+ File.stub(:open){@file}
96
+ @file.stub(:read){"# hello"}
97
+ @release_notes.html.should eq("<h1>hello</h1>\n")
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+ require 'yolo/tools/ios/xcode'
3
+ require 'yolo/formatters'
4
+
5
+ describe Yolo::Tools::Ios::Xcode do
6
+ before do
7
+ @xcode = Yolo::Tools::Ios::Xcode.new
8
+ Yolo::Formatters::ErrorFormatter.any_instance.stub(:puts)
9
+ end
10
+
11
+ describe "on init" do
12
+ it "should load a preferences file path" do
13
+ @xcode.prefs_plist_path.should_not eq(nil)
14
+ end
15
+
16
+ it "should load an info plist path" do
17
+ xcode = Yolo::Tools::Ios::Xcode.new("path")
18
+ xcode.info_plist_path.should eq("path")
19
+ end
20
+ end
21
+
22
+ describe "when loading plists" do
23
+ it "shoud load xcode's preferences" do
24
+ @plist = ""
25
+ @plist.stub(:value)
26
+ @xcode.stub(:prefs_plist_path){"path"}
27
+ CFPropertyList::List.stub(:new){@plist}
28
+ CFPropertyList::List.should_receive(:new).with({:file => "path"})
29
+ @xcode.prefs
30
+ end
31
+ end
32
+
33
+ describe "when loading xcode preferences" do
34
+ it "should recognise a custom build folder location" do
35
+ @xcode.stub(:prefs){{"IDECustomDerivedDataLocation" => "path"}}
36
+ @xcode.build_path.should eq("path")
37
+ end
38
+
39
+ it "should recognise a default build folder location" do
40
+ @xcode.stub(:prefs){{}}
41
+ Dir.stub(:pwd){"path"}
42
+ @xcode.build_path.should eq("path/Library/Developer/Xcode/DerivedData")
43
+ end
44
+ end
45
+
46
+ describe "when loading the info.plist" do
47
+ it "should recognise if the plist path is not set" do
48
+ @xcode.info_plist_path = nil
49
+ Yolo::Formatters::ErrorFormatter.any_instance.should_receive(:info_plist_not_found)
50
+ @xcode.info_plist
51
+ end
52
+
53
+ it "should load the info plist" do
54
+ @plist = ""
55
+ @plist.stub(:value)
56
+ CFPropertyList::List.stub(:new){@plist}
57
+ @xcode.info_plist_path = "path"
58
+ CFPropertyList::List.should_receive(:new).with({:file => "path"})
59
+ @xcode.info_plist
60
+ end
61
+
62
+ it "should load the build number from the info plist" do
63
+ @xcode.stub(:info_plist){{"CFBundleVersion" => 10}}
64
+ @xcode.build_number.should eq(10)
65
+ end
66
+
67
+ it "should load the version number from the info plist" do
68
+ @xcode.stub(:info_plist){{"CFBundleShortVersionString" => 10}}
69
+ @xcode.version_number.should eq(10)
70
+ end
71
+ end
72
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yolo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 1.1.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-09 00:00:00.000000000 Z
12
+ date: 2013-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xcodebuild-rb
@@ -116,6 +116,19 @@ files:
116
116
  - lib/yolo/tools/ios.rb
117
117
  - lib/yolo/tools.rb
118
118
  - lib/yolo.rb
119
+ - spec/config/settings_spec.rb
120
+ - spec/deployment/base_deployer_spec.rb
121
+ - spec/deployment/ota_spec.rb
122
+ - spec/deployment/test_flight_spec.rb
123
+ - spec/notify/email_spec.rb
124
+ - spec/notify/ios/ota_email_spec.rb
125
+ - spec/spec_helper.rb
126
+ - spec/tools/git_spec.rb
127
+ - spec/tools/ios/calabash_spec.rb
128
+ - spec/tools/ios/coverage_spec.rb
129
+ - spec/tools/ios/ipa_spec.rb
130
+ - spec/tools/ios/release_notes_spec.rb
131
+ - spec/tools/ios/xcode_spec.rb
119
132
  - README.md
120
133
  homepage: http://rubygems.org/gems/yolo
121
134
  licenses: []
@@ -137,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
150
  version: '0'
138
151
  requirements: []
139
152
  rubyforge_project:
140
- rubygems_version: 1.8.25
153
+ rubygems_version: 1.8.23
141
154
  signing_key:
142
155
  specification_version: 3
143
156
  summary: YOLO!