jumpup-heroku 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c31d2c9aa6f35da153e9f7a632c4a6a609c96acc
4
+ data.tar.gz: 947acb21f4f2d079f486005536d73230041c4072
5
+ SHA512:
6
+ metadata.gz: 372c4b33cd75739c43f2f74af77bfab74f36353f8c6a6452db317961d1e5dda01f372dd8cf7f188e6c37b19ed70fecc0069c465cad1a5bfa10612286baf8eafd
7
+ data.tar.gz: e1a0360be22f61d9897be8696d22e2cb6b6f5e8994847e1dcb15fcecc725efb0624f21915bb72d8d7070180bdd4cc5b4bc64a060a91069ca9ab93aef631f4f08
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ jumpup-heroku
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.0.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ ## 0.0.1 (Unreleased)
4
+
5
+ ### features
6
+
7
+ - Create all tasks of heroku deploy
8
+ - Create run_database_tasks config
9
+
10
+ ### improvements
11
+
12
+ ### bug fixes
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,47 @@
1
+ # Contributing
2
+
3
+ We love pull requests. Here's a quick guide:
4
+
5
+ 1. Fork the repo.
6
+
7
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
8
+
9
+ 3. Run the tests. We only take pull requests with passing tests, and it's great
10
+ to know that you have a clean slate: `bundle && rake`
11
+
12
+ 4. Add a test for your change. Only refactoring and documentation changes
13
+ require no new tests. If you are adding functionality or fixing a bug, we need
14
+ a test!
15
+
16
+ 5. Make the test pass.
17
+
18
+ 6. Update [CHANGELOG.md](https://github.com/Helabs/jumpup-heroku/blob/master/CHANGELOG.md) with a brief description of your changes under the `unreleased` heading.
19
+
20
+ 7. Commit your changes (`git commit -am 'Added some feature'`)
21
+
22
+ 8. Push to the branch (`git push origin my-new-feature`)
23
+
24
+ 9. Create new Pull Request
25
+
26
+ At this point you're waiting on us. We like to at least comment on, if not
27
+ accept, pull requests within three business days (and, typically, one business
28
+ day). We may suggest some changes or improvements or alternatives.
29
+
30
+ Some things that will increase the chance that your pull request is accepted,
31
+ taken straight from the Ruby on Rails guide:
32
+
33
+ * Use Rails idioms and helpers
34
+ * Include tests that fail without your code, and pass with it
35
+ * Update the documentation, the surrounding one, examples elsewhere, guides,
36
+ whatever is affected by your contribution
37
+
38
+ Syntax:
39
+
40
+ * Two spaces, no tabs.
41
+ * No trailing whitespace. Blank lines should not have any space.
42
+ * Prefer &&/|| over and/or.
43
+ * my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
44
+ * a = b and not a=b.
45
+ * Follow the conventions you see used in the source already.
46
+
47
+ And in case we didn't emphasize it enough: we love tests!
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jumpup-heroku.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Mauro George
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # Jumpup-heroku
2
+
3
+ Rake tasks to deploy on heroku.
4
+
5
+ ## Instalation
6
+
7
+ Add to your gem file.
8
+
9
+ ```ruby
10
+ gem 'jumpup-heroku', github: 'Helabs/jumpup-heroku'
11
+ ```
12
+
13
+ Without groups on Gemfile, because of initializer.
14
+
15
+ ## Usage
16
+
17
+ 1. Create the initializer on `config/initializers/jumpup-heroku.rb`
18
+
19
+ ```ruby
20
+ # config/initializers/jumpup-heroku.rb
21
+ Jumpup::Heroku.configure do |config|
22
+ config.app = 'myapp'
23
+ end
24
+ ```
25
+
26
+ Have production and staging app? Do like this:
27
+
28
+ ```ruby
29
+ Jumpup::Heroku.configure do |config|
30
+ config.staging_app = 'myapp-staging'
31
+ config.production_app = 'myapp'
32
+ end
33
+ ```
34
+
35
+ If you need to disable remote database tasks (backup, migrate and seed):
36
+
37
+ ```ruby
38
+ Jumpup::Heroku.configure do |config|
39
+ config.app = 'myapp'
40
+ config.run_database_tasks = false # Default: true
41
+ end
42
+ ```
43
+
44
+ 2. Add to the tasks on integration.rake the tasks to deploy on Heroku:
45
+
46
+ ```ruby
47
+ # integration.rake
48
+
49
+ INTEGRATION_TASKS = %w(
50
+ jumpup:heroku:add_remote
51
+ jumpup:heroku:check
52
+ jumpup:heroku:lock
53
+ integration:start
54
+ integration:bundle_install
55
+ db:migrate
56
+ spec
57
+ integration:coverage_verify
58
+ integration:finish
59
+ jumpup:heroku:deploy
60
+ jumpup:heroku:unlock
61
+ )
62
+ ```
63
+
64
+ ## Versioning
65
+
66
+ Jumpup-heroku follow the [Semantic Versioning](http://semver.org/).
67
+
68
+ ## Issues
69
+
70
+ If you have problems, please create a [Github Issue](https://github.com/Helabs/jumpup-heroku/issues).
71
+
72
+ ## Contributing
73
+
74
+ Please see [CONTRIBUTING.md](https://github.com/Helabs/jumpup-heroku/blob/master/CONTRIBUTING.md) for details.
75
+
76
+ ## Credits
77
+
78
+ Jumpup-heroku is maintained and funded by [HE:labs](http://helabs.com.br/opensource/).
79
+ Thank you to all the [contributors](https://github.com/Helabs/jumpup-heroku/graphs/contributors).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jumpup/heroku/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jumpup-heroku"
8
+ spec.version = Jumpup::Heroku::VERSION
9
+ spec.authors = ["HE:labs"]
10
+ spec.email = ["contato@helabs.com.br"]
11
+ spec.description = %q{Rake tasks to deploy on heroku}
12
+ spec.summary = %q{Rake tasks to deploy on heroku}
13
+ spec.homepage = "https://github.com/Helabs/jumpup-heroku"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,40 @@
1
+ module Jumpup
2
+ module Heroku
3
+
4
+ class << self
5
+ attr_accessor :configuration
6
+ end
7
+
8
+ def self.configure
9
+ self.configuration ||= Configuration.new
10
+ yield(configuration)
11
+ end
12
+
13
+
14
+ class Configuration
15
+ attr_accessor :app, :staging_app, :production_app, :run_database_tasks
16
+
17
+ def initialize
18
+ @run_database_tasks ||= true
19
+ end
20
+
21
+ def valid?
22
+ boolean_run_database_tasks? && (only_app? || only_production_and_staging_apps?)
23
+ end
24
+
25
+ private
26
+
27
+ def only_app?
28
+ app && staging_app.nil? && production_app.nil?
29
+ end
30
+
31
+ def only_production_and_staging_apps?
32
+ staging_app && production_app && app.nil?
33
+ end
34
+
35
+ def boolean_run_database_tasks?
36
+ run_database_tasks.is_a?(TrueClass) || run_database_tasks.is_a?(FalseClass)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,23 @@
1
+ module Jumpup
2
+ module Heroku
3
+
4
+ class Env
5
+
6
+ def self.all
7
+ if Jumpup::Heroku.configuration.valid?
8
+ {
9
+ app: Jumpup::Heroku.configuration.app,
10
+ staging_app: Jumpup::Heroku.configuration.staging_app,
11
+ production_app: Jumpup::Heroku.configuration.production_app,
12
+ run_database_tasks: Jumpup::Heroku.configuration.run_database_tasks
13
+ }.delete_if { |k, v| v.nil? }
14
+ else
15
+ error_message = 'Check your `/config/initializers/jumpup-heroku.rb` and ' \
16
+ 'confirm you have defined only `app` or `staging_app` and `production_app` together ' \
17
+ 'more info here https://github.com/Helabs/jumpup-heroku'
18
+ raise ConfigurationError, error_message
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,8 @@
1
+ module Jumpup
2
+ module Heroku
3
+
4
+ class ConfigurationError < StandardError
5
+ end
6
+ end
7
+ end
8
+
@@ -0,0 +1,189 @@
1
+ module Jumpup
2
+ module Heroku
3
+
4
+ class Integrate
5
+
6
+ def self.deploy
7
+ integrate.deploy
8
+ end
9
+
10
+ def self.deploy_to_production
11
+ app = Env.all[:production_app]
12
+ new(app).deploy_to_production
13
+ end
14
+
15
+ def self.add_remote
16
+ integrate.add_remote
17
+ end
18
+
19
+ def self.check
20
+ integrate.check
21
+ end
22
+
23
+ def self.lock
24
+ integrate.lock
25
+ end
26
+
27
+ def self.unlock
28
+ integrate.unlock
29
+ end
30
+
31
+ def self.integrate
32
+ envs = Env.all
33
+ app = envs[:app] || envs[:staging_app]
34
+ new(app)
35
+ end
36
+
37
+ def initialize(app)
38
+ @app = app
39
+ @envs = Env.all
40
+ end
41
+
42
+ def deploy
43
+ backup
44
+ push
45
+ migrate
46
+ seed
47
+ restart
48
+ end
49
+
50
+ def deploy_to_production
51
+ confirm_deploy
52
+ spec
53
+ confirm_maintenance
54
+ maintenance
55
+ backup
56
+ tag
57
+ push
58
+ migrate
59
+ seed
60
+ close_maintenance
61
+ restart
62
+ end
63
+
64
+ def add_remote
65
+ puts "--> Adding Heroku git remotes for app #{app}"
66
+ remote = run_with_clean_env("git remote | grep heroku", true).strip
67
+ run_with_clean_env("git remote add heroku git@heroku.com:#{app}.git") if remote.blank?
68
+ end
69
+
70
+ def check
71
+ puts "--> Checking if there's already someone integrating to #{app}"
72
+
73
+ var = run_with_clean_env("heroku config -s --app #{app} | grep INTEGRATING_BY", true).strip
74
+ integrating_by = var.split('=')[1]
75
+
76
+ integrating_by.strip! unless integrating_by.blank?
77
+
78
+ if integrating_by != user and not integrating_by.blank?
79
+ puts "--> Project is already being integrated by '#{integrating_by}', halting"
80
+ exit
81
+ end
82
+ end
83
+
84
+ def lock
85
+ puts "--> Locking Heroku integration for you (#{user})"
86
+ run_with_clean_env("heroku config:set INTEGRATING_BY='#{user}' --app #{app}")
87
+ end
88
+
89
+ def unlock
90
+ puts "--> Unlocking Heroku integration"
91
+ run_with_clean_env("heroku config:unset INTEGRATING_BY --app #{app}")
92
+ end
93
+
94
+ private
95
+ attr_reader :app, :envs, :maintenance_mode
96
+
97
+ def user
98
+ @user ||= run_with_clean_env("git config --get user.name", true).strip
99
+ end
100
+
101
+ def run_with_clean_env(command, capture_output = false)
102
+ Bundler.with_clean_env { capture_output ? `#{command}` : system(command) }
103
+ end
104
+
105
+ def confirm(message)
106
+ print "\n#{message}\nAre you sure? [yN] "
107
+ raise 'Ok. Bye...' unless STDIN.gets.chomp.downcase == 'y'
108
+ end
109
+
110
+ def run_database_tasks?
111
+ @envs[:run_database_tasks]
112
+ end
113
+
114
+ def backup
115
+ return unless run_database_tasks?
116
+ puts "--> Backing up database via Heroku"
117
+ run_with_clean_env("heroku pgbackups:capture --expire --app #{app}")
118
+ end
119
+
120
+ def migrate
121
+ return unless run_database_tasks?
122
+ puts "--> Migrating"
123
+ run_with_clean_env("heroku run rake db:migrate --app #{app}")
124
+ end
125
+
126
+ def seed
127
+ return unless run_database_tasks?
128
+ puts "--> Seeding"
129
+ run_with_clean_env("heroku run rake db:seed --app #{app}")
130
+ end
131
+
132
+ def restart
133
+ puts "--> Restarting"
134
+ run_with_clean_env("heroku restart --app #{app}")
135
+ end
136
+
137
+ def push
138
+ puts "--> Pushing"
139
+ run_with_clean_env("git push git@heroku.com:#{app}.git HEAD:master")
140
+ end
141
+
142
+ def confirm_deploy
143
+ confirm("Going deploy to production [#{app}]...")
144
+ end
145
+
146
+ def spec
147
+ puts "--> Running all specs"
148
+ Rake::Task['spec'].invoke
149
+ end
150
+
151
+ def confirm_maintenance
152
+ print "\nPut #{app} in maintenance mode? [Yn] "
153
+ @maintenance_mode = true if STDIN.gets.chomp.downcase == 'y'
154
+ end
155
+
156
+ def maintenance?
157
+ @maintenance_mode
158
+ end
159
+
160
+ def maintenance
161
+ if maintenance?
162
+ puts "--> Setting Maintenance on"
163
+ run_with_clean_env("heroku maintenance:on --app #{app}")
164
+ restart
165
+ puts "--> Waiting 20 seconds to app come back (in maintenance mode)"
166
+ sleep(20)
167
+ end
168
+ end
169
+
170
+ def tag
171
+ iso_date = Time.now.strftime('%Y-%m-%dT%H%M%S')
172
+ tag_name = "production-#{iso_date}"
173
+
174
+ puts "--> Tagging as #{tag_name}"
175
+ run_with_clean_env("git tag #{tag_name} master")
176
+
177
+ puts "--> Pushing to origin"
178
+ run_with_clean_env("git push origin #{tag_name}")
179
+ end
180
+
181
+ def close_maintenance
182
+ if maintenance?
183
+ puts "Setting Maintenance off"
184
+ run_with_clean_env("heroku maintenance:off --app #{app}")
185
+ end
186
+ end
187
+ end
188
+ end
189
+ end
@@ -0,0 +1,5 @@
1
+ module Jumpup
2
+ module Heroku
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ require "jumpup/heroku/version"
2
+
3
+ module Jumpup
4
+ module Heroku
5
+ require 'jumpup/heroku/errors'
6
+ require 'jumpup/heroku/configuration'
7
+ require 'jumpup/heroku/env'
8
+ require 'jumpup/heroku/integrate'
9
+ end
10
+ end
11
+
12
+ def gem_path
13
+ Gem::Specification.find_by_name('jumpup-heroku').full_gem_path
14
+ end
15
+
16
+ Dir["#{gem_path}/lib/tasks/*.rake"].each { |ext| load ext } if defined?(Rake)
17
+
@@ -0,0 +1,38 @@
1
+ namespace :jumpup do
2
+ namespace :heroku do
3
+
4
+ desc "Add Heroku git remotes"
5
+ task add_remote: :environment do
6
+ Jumpup::Heroku::Integrate.add_remote
7
+ end
8
+
9
+ desc "Check if there's someone else integrating the project"
10
+ task check: :environment do
11
+ Jumpup::Heroku::Integrate.check
12
+ end
13
+
14
+ desc "Lock the Heroku integration"
15
+ task lock: :environment do
16
+ Jumpup::Heroku::Integrate.lock
17
+ end
18
+
19
+ desc "Unlock the Heroku integration"
20
+ task unlock: :environment do
21
+ Jumpup::Heroku::Integrate.unlock
22
+ end
23
+
24
+ desc "Deploy to heroku"
25
+ task deploy: :environment do
26
+ Jumpup::Heroku::Integrate.deploy
27
+ end
28
+
29
+ namespace :deploy do
30
+
31
+ desc "Deploy to production"
32
+ task production: :environment do
33
+ Jumpup::Heroku::Integrate.deploy_to_production
34
+ end
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,214 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jumpup::Heroku::Configuration do
4
+
5
+ before do
6
+ Jumpup::Heroku.configuration = nil
7
+ end
8
+
9
+ describe ".configure" do
10
+
11
+ describe "without configuration" do
12
+ before do
13
+ Jumpup::Heroku.configure do |config|
14
+ end
15
+ end
16
+
17
+ subject do
18
+ Jumpup::Heroku.configuration
19
+ end
20
+
21
+ its(:app) { should be_nil }
22
+ its(:staging_app) { should be_nil }
23
+ its(:production_app) { should be_nil }
24
+ its(:run_database_tasks) { should be_true }
25
+ end
26
+
27
+ describe "with configurations" do
28
+
29
+ before do
30
+ Jumpup::Heroku.configure do |config|
31
+ config.app = 'myapp'
32
+ config.production_app = 'myapp-production'
33
+ config.staging_app = 'myapp-staging'
34
+ config.run_database_tasks = false
35
+ end
36
+ end
37
+
38
+ subject do
39
+ Jumpup::Heroku.configuration
40
+ end
41
+
42
+ its(:app) { should eq('myapp') }
43
+ its(:staging_app) { should eq('myapp-staging')}
44
+ its(:production_app) { should eq('myapp-production') }
45
+ its(:run_database_tasks) { should be_false }
46
+ end
47
+ end
48
+
49
+ describe "#valid?" do
50
+
51
+ describe "with app" do
52
+
53
+ before do
54
+ Jumpup::Heroku.configure do |config|
55
+ config.app = 'myapp'
56
+ end
57
+ end
58
+
59
+ it 'be valid' do
60
+ expect(Jumpup::Heroku.configuration).to be_valid
61
+ end
62
+ end
63
+
64
+ describe "with staging_app and production_app" do
65
+
66
+ before do
67
+ Jumpup::Heroku.configure do |config|
68
+ config.production_app = 'myapp-production'
69
+ config.staging_app = 'myapp-staging'
70
+ end
71
+ end
72
+
73
+ it 'be valid' do
74
+ expect(Jumpup::Heroku.configuration).to be_valid
75
+ end
76
+ end
77
+
78
+ describe "with app, staging_app and production_app" do
79
+
80
+ before do
81
+ Jumpup::Heroku.configure do |config|
82
+ config.app = 'myapp'
83
+ config.production_app = 'myapp-production'
84
+ config.staging_app = 'myapp-staging'
85
+ end
86
+ end
87
+
88
+ it 'not be valid' do
89
+ expect(Jumpup::Heroku.configuration).to_not be_valid
90
+ end
91
+ end
92
+
93
+ describe "with staging_app" do
94
+
95
+ before do
96
+ Jumpup::Heroku.configure do |config|
97
+ config.staging_app = 'myapp-staging'
98
+ end
99
+ end
100
+
101
+ it 'not be valid' do
102
+ expect(Jumpup::Heroku.configuration).to_not be_valid
103
+ end
104
+ end
105
+
106
+ describe "with production_app" do
107
+
108
+ before do
109
+ Jumpup::Heroku.configure do |config|
110
+ config.production_app = 'myapp-production'
111
+ end
112
+ end
113
+
114
+ it 'not be valid' do
115
+ expect(Jumpup::Heroku.configuration).to_not be_valid
116
+ end
117
+ end
118
+
119
+ describe "with app and production_app" do
120
+
121
+ before do
122
+ Jumpup::Heroku.configure do |config|
123
+ config.app = 'myapp'
124
+ config.production_app = 'myapp-production'
125
+ end
126
+ end
127
+
128
+ it 'not be valid' do
129
+ expect(Jumpup::Heroku.configuration).to_not be_valid
130
+ end
131
+ end
132
+
133
+ describe "with app and staging_app" do
134
+
135
+ before do
136
+ Jumpup::Heroku.configure do |config|
137
+ config.app = 'myapp'
138
+ config.staging_app = 'myapp-staging'
139
+ end
140
+ end
141
+
142
+ it 'not be valid' do
143
+ expect(Jumpup::Heroku.configuration).to_not be_valid
144
+ end
145
+ end
146
+
147
+ describe "with true run_database_tasks" do
148
+
149
+ before do
150
+ Jumpup::Heroku.configure do |config|
151
+ config.app = 'myapp'
152
+ config.run_database_tasks = true
153
+ end
154
+ end
155
+
156
+ it 'be valid' do
157
+ expect(Jumpup::Heroku.configuration).to be_valid
158
+ end
159
+ end
160
+
161
+ describe "with false run_database_tasks" do
162
+
163
+ before do
164
+ Jumpup::Heroku.configure do |config|
165
+ config.app = 'myapp'
166
+ config.run_database_tasks = false
167
+ end
168
+ end
169
+
170
+ it 'be valid' do
171
+ expect(Jumpup::Heroku.configuration).to be_valid
172
+ end
173
+ end
174
+
175
+ describe "with invalid run_database_tasks" do
176
+
177
+ before do
178
+ Jumpup::Heroku.configure do |config|
179
+ config.app = 'myapp'
180
+ config.run_database_tasks = 'a'
181
+ end
182
+ end
183
+
184
+ it 'be valid' do
185
+ expect(Jumpup::Heroku.configuration).to_not be_valid
186
+ end
187
+ end
188
+
189
+ describe "without configuration" do
190
+
191
+ before do
192
+ Jumpup::Heroku.configure do |config|
193
+ end
194
+ end
195
+
196
+ it 'not be valid' do
197
+ expect(Jumpup::Heroku.configuration).to_not be_valid
198
+ end
199
+ end
200
+
201
+ describe "with configuration nil" do
202
+
203
+ before do
204
+ Jumpup::Heroku.configuration = nil
205
+ end
206
+
207
+ it 'not be valid' do
208
+ pending "The bug is raised when have no config/initialier/heroku-deploy.rb file"
209
+ expect(Jumpup::Heroku.configuration).to_not be_valid
210
+ end
211
+ end
212
+ end
213
+ end
214
+
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jumpup::Heroku::Env do
4
+
5
+ before do
6
+ Jumpup::Heroku.configuration = nil
7
+ end
8
+
9
+ describe "with app" do
10
+
11
+ before do
12
+ Jumpup::Heroku.configure do |config|
13
+ config.app = 'myapp'
14
+ end
15
+ end
16
+
17
+ it "have correct env info" do
18
+ expect(Jumpup::Heroku::Env.all).to eq({ app: 'myapp', run_database_tasks: true })
19
+ end
20
+ end
21
+
22
+ describe "with staging_app and production_app" do
23
+
24
+ before do
25
+ Jumpup::Heroku.configure do |config|
26
+ config.production_app = 'myapp-production'
27
+ config.staging_app = 'myapp-staging'
28
+ end
29
+ end
30
+
31
+ it "have correct env info" do
32
+ result = { production_app: 'myapp-production', staging_app: 'myapp-staging', run_database_tasks: true }
33
+ expect(Jumpup::Heroku::Env.all).to eq(result)
34
+ end
35
+ end
36
+
37
+ describe "with run_database_tasks" do
38
+
39
+ before do
40
+ Jumpup::Heroku.configure do |config|
41
+ config.app = 'myapp'
42
+ config.run_database_tasks = false
43
+ end
44
+ end
45
+
46
+ it "have correct env info" do
47
+ result = { app: 'myapp', run_database_tasks: false }
48
+ expect(Jumpup::Heroku::Env.all).to eq(result)
49
+ end
50
+ end
51
+
52
+ describe "with a invalid config env" do
53
+
54
+ before do
55
+ Jumpup::Heroku.configure do |config|
56
+ config.app = 'myapp'
57
+ config.production_app = 'myapp-production'
58
+ config.staging_app = 'myapp-staging'
59
+ config.run_database_tasks = 'a'
60
+ end
61
+ end
62
+
63
+ it 'raise error' do
64
+ expect do
65
+ Jumpup::Heroku::Env.all
66
+ end.to raise_error(Jumpup::Heroku::ConfigurationError, %r{/config/initializers/jumpup-heroku.rb})
67
+ end
68
+ end
69
+ end
70
+
@@ -0,0 +1,11 @@
1
+ require "bundler/setup"
2
+ Bundler.require(:default, :development)
3
+
4
+ require "jumpup/heroku"
5
+
6
+ RSpec.configure do |config|
7
+ config.expect_with :rspec do |c|
8
+ c.syntax = :expect
9
+ end
10
+ end
11
+
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jumpup-heroku
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - HE:labs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Rake tasks to deploy on heroku
56
+ email:
57
+ - contato@helabs.com.br
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .ruby-gemset
64
+ - .ruby-version
65
+ - CHANGELOG.md
66
+ - CONTRIBUTING.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - jumpup-heroku.gemspec
72
+ - lib/jumpup/heroku.rb
73
+ - lib/jumpup/heroku/configuration.rb
74
+ - lib/jumpup/heroku/env.rb
75
+ - lib/jumpup/heroku/errors.rb
76
+ - lib/jumpup/heroku/integrate.rb
77
+ - lib/jumpup/heroku/version.rb
78
+ - lib/tasks/integrate.rake
79
+ - spec/jumpup/heroku/configuration_spec.rb
80
+ - spec/jumpup/heroku/env_spec.rb
81
+ - spec/spec_helper.rb
82
+ homepage: https://github.com/Helabs/jumpup-heroku
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.0.6
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Rake tasks to deploy on heroku
106
+ test_files:
107
+ - spec/jumpup/heroku/configuration_spec.rb
108
+ - spec/jumpup/heroku/env_spec.rb
109
+ - spec/spec_helper.rb