fourchette 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3d2dcc715d8a2c65fe34a0248a6089bcfb5762a
4
- data.tar.gz: 74456ce01a2cff7e4939f04efc7b0c49891597a1
3
+ metadata.gz: 6dd6591b8703b74bde51dd854677cb614f5f3aa1
4
+ data.tar.gz: 345b066b668937adb7a2c5efbf81eab03e80f3a1
5
5
  SHA512:
6
- metadata.gz: b8055c8a81b2dc7253139b50b42e5fbd7188c137246ff73a44a4e0ce9a15ea9539a12dacab07f7893f56d389a7bac072aa18688f7f51357617aac2971118e4e4
7
- data.tar.gz: 69ba6c5cc5d1e26972a865ef438168e154f879cc9e419405d760c0c881a0e58897f98adf5a8d026cf1281776c9c4b78a54162b3f87c01330f545cac63234acb9
6
+ metadata.gz: 7221c0baa009a6b26853b653c194b2ee51b90414dd2e28ed06d9c113f82323adef5f330f215594b9abc6174efcb64409f8c73fa1526dcd4865a1d6fe09570ba8
7
+ data.tar.gz: 06b66d34ba4241156741e090ee34c3c89c2446b7ba674958b5844803151aef4cdd41db987c9f89a042872be5cbcb25652a659aab9cac54b4e1f068414ca16052
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 2.0.0-p353
5
4
  - 2.1.0
6
5
  - 2.1.1
6
+ - 2.1.2
data/Gemfile.lock.orig ADDED
@@ -0,0 +1,163 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fourchette (0.0.8)
5
+ git
6
+ heroku
7
+ octokit
8
+ platform-api (~> 0.2.0)
9
+ rake
10
+ sinatra
11
+ sinatra-contrib
12
+ sucker_punch
13
+ thor
14
+
15
+ GEM
16
+ remote: http://rubygems.org/
17
+ specs:
18
+ addressable (2.3.6)
19
+ backports (3.6.0)
20
+ byebug (2.7.0)
21
+ columnize (~> 0.3)
22
+ debugger-linecache (~> 1.2)
23
+ celluloid (0.15.2)
24
+ timers (~> 1.1.0)
25
+ celluloid-io (0.15.0)
26
+ celluloid (>= 0.15.0)
27
+ nio4r (>= 0.5.0)
28
+ coderay (1.1.0)
29
+ columnize (0.8.9)
30
+ coveralls (0.7.0)
31
+ multi_json (~> 1.3)
32
+ rest-client
33
+ simplecov (>= 0.7)
34
+ term-ansicolor
35
+ thor
36
+ debugger-linecache (1.2.0)
37
+ diff-lcs (1.2.5)
38
+ docile (1.1.3)
39
+ dotenv (0.7.0)
40
+ erubis (2.7.0)
41
+ excon (0.34.0)
42
+ faraday (0.9.0)
43
+ multipart-post (>= 1.2, < 3)
44
+ ffi (1.9.3)
45
+ foreman (0.64.0)
46
+ dotenv (~> 0.7.0)
47
+ thor (>= 0.13.6)
48
+ formatador (0.2.4)
49
+ git (1.2.6)
50
+ guard (2.5.1)
51
+ formatador (>= 0.2.4)
52
+ listen (~> 2.6)
53
+ lumberjack (~> 1.0)
54
+ pry (>= 0.9.12)
55
+ thor (>= 0.18.1)
56
+ guard-rspec (4.2.7)
57
+ guard (~> 2.1)
58
+ rspec (>= 2.14, < 4.0)
59
+ heroics (0.0.10)
60
+ erubis (~> 2.7.0)
61
+ excon
62
+ moneta
63
+ multi_json (>= 1.9.2)
64
+ netrc
65
+ heroku (3.8.2)
66
+ heroku-api (~> 0.3.17)
67
+ launchy (>= 0.3.2)
68
+ netrc (~> 0.7.7)
69
+ rest-client (~> 1.6.1)
70
+ rubyzip
71
+ heroku-api (0.3.18)
72
+ excon (~> 0.27)
73
+ multi_json (~> 1.8)
74
+ launchy (2.4.2)
75
+ addressable (~> 2.3)
76
+ listen (2.6.2)
77
+ celluloid (>= 0.15.2)
78
+ celluloid-io (>= 0.15.0)
79
+ rb-fsevent (>= 0.9.3)
80
+ rb-inotify (>= 0.9)
81
+ lumberjack (1.0.4)
82
+ method_source (0.8.2)
83
+ mime-types (2.2)
84
+ moneta (0.7.20)
85
+ multi_json (1.9.2)
86
+ multipart-post (2.0.0)
87
+ netrc (0.7.7)
88
+ nio4r (1.0.0)
89
+ octokit (3.1.0)
90
+ sawyer (~> 0.5.3)
91
+ platform-api (0.2.0)
92
+ heroics (~> 0.0.10)
93
+ pry (0.9.12.6)
94
+ coderay (~> 1.0)
95
+ method_source (~> 0.8)
96
+ slop (~> 3.4)
97
+ pry-byebug (1.3.2)
98
+ byebug (~> 2.7)
99
+ pry (~> 0.9.12)
100
+ puma (2.8.2)
101
+ rack (>= 1.1, < 2.0)
102
+ rack (1.5.2)
103
+ rack-protection (1.5.3)
104
+ rack
105
+ rack-test (0.6.2)
106
+ rack (>= 1.0)
107
+ rake (10.3.2)
108
+ rb-fsevent (0.9.4)
109
+ rb-inotify (0.9.3)
110
+ ffi (>= 0.5.0)
111
+ rest-client (1.6.7)
112
+ mime-types (>= 1.16)
113
+ rspec (2.14.1)
114
+ rspec-core (~> 2.14.0)
115
+ rspec-expectations (~> 2.14.0)
116
+ rspec-mocks (~> 2.14.0)
117
+ rspec-core (2.14.8)
118
+ rspec-expectations (2.14.5)
119
+ diff-lcs (>= 1.1.3, < 2.0)
120
+ rspec-mocks (2.14.6)
121
+ rubyzip (1.1.4)
122
+ sawyer (0.5.4)
123
+ addressable (~> 2.3.5)
124
+ faraday (~> 0.8, < 0.10)
125
+ simplecov (0.8.2)
126
+ docile (~> 1.1.0)
127
+ multi_json
128
+ simplecov-html (~> 0.8.0)
129
+ simplecov-html (0.8.0)
130
+ sinatra (1.4.5)
131
+ rack (~> 1.4)
132
+ rack-protection (~> 1.4)
133
+ tilt (~> 1.3, >= 1.3.4)
134
+ sinatra-contrib (1.4.2)
135
+ backports (>= 2.0)
136
+ multi_json
137
+ rack-protection
138
+ rack-test
139
+ sinatra (~> 1.4.0)
140
+ tilt (~> 1.3)
141
+ slop (3.5.0)
142
+ sucker_punch (1.0.5)
143
+ celluloid (~> 0.15.2)
144
+ term-ansicolor (1.3.0)
145
+ tins (~> 1.0)
146
+ terminal-notifier-guard (1.5.3)
147
+ thor (0.19.1)
148
+ tilt (1.4.1)
149
+ timers (1.1.0)
150
+ tins (1.1.0)
151
+
152
+ PLATFORMS
153
+ ruby
154
+
155
+ DEPENDENCIES
156
+ coveralls
157
+ foreman
158
+ fourchette!
159
+ guard-rspec
160
+ pry-byebug
161
+ puma
162
+ rspec (~> 2.14.1)
163
+ terminal-notifier-guard
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  <b>Your new best friend for isolated testing environments on Heroku</b>
7
7
  <br />
8
8
  <a href="https://codeclimate.com/github/jipiboily/fourchette"><img src="https://codeclimate.com/github/jipiboily/fourchette.png" /></a>
9
- <a href="https://github.com/jipiboily/fourchette"><img src="https://travis-ci.org/jipiboily/fourchette.png?branch=master" /></a>
9
+ <a href="https://travis-ci.org/jipiboily/fourchette"><img src="https://travis-ci.org/jipiboily/fourchette.png?branch=master" /></a>
10
10
  <a href='https://coveralls.io/r/jipiboily/fourchette'><img src='https://coveralls.io/repos/jipiboily/fourchette/badge.png' alt='Coverage Status' /></a>
11
11
  <a href="http://badge.fury.io/rb/fourchette"><img src="https://badge.fury.io/rb/fourchette.svg" alt="Gem Version" height="18"></a>
12
12
  </p>
@@ -16,18 +16,17 @@ Fourchette is your new best friend for having isolated testing environements. It
16
16
  **IMPORTANT: Please note that forking your Heroku app means it will copy the same addon plans and that you will pay for multiple apps and their addons. Watch out!**
17
17
 
18
18
  ## Table of content
19
- 1. How does that work exactly?
20
- - Features
21
- - Installation
22
- * Configuration
23
- * Enable your Fourchette instance
24
- * Enable, disable, update or delete the hook
25
- * Before & after steps, aka, callbacks
26
- - Rake tasks
27
- - Async processing note
28
- - Contribute
29
- - Logging
30
- - Contributors
19
+ 1. [How does that work exactly?](#how-does-that-work-exactly)
20
+ - [Installation](#installation)
21
+ * [Configuration](#configuration)
22
+ * [Enable your Fourchette instance](#enable-your-fourchette-instance)
23
+ * [Enable, disable, update or delete the hook](#enable-disable-update-or-delete-the-hook)
24
+ * [Before & after steps, aka, callbacks](#before--after-steps-aka-callbacks)
25
+ - [Rake tasks](#rake-tasks)
26
+ - [Async processing note](#async-processing-note)
27
+ - [Contribute](#contribute)
28
+ - [Logging](#logging)
29
+ - [Contributors](#contributors)
31
30
 
32
31
  ## How does that work exactly?
33
32
 
@@ -37,6 +36,8 @@ Fourchette is your new best friend for having isolated testing environements. It
37
36
  - any new commit against that PR will update the code
38
37
  - closing the PR will delete the forked app
39
38
  - re-opening the PR will re-create a fork
39
+
40
+ We use it a lot at [Rainforest QA](https://www.rainforestqa.com/). If you want to see a sample Fourchette app, here is one for you to look at: https://github.com/rainforestapp/fourchette.
40
41
 
41
42
  ## Installation
42
43
 
data/fourchette.gemspec CHANGED
@@ -23,15 +23,15 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "sinatra-contrib"
24
24
  spec.add_dependency "octokit"
25
25
  spec.add_dependency "git"
26
- spec.add_dependency "heroku" # Deprecated, but best/easiest solution for the pgbackups...
26
+ spec.add_dependency "heroku", "~> 3.9" # Deprecated, but best/easiest solution for the pgbackups...
27
27
  spec.add_dependency 'platform-api', '~> 0.2.0'
28
28
  spec.add_dependency "sucker_punch"
29
29
  spec.add_dependency "thor"
30
30
 
31
31
  spec.add_development_dependency 'foreman'
32
- spec.add_development_dependency 'pry-debugger'
32
+ spec.add_development_dependency 'pry-byebug'
33
33
  spec.add_development_dependency 'rspec', '~> 2.14.1'
34
34
  spec.add_development_dependency 'guard-rspec'
35
35
  spec.add_development_dependency 'terminal-notifier-guard'
36
36
  spec.add_development_dependency 'coveralls'
37
- end
37
+ end
@@ -24,11 +24,11 @@ class Fourchette::Fork
24
24
  def monitor_build build
25
25
  logger.info "Start of the build process on Heroku..."
26
26
  build_info = @heroku.client.build.info(fork_name, build['id'])
27
- # Let's just leave some time to Heroku to download the tarball and start
27
+ # Let's just leave some time to Heroku to download the tarball and start
28
28
  # the process. This is some random timing that seems to make sense at first.
29
29
  sleep 30
30
30
  if build_info['status'] == 'failed'
31
- @github.comment_pr(pr_number, "The build failed on Herok. See the activity tab on Heroku.")
31
+ @github.comment_pr(pr_number, "The build failed on Heroku. See the activity tab on Heroku.")
32
32
  fail Fourchette::DeployException
33
33
  end
34
34
  end
@@ -41,11 +41,9 @@ class Fourchette::Fork
41
41
 
42
42
  def delete
43
43
  @heroku.delete(fork_name)
44
-
45
- # Update PR with URL
46
44
  @github.comment_pr(pr_number, "Test app deleted!")
47
45
  end
48
-
46
+
49
47
  def fork_name
50
48
  "#{ENV['FOURCHETTE_HEROKU_APP_PREFIX']}-PR-#{pr_number}".downcase # It needs to be lowercase only.
51
49
  end
@@ -58,15 +56,22 @@ class Fourchette::Fork
58
56
  @params['pull_request']['number']
59
57
  end
60
58
 
61
- private
62
59
  def create_unless_exists
63
60
  unless @heroku.app_exists?(fork_name)
64
61
  @heroku.fork(ENV['FOURCHETTE_HEROKU_APP_TO_FORK'] ,fork_name)
65
- # Update PR with URL
66
- @github.comment_pr(pr_number, "Test URL: #{@heroku.client.app.info(fork_name)['web_url']}")
62
+ post_fork_url
67
63
  end
68
64
  end
69
65
 
66
+ private
67
+
68
+ # Update PR with URL. This is a method so that we can override it and just not
69
+ # have that, if we don't want. Use case: we have custom domains, so we post
70
+ # the URLs later on.
71
+ def post_fork_url
72
+ @github.comment_pr(pr_number, "Test URL: #{@heroku.client.app.info(fork_name)['web_url']}")
73
+ end
74
+
70
75
  def git_branch_name
71
76
  "remotes/origin/#{branch_name}"
72
77
  end
@@ -10,6 +10,7 @@ class Fourchette::Heroku
10
10
  copy_config(from, to)
11
11
  copy_add_ons(from, to)
12
12
  copy_pg(from, to)
13
+ copy_RACK_AND_RAILS_ENV_again(from, to)
13
14
  end
14
15
 
15
16
  def delete app_name
@@ -33,7 +34,6 @@ class Fourchette::Heroku
33
34
  client.app.info(app_name)['git_url']
34
35
  end
35
36
 
36
- private
37
37
  def create_app name
38
38
  logger.info "Creating #{name}"
39
39
  client.app.create({ name: name })
@@ -67,4 +67,21 @@ class Fourchette::Heroku
67
67
  backup = Fourchette::Pgbackups.new
68
68
  backup.copy(from, to)
69
69
  end
70
+
71
+ def copy_RACK_AND_RAILS_ENV_again(from, to)
72
+ env_to_update = get_original_env(from)
73
+ unless env_to_update.empty?
74
+ client.config_var.update(to, env_to_update)
75
+ end
76
+ end
77
+
78
+ def get_original_env(from)
79
+ environments = {}
80
+ ['RACK_ENV', 'RAILS_ENV'].each do |var|
81
+ if client.config_var.info(from)[var]
82
+ environments[var] = client.config_var.info(from)[var]
83
+ end
84
+ end
85
+ environments
86
+ end
70
87
  end
@@ -27,7 +27,7 @@ class Fourchette::Tarball
27
27
  def tar(path)
28
28
  logger.info "Preparing tarball..."
29
29
  filepath = "#{path}/#{expiration_timestamp}.tar.gz"
30
- system("tar -zcvf #{filepath} -C #{path} .")
30
+ system("tar -zcf #{filepath} -C #{path} .")
31
31
  filepath
32
32
  end
33
33
 
@@ -1,3 +1,3 @@
1
1
  module Fourchette
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -0,0 +1,120 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fourchette::Fork do
4
+ subject { described_class.new(params) }
5
+
6
+ let(:params) {
7
+ {
8
+ 'pull_request' => {
9
+ 'number' => 1,
10
+ 'head' => {
11
+ 'ref' => '123456'
12
+ }
13
+ }
14
+ }
15
+ }
16
+ let(:fork_name) { 'my-fork-pr-1' }
17
+
18
+ before do
19
+ stub_const('ENV', {
20
+ 'FOURCHETTE_HEROKU_APP_PREFIX' => 'my-fork',
21
+ 'FOURCHETTE_HEROKU_APP_TO_FORK' => 'my-heroku-app-name'
22
+ })
23
+ end
24
+
25
+ describe '#update' do
26
+ before do
27
+ subject.stub(:create_unless_exists)
28
+ subject.stub(:monitor_build)
29
+ Fourchette::Heroku.any_instance.stub_chain(:client, :build, :create)
30
+ end
31
+
32
+ after do
33
+ # subject.update
34
+ end
35
+
36
+ it 'calls #create_unless_exists' do
37
+ subject.should_receive(:create_unless_exists)
38
+
39
+ end
40
+
41
+ it 'starts the build process with the generated tarball URL' do
42
+ heroku_client_stub = double
43
+ heroku_client_stub.stub(:build)
44
+ heroku_client_stub.build.should_receive(:create)
45
+ Fourchette::Heroku.any_instance.stub(:client).and_return(heroku_client_stub)
46
+ subject.update
47
+ end
48
+
49
+ it 'starts monitoring the build' do
50
+ end
51
+ end
52
+
53
+ describe '#create' do
54
+ it 'calls #update and #create_unless_exists' do
55
+ subject.should_receive(:create_unless_exists)
56
+ subject.should_receive(:update)
57
+ subject.create
58
+ end
59
+ end
60
+
61
+ describe '#create_unless_exists' do
62
+ after do
63
+ subject.create_unless_exists
64
+ end
65
+
66
+ context 'app does NOT exists' do
67
+ before do
68
+ Fourchette::Heroku.any_instance.stub(:app_exists?).and_return(false)
69
+ end
70
+
71
+ it 'calls the fork creation' do
72
+ subject.stub(:post_fork_url)
73
+ Fourchette::Heroku.any_instance.should_receive(:fork).with('my-heroku-app-name', fork_name)
74
+ end
75
+
76
+ it 'post the URL to the fork on the GitHub PR' do
77
+ Fourchette::Heroku.any_instance.stub(:fork)
78
+ Fourchette::Heroku.any_instance.stub_chain(:client, :app, :info).and_return({'web_url' => 'rainforestqa.com'})
79
+ Fourchette::GitHub.any_instance.should_receive(:comment_pr).with(1, 'Test URL: rainforestqa.com')
80
+ end
81
+ end
82
+
83
+ context 'app DOES exists' do
84
+ before do
85
+ Fourchette::Heroku.any_instance.stub(:app_exists?).and_return(true)
86
+ end
87
+
88
+ it 'does nothing' do
89
+ Fourchette::GitHub.any_instance.should_not_receive(:comment_pr)
90
+ Fourchette::Heroku.any_instance.should_not_receive(:fork)
91
+ end
92
+ end
93
+ end
94
+
95
+ describe '#delete' do
96
+ it 'calls deletes the fork' do
97
+ Fourchette::GitHub.any_instance.stub(:comment_pr)
98
+ Fourchette::Heroku.any_instance.should_receive(:delete).with(fork_name)
99
+ subject.delete
100
+ end
101
+
102
+ it 'comments on the GitHub PR' do
103
+ Fourchette::Heroku.any_instance.stub(:delete)
104
+ Fourchette::GitHub.any_instance.should_receive(:comment_pr).with(1, 'Test app deleted!')
105
+ subject.delete
106
+ end
107
+ end
108
+
109
+ describe '#fork_name' do
110
+ it { expect(subject.fork_name).to eq fork_name }
111
+ end
112
+
113
+ describe '#branch_name' do
114
+ it { expect(subject.branch_name).to eq '123456' }
115
+ end
116
+
117
+ describe '#pr_number' do
118
+ it { expect(subject.pr_number).to eq 1 }
119
+ end
120
+ end
File without changes
@@ -4,14 +4,18 @@ describe Fourchette::Heroku do
4
4
  let(:heroku) { Fourchette::Heroku.new }
5
5
  let(:from_app_name) { 'awesome app' }
6
6
  let(:to_app_name) { 'awesomer app!' }
7
+ let(:app_list) do
8
+ [
9
+ { 'name' => 'fourchette-pr-7' },
10
+ { 'name' => 'fourchette-pr-8' }
11
+ ]
12
+ end
7
13
 
8
14
  before do
9
15
  client = double('client')
10
16
  client_app = double('client')
11
- app_list = [ { 'name' => 'fourchette-pr-7' }, { 'name' => 'fourchette-pr-8' } ]
12
17
  client_app.stub(:list).and_return(app_list)
13
18
  client.stub(:app).and_return(client_app)
14
-
15
19
  config_var = double('config_var')
16
20
  client.stub(:config_var).and_return(config_var)
17
21
 
@@ -32,9 +36,10 @@ describe Fourchette::Heroku do
32
36
  heroku.stub(:copy_config)
33
37
  heroku.stub(:copy_add_ons)
34
38
  heroku.stub(:copy_pg)
39
+ heroku.stub(:copy_RACK_AND_RAILS_ENV_again)
35
40
  end
36
41
 
37
- ['create_app', 'copy_config', 'copy_add_ons', 'copy_pg'].each do |method_name|
42
+ ['create_app', 'copy_config', 'copy_add_ons', 'copy_pg', 'copy_RACK_AND_RAILS_ENV_again'].each do |method_name|
38
43
  it "calls `#{method_name}'" do
39
44
  heroku.should_receive(method_name)
40
45
  heroku.fork(from_app_name, to_app_name)
@@ -60,56 +65,90 @@ describe Fourchette::Heroku do
60
65
  end
61
66
  end
62
67
 
63
- describe 'private functions' do
64
- describe '#create_app' do
65
- it 'calls app.create on the Heroku client' do
66
- heroku.client.app.should_receive(:create).with({ name: to_app_name })
67
- heroku.send(:create_app, to_app_name)
68
- end
68
+ describe '#create_app' do
69
+ it 'calls app.create on the Heroku client' do
70
+ heroku.client.app.should_receive(:create).with({ name: to_app_name })
71
+ heroku.create_app(to_app_name)
69
72
  end
73
+ end
70
74
 
71
- describe '#copy_config' do
72
- let(:vars) { { 'WHATEVER' => 'ok', 'HEROKU_POSTGRESQL_SOMETHING_URL' => 'FAIL@POSTGRES/DB' } }
73
- let(:cleaned_vars) { { 'WHATEVER' => 'ok'} }
75
+ describe '#copy_config' do
76
+ let(:vars) { { 'WHATEVER' => 'ok', 'HEROKU_POSTGRESQL_SOMETHING_URL' => 'FAIL@POSTGRES/DB' } }
77
+ let(:cleaned_vars) { { 'WHATEVER' => 'ok'} }
74
78
 
75
- it 'calls #config_vars' do
76
- heroku.client.config_var.stub(:update)
77
- heroku.should_receive(:config_vars).with(from_app_name).and_return(vars)
78
- heroku.send(:copy_config, from_app_name, to_app_name)
79
- end
79
+ it 'calls #config_vars' do
80
+ heroku.client.config_var.stub(:update)
81
+ heroku.should_receive(:config_vars).with(from_app_name).and_return(vars)
82
+ heroku.copy_config(from_app_name, to_app_name)
83
+ end
80
84
 
81
- it 'updates config vars without postgres URLs' do
82
- heroku.client.config_var.should_receive(:update).with(to_app_name, cleaned_vars )
83
- heroku.stub(:config_vars).and_return(vars)
84
- heroku.send(:copy_config, 'from', to_app_name)
85
- end
85
+ it 'updates config vars without postgres URLs' do
86
+ heroku.client.config_var.should_receive(:update).with(to_app_name, cleaned_vars )
87
+ heroku.stub(:config_vars).and_return(vars)
88
+ heroku.copy_config('from', to_app_name)
89
+ end
90
+ end
91
+
92
+ describe '#copy_add_ons' do
93
+ let(:addon_list) { [ { 'plan' => { 'name' => 'redistogo' } } ] }
94
+
95
+ before do
96
+ heroku.client.stub(:addon).and_return( double('addon') )
97
+ heroku.client.addon.stub(:create)
98
+ heroku.client.addon.stub(:list).and_return(addon_list)
99
+ end
100
+
101
+ it 'gets the addon list' do
102
+ heroku.client.addon.should_receive(:list).with(from_app_name).and_return(addon_list)
103
+ heroku.copy_add_ons(from_app_name, to_app_name)
86
104
  end
87
105
 
88
- describe '#copy_add_ons' do
89
- let(:addon_list) { [ { 'plan' => { 'name' => 'redistogo' } } ] }
106
+ it 'creates addons' do
107
+ heroku.client.addon.should_receive(:create).with(to_app_name, { plan: 'redistogo' })
108
+ heroku.copy_add_ons(from_app_name, to_app_name)
109
+ end
110
+ end
90
111
 
112
+ describe '#copy_pg' do
113
+ it 'calls Fourchette::Pgbackups#copy' do
114
+ Fourchette::Pgbackups.any_instance.should_receive(:copy).with(from_app_name, to_app_name)
115
+ heroku.copy_pg(from_app_name, to_app_name)
116
+ end
117
+ end
118
+
119
+ describe '#copy_RACK_AND_RAILS_ENV_again' do
120
+ context 'with RACK_ENV or RAILS_ENV setup' do
91
121
  before do
92
- heroku.client.stub(:addon).and_return( double('addon') )
93
- heroku.client.addon.stub(:create)
94
- heroku.client.addon.stub(:list).and_return(addon_list)
122
+ heroku.stub(:get_original_env).and_return({ 'RACK_ENV' => 'qa' })
123
+ end
124
+
125
+ it 'updates the config vars' do
126
+ heroku.client.config_var.should_receive(:update).with(to_app_name, { 'RACK_ENV' => 'qa' })
127
+ heroku.copy_RACK_AND_RAILS_ENV_again(from_app_name, to_app_name)
95
128
  end
129
+ end
96
130
 
97
- it 'gets the addon list' do
98
- heroku.client.addon.should_receive(:list).with(from_app_name).and_return(addon_list)
99
- heroku.send(:copy_add_ons, from_app_name, to_app_name)
131
+ context 'with NO env setup' do
132
+ before do
133
+ heroku.stub(:get_original_env).and_return({})
100
134
  end
101
135
 
102
- it 'creates addons' do
103
- heroku.client.addon.should_receive(:create).with(to_app_name, { plan: 'redistogo' })
104
- heroku.send(:copy_add_ons, from_app_name, to_app_name)
136
+ it 'does not update config vars' do
137
+ heroku.client.config_var.should_not_receive(:update)
138
+ heroku.copy_RACK_AND_RAILS_ENV_again(from_app_name, to_app_name)
105
139
  end
106
140
  end
141
+ end
107
142
 
108
- describe '#copy_pg' do
109
- it 'calls Fourchette::Pgbackups#copy' do
110
- Fourchette::Pgbackups.any_instance.should_receive(:copy).with(from_app_name, to_app_name)
111
- heroku.send(:copy_pg, from_app_name, to_app_name)
112
- end
143
+ describe '#get_original_env' do
144
+ before do
145
+ stub_cong_var = { 'RACK_ENV' => 'qa', 'RAILS_ENV' => 'staging', 'DATABASE_URL' => 'postgres://....' }
146
+ heroku.stub_chain(:client, :config_var, :info).and_return(stub_cong_var)
147
+ end
148
+
149
+ it 'returns the set env vars' do
150
+ return_value = heroku.get_original_env(from_app_name)
151
+ expect(return_value).to eq({'RACK_ENV' => 'qa', 'RAILS_ENV' => 'staging'})
113
152
  end
114
153
  end
115
- end
154
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fourchette::Logger do
4
+ class FakeClassToTest
5
+ include Fourchette::Logger
6
+ end
7
+
8
+ subject { FakeClassToTest.new }
9
+
10
+ it { expect(subject.logger.level).to be Logger::INFO }
11
+
12
+ context 'first time called' do
13
+ it { expect(subject.logger).to be_a(Logger) }
14
+ end
15
+
16
+ context 'each time after' do
17
+ it 'returns the cached version' do
18
+ logger = subject.logger
19
+ expect(subject.logger).to be(logger)
20
+ end
21
+ end
22
+ end
@@ -33,7 +33,7 @@ describe Fourchette::Tarball do
33
33
 
34
34
  it 'creates the tarball' do
35
35
  subject.unstub(:tar)
36
- subject.should_receive(:system).with 'tar -zcvf tmp/1234567/123.tar.gz -C tmp/1234567 .'
36
+ subject.should_receive(:system).with 'tar -zcf tmp/1234567/123.tar.gz -C tmp/1234567 .'
37
37
  subject.url(git_repo_url, branch_name, github_repo)
38
38
  end
39
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fourchette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Philippe Boily
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-06 00:00:00.000000000 Z
11
+ date: 2014-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: heroku
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '3.9'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '3.9'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: platform-api
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: pry-debugger
154
+ name: pry-byebug
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -235,6 +235,7 @@ files:
235
235
  - ".gitignore"
236
236
  - ".travis.yml"
237
237
  - Gemfile
238
+ - Gemfile.lock.orig
238
239
  - Guardfile
239
240
  - LICENSE.txt
240
241
  - Procfile
@@ -258,7 +259,10 @@ files:
258
259
  - lib/fourchette/web/hooks.rb
259
260
  - lib/fourchette/web/tarball.rb
260
261
  - spec/factories/fake_file
262
+ - spec/lib/fourchette/fork_spec.rb
263
+ - spec/lib/fourchette/github_spec.rb
261
264
  - spec/lib/fourchette/heroku_spec.rb
265
+ - spec/lib/fourchette/logger_spec.rb
262
266
  - spec/lib/fourchette/pull_request_spec.rb
263
267
  - spec/lib/fourchette/tarball_spec.rb
264
268
  - spec/lib/web/tarball_spec.rb
@@ -296,7 +300,10 @@ specification_version: 4
296
300
  summary: Your new best friend for isolated testing environments on Heroku.
297
301
  test_files:
298
302
  - spec/factories/fake_file
303
+ - spec/lib/fourchette/fork_spec.rb
304
+ - spec/lib/fourchette/github_spec.rb
299
305
  - spec/lib/fourchette/heroku_spec.rb
306
+ - spec/lib/fourchette/logger_spec.rb
300
307
  - spec/lib/fourchette/pull_request_spec.rb
301
308
  - spec/lib/fourchette/tarball_spec.rb
302
309
  - spec/lib/web/tarball_spec.rb