hanzo 0.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4740905e91e0e036d29b67be68245425bacae8a1
4
- data.tar.gz: e653917084f0b4b442ea4e983eeb1fa0b393ca25
3
+ metadata.gz: 4bf04575cd4cf4815cd76c2f2d8010b4b228cdc9
4
+ data.tar.gz: b6aaa35696f469f440e3f59e672c0fb3b75c1bab
5
5
  SHA512:
6
- metadata.gz: 4c5d1e3d5d0d79b9231b89cfcd2fd13753cd119ef30a910a07ffd155bea208682c0222d6b4adedd55fa3ab2a8041e6c55515987564fd4bcc5ac85284651a3a82
7
- data.tar.gz: 455dacbe103c05eb86dba320fefcbd44c77fef3323cd27c4399a5213b99ba115e721a183e0cb66d92491a608e262013c4f2268040dad79cd73f68486082f5188
6
+ metadata.gz: 5d579c2eed73dd8e1712c2ca0675f8c48f7c19d5c8d73f963a86b8150c0f211a4a5d63e5cbbda7bf905326e7a486db367315f492ff0e8475ef38f1279f0e31fc
7
+ data.tar.gz: 9ac23d25ffb74114f85857944122d11760ad3c6f2963b15b57eb91146820c9f61a4b4b04074e70b7e664dd398f29137b4a5caf4e6a8cfd3dad38f17915df2d2e
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.0.0
5
+ - 1.9.3
6
+
7
+ script: "echo 'DO IT' && bundle exec rake spec"
data/README.md CHANGED
@@ -7,6 +7,7 @@
7
7
  <br /><br />
8
8
  <a href="https://rubygems.org/gems/hanzo"><img src="https://badge.fury.io/rb/hanzo.png" /></a>
9
9
  <a href="https://codeclimate.com/github/mirego/hanzo"><img src="https://codeclimate.com/github/mirego/hanzo.png" /></a>
10
+ <a href="https://travis-ci.org/mirego/hanzo"><img src="https://travis-ci.org/mirego/hanzo.png?branch=master" /></a>
10
11
  </p>
11
12
 
12
13
  ---
@@ -73,6 +74,6 @@ Heroku labs feature for all your environments.
73
74
 
74
75
  ## About Mirego
75
76
 
76
- Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We proudly build mobile applications for [iPhone](http://mirego.com/en/iphone-app-development/ "iPhone application development"), [iPad](http://mirego.com/en/ipad-app-development/ "iPad application development"), [Android](http://mirego.com/en/android-app-development/ "Android application development"), [Blackberry](http://mirego.com/en/blackberry-app-development/ "Blackberry application development"), [Windows Phone](http://mirego.com/en/windows-phone-app-development/ "Windows Phone application development") and [Windows 8](http://mirego.com/en/windows-8-app-development/ "Windows 8 application development") in beautiful Quebec City.
77
+ [Mirego](http://mirego.com) is a team of passionate people who believe that work is a place where you can innovate and have fun. We're a team of [talented people](http://life.mirego.com) who imagine and build beautiful Web and mobile applications. We come together to share ideas and [change the world](http://mirego.org).
77
78
 
78
- We also love [open-source software](http://open.mirego.com/) and we try to extract as much code as possible from our projects to give back to the community.
79
+ We also [love open-source software](http://open.mirego.com) and we try to give back to the community as much as we can.
data/Rakefile CHANGED
@@ -1,3 +1,11 @@
1
1
  require 'bundler'
2
2
  require 'rake'
3
3
  require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ task default: :spec
7
+
8
+ desc 'Run all specs'
9
+ RSpec::Core::RakeTask.new(:spec) do |task|
10
+ task.pattern = 'spec/**/*_spec.rb'
11
+ end
@@ -2,7 +2,7 @@ module Hanzo
2
2
  class Config < Base
3
3
 
4
4
  def compare
5
- Hanzo.title("Fetching environment variables")
5
+ Hanzo.title "Fetching environment variables"
6
6
  fetch_variables
7
7
 
8
8
  Hanzo.title "Comparing environment variables"
@@ -39,7 +39,11 @@ module Hanzo
39
39
  def run_migrations
40
40
  if Dir.exists?('db/migrate')
41
41
  migration = Hanzo.agree('Run migrations?')
42
- Hanzo.run "heroku run rake db:migrate --remote #{@env}" if migration
42
+
43
+ if migration
44
+ Hanzo.run "heroku run rake db:migrate --remote #{@env}"
45
+ Hanzo.run "heroku ps:restart --remote #{@env}"
46
+ end
43
47
  end
44
48
  end
45
49
  end
@@ -7,7 +7,7 @@ module Hanzo
7
7
  Hanzo::Heroku.available_labs.each do |name, description|
8
8
  if Hanzo.agree("Add #{name}?")
9
9
  Hanzo::Installers::Remotes.environments.each_pair do |env, app|
10
- Hanzo::Installers::Labs.enable(env, lab)
10
+ Hanzo::Installers::Labs.enable(env, name)
11
11
  end
12
12
  end
13
13
  end
data/lib/hanzo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hanzo
2
- VERSION = '0.3'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hanzo::CLI do
4
+ describe :config do
5
+ let(:config!) { Hanzo::CLI.new(['config', action]) }
6
+ let(:heroku_remotes) { { 'production' => 'heroku-app-production', 'qa' => 'heroku-app-qa' } }
7
+
8
+ before { Hanzo::Installers::Remotes.stub(:environments).and_return(heroku_remotes) }
9
+
10
+ describe :compare do
11
+ let(:action) { 'compare' }
12
+ let(:config_cmd) { 'heroku config' }
13
+
14
+ let(:fetch_environment_title) { 'Fetching environment variables' }
15
+ let(:compare_environment_title) { 'Comparing environment variables' }
16
+
17
+ let(:environment_one_name) { 'production' }
18
+ let(:environment_two_name) { 'qa' }
19
+ let(:environment_one) {
20
+ <<-RUBY
21
+ SMTP_PORT: 25
22
+ SMTP_PASSWORD: hanzo
23
+ SMTP_HOST: localhost
24
+ RUBY
25
+ }
26
+ let(:environment_two) {
27
+ <<-RUBY
28
+ SMTP_PORT: 25
29
+ SMTP_USERNAME: hanzo
30
+ RUBY
31
+ }
32
+
33
+ before do
34
+ Hanzo.should_receive(:title).with(fetch_environment_title)
35
+ Hanzo.should_receive(:title).with(compare_environment_title)
36
+
37
+ Hanzo.should_receive(:run).with("#{config_cmd} -r #{environment_one_name}").and_return(environment_one)
38
+ Hanzo.should_receive(:run).with("#{config_cmd} -r #{environment_two_name}").and_return(environment_two)
39
+
40
+ Hanzo.should_receive(:print).with("Missing variables in #{environment_one_name}", :yellow)
41
+ Hanzo.should_receive(:print).with(['- SMTP_USERNAME'])
42
+ Hanzo.should_receive(:print).with("Missing variables in #{environment_two_name}", :yellow)
43
+ Hanzo.should_receive(:print).with(['- SMTP_PASSWORD', '- SMTP_HOST'])
44
+ end
45
+
46
+ it 'should install specified labs for each environment' do
47
+ config!
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hanzo::CLI do
4
+ describe :deploy do
5
+ let(:env) { 'production' }
6
+ let(:branch) { '1.0.0' }
7
+ let(:deploy!) { Hanzo::CLI.new(['deploy', env]) }
8
+ let(:migrations_exist) { false }
9
+ let(:heroku_remotes) { { 'production' => 'heroku-app-production' } }
10
+ let(:migration_dir) { 'db/migrate' }
11
+
12
+ let(:migration_question) { 'Run migrations?' }
13
+ let(:deploy_question) { "Branch to deploy in #{env}:" }
14
+
15
+ let(:migration_cmd) { "heroku run rake db:migrate --remote #{env}" }
16
+ let(:restart_cmd) { "heroku ps:restart --remote #{env}" }
17
+ let(:deploy_cmd) { "git push -f #{env} #{branch}:master" }
18
+
19
+ before do
20
+ Dir.should_receive(:exists?).with(migration_dir).and_return(migrations_exist)
21
+ Hanzo::Installers::Remotes.stub(:environments).and_return(heroku_remotes)
22
+ Hanzo.should_receive(:ask).with(deploy_question).and_return(branch)
23
+ Hanzo.should_receive(:run).with(deploy_cmd).once
24
+ end
25
+
26
+ context 'without migration' do
27
+ it 'should git push to heroku upstream' do
28
+ deploy!
29
+ end
30
+ end
31
+
32
+ context 'with migrations' do
33
+ let(:migrations_exist) { true }
34
+
35
+ context 'that should be ran' do
36
+ before do
37
+ Hanzo.should_receive(:agree).with(migration_question).and_return(true)
38
+ Hanzo.should_receive(:run).with(migration_cmd)
39
+ Hanzo.should_receive(:run).with(restart_cmd)
40
+ end
41
+
42
+ it 'should run migrations' do
43
+ deploy!
44
+ end
45
+ end
46
+
47
+ context 'that should not be ran' do
48
+ before do
49
+ Hanzo.should_receive(:agree).with(migration_question).and_return(false)
50
+ Hanzo.should_not_receive(:run).with(migration_cmd)
51
+ Hanzo.should_not_receive(:run).with(restart_cmd)
52
+ end
53
+
54
+ it 'should not run migrations' do
55
+ deploy!
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hanzo::CLI do
4
+ describe :install do
5
+ let(:install!) { Hanzo::CLI.new(['install', type]) }
6
+ let(:heroku_remotes) { { 'production' => 'heroku-app-production', 'qa' => 'heroku-app-qa' } }
7
+
8
+ describe :labs do
9
+ let(:type) { 'labs' }
10
+ let(:labs_title) { 'Activating Heroku Labs' }
11
+ let(:available_labs) { { 'user-env-compile' => 'Description' } }
12
+
13
+ let(:enable_labs_cmd) { "heroku labs:enable" }
14
+ let(:enable_labs_info) { '- Enabled for' }
15
+
16
+ before do
17
+ Hanzo::Installers::Remotes.stub(:environments).and_return(heroku_remotes)
18
+ Hanzo::Heroku.stub(:available_labs).and_return(available_labs)
19
+ Hanzo.should_receive(:title).with(labs_title)
20
+
21
+ available_labs.each do |name, description|
22
+ Hanzo.should_receive(:agree).with("Add #{name}?").and_return(true)
23
+
24
+ heroku_remotes.each do |env, app|
25
+ Hanzo.should_receive(:run).with("#{enable_labs_cmd} #{name} --remote #{env}")
26
+ Hanzo.should_receive(:print).with("#{enable_labs_info} #{env}")
27
+ end
28
+ end
29
+ end
30
+
31
+ it 'should install specified labs for each environment' do
32
+ install!
33
+ end
34
+ end
35
+
36
+ describe :remotes do
37
+ let(:type) { 'remotes' }
38
+ let(:create_remotes_title) { 'Creating git remotes' }
39
+
40
+ before { Hanzo.should_receive(:title).with(create_remotes_title) }
41
+
42
+ context '.heroku-remotes exists' do
43
+ before do
44
+ Hanzo::Installers::Remotes.stub(:environments).and_return(heroku_remotes)
45
+ heroku_remotes.each do |env, app|
46
+ Hanzo.should_receive(:print).with("Adding #{env}")
47
+ Hanzo.should_receive(:run).with("git remote rm #{env} 2>&1 > /dev/null")
48
+ Hanzo.should_receive(:run).with("git remote add #{env} git@heroku.com:#{app}.git")
49
+ end
50
+ end
51
+
52
+ it 'should install git remotes' do
53
+ install!
54
+ end
55
+ end
56
+
57
+ context '.heroku-remotes file is missing' do
58
+ before { Hanzo.should_receive(:print).twice }
59
+
60
+ it 'should display error message' do
61
+ lambda { install! }.should raise_error SystemExit
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,6 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
+
3
+ require 'hanzo'
4
+
5
+ RSpec.configure do |c|
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanzo
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garneau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-18 00:00:00.000000000 Z
11
+ date: 2014-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,6 +75,8 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - .gitignore
78
+ - .rspec
79
+ - .travis.yml
78
80
  - Gemfile
79
81
  - LICENSE.md
80
82
  - README.md
@@ -91,6 +93,10 @@ files:
91
93
  - lib/hanzo/modules/installers/labs.rb
92
94
  - lib/hanzo/modules/installers/remotes.rb
93
95
  - lib/hanzo/version.rb
96
+ - spec/cli/config_spec.rb
97
+ - spec/cli/deploy_spec.rb
98
+ - spec/cli/install_spec.rb
99
+ - spec/spec_helper.rb
94
100
  homepage: https://github.com/mirego/hanzo
95
101
  licenses:
96
102
  - BSD 3-Clause
@@ -115,4 +121,8 @@ rubygems_version: 2.1.0
115
121
  signing_key:
116
122
  specification_version: 4
117
123
  summary: Hanzo is a tool to handle deployments in multiple environments on Heroku.
118
- test_files: []
124
+ test_files:
125
+ - spec/cli/config_spec.rb
126
+ - spec/cli/deploy_spec.rb
127
+ - spec/cli/install_spec.rb
128
+ - spec/spec_helper.rb