heroku-rails-saas 0.1.7 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe HerokuRailsSaas::Displayer do
4
+ before(:each) do
5
+ @color = "green"
6
+ @remote_name = "Random"
7
+ @displayer = described_class.new(@remote_name, @color)
8
+ end
9
+
10
+ describe "#labelize" do
11
+ before(:each) do
12
+ @orig_stdout = $stdout
13
+ @output_string_io = StringIO.new
14
+ $stdout = @output_string_io
15
+ end
16
+
17
+ after(:each) do
18
+ $stdout = @orig_stdout
19
+ end
20
+
21
+ context "with new_line enable" do
22
+ it "should prepend 'output message' with a label 'Random' with a font color of 'green'" do
23
+ @displayer.labelize("output message")
24
+ @output_string_io.string.should == "[ \e[32mRandom\e[0m ] output message\n"
25
+ end
26
+ end
27
+
28
+ context "with new_line disable" do
29
+ it "should prepend 'output message' with a label 'Random' with a font color of 'green'" do
30
+ @displayer.labelize("output message", false)
31
+ @output_string_io.string.should == "[ \e[32mRandom\e[0m ] output message"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe HerokuRailsSaas::Helper do
4
+ describe "color methods" do
5
+ it "should defined by HerokuRailsSaas::Helper::COLORS" do
6
+ described_class.const_get("COLORS").each do |color|
7
+ described_class.methods.should include(color.to_sym)
8
+ end
9
+ end
10
+
11
+ it "should output color font" do
12
+ described_class.red("message").should == "\e[31mmessage\e[0m"
13
+ described_class.green("message").should == "\e[32mmessage\e[0m"
14
+ described_class.yellow("message").should == "\e[33mmessage\e[0m"
15
+ described_class.magenta("message").should == "\e[35mmessage\e[0m"
16
+ described_class.cyan("message").should == "\e[36mmessage\e[0m"
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe HerokuRailsSaas::HerokuClient do
4
+ it "should raise StandardError when there is no .netrc" do
5
+ File.stub!(:exists?).and_return(false)
6
+ lambda { described_class.new }.should raise_error(StandardError)
7
+ end
8
+
9
+ it "should obtain a user and api_token when there is a .netrc" do
10
+ netrc_pathname = config_path("example.netrc").to_s
11
+ File.chmod(0600, netrc_pathname)
12
+ fixture_netrc = Netrc.read(netrc_pathname)
13
+ Netrc.should_receive(:read).and_return(fixture_netrc)
14
+ File.stub!(:exists?).and_return(true)
15
+
16
+ client = described_class.new
17
+ client.api_token.should == "THIS_IS_YOU_API_TOKEN"
18
+ client.user.should == "user@example.com"
19
+ end
20
+
21
+ context "Making Heroku calls" do
22
+ before(:each) do
23
+ WebMock.enable!
24
+
25
+ netrc_pathname = config_path("example.netrc").to_s
26
+ File.chmod(0600, netrc_pathname)
27
+ fixture_netrc = Netrc.read(netrc_pathname)
28
+ Netrc.should_receive(:read).and_return(fixture_netrc)
29
+ File.stub!(:exists?).and_return(true)
30
+
31
+ @client = described_class.new
32
+ end
33
+
34
+ after(:each) do
35
+ WebMock.reset!
36
+ WebMock.disable!
37
+ end
38
+
39
+ it "should return the output when making a valid API call" do
40
+ response = [{"id" => 1000010, "name" => "awesomeapp-staging", "dynos" => 1, "workers" => 0,
41
+ "repo_size" => 41218048, "slug_size" => 34458496, "stack" => "cedar"},
42
+ {"id" => 1000010, "name" => "awesomeapp", "dynos" => 1, "workers" => 0,
43
+ "repo_size" => 41218048, "slug_size" => 34458496, "stack" => "cedar"}]
44
+ stub_request(:any, /.*heroku.*/).to_return(:body => response.to_json, :status => 200)
45
+ @client.get_apps.should == response
46
+ end
47
+
48
+ it "should raise RuntimeError when making a invalid API call" do
49
+ response = {"id" => "forbidden", "error" => "You do not have permission to provision paid resources for awesomeapp-staging.\\nOnly the app owner, admin@awesomeapp.com, can do that."}
50
+ stub_request(:any, /.*heroku.*/).to_return(:status => 403, :body => response.to_json)
51
+ lambda { @client.post_addon("awesomeapp-staging", "memcache:250mb") }.should raise_error(RuntimeError)
52
+ end
53
+
54
+ it "should raise NoMethodError when making a non-exisiting API call" do
55
+ lambda { @client.non_existing_api_call }.should raise_error(NoMethodError)
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe HerokuRailsSaas::Runner do
4
+ describe "#each_heroku_app" do
5
+ it "should return all apps in all environments" do
6
+ config_files = {:default => config_path("heroku-config.yml"), :apps => [config_path("awesomeapp.yml"), config_path("mediocreapp.yml")]}
7
+ config = HerokuRailsSaas::Config.new(config_files)
8
+ runner = described_class.new(config)
9
+ runner.all_environments
10
+ runner.each_heroku_app {}.should == ["awesomeapp:production", "awesomeapp:staging", "mediocreapp:development"]
11
+ end
12
+
13
+ it "should not return a production app if @environment is not specified and there's only one app" do
14
+ config_files = {:default => config_path("heroku-config.yml"), :apps => [config_path("mediocreapp.yml")]}
15
+ config = HerokuRailsSaas::Config.new(config_files)
16
+ runner = described_class.new(config)
17
+ runner.instance_variable_set("@environments", [])
18
+ lambda { runner.each_heroku_app }.should raise_error(SystemExit)
19
+ end
20
+ end
21
+
22
+ context "Methods" do
23
+ let(:client) { HerokuRailsSaas::HerokuClient.new }
24
+
25
+ before(:each) do
26
+ WebMock.enable!
27
+
28
+ config_files = {:default => config_path("heroku-config.yml"), :apps => [config_path("awesomeapp.yml")]}
29
+ config = HerokuRailsSaas::Config.new(config_files)
30
+ @runner = described_class.new(config)
31
+ @runner.stub!(:heroku).and_return(client)
32
+ end
33
+
34
+ after(:each) do
35
+ WebMock.reset!
36
+ WebMock.disable!
37
+ end
38
+
39
+ describe "#setup_app" do
40
+ it "should create a new app for 'awesomeapp:production'"do
41
+ stub_request(:get, "https://api.heroku.com/apps").to_return(:body => [].to_json, :status => 200)
42
+ stub_request(:post, /.*api\.heroku\.com\/apps.*/).to_return(:body => {}.to_json, :status => 202)
43
+
44
+ @runner.add_app("awesomeapp:production")
45
+ @runner.setup_app
46
+ end
47
+ end
48
+
49
+ describe "#setup_stack" do
50
+ end
51
+
52
+ describe "#setup_collaborators" do
53
+ end
54
+
55
+ describe "#setup_addons" do
56
+ end
57
+
58
+ describe "#setup_config" do
59
+ end
60
+
61
+ describe "#setup_domains" do
62
+ end
63
+ end
64
+ end
@@ -1,5 +1,8 @@
1
- require 'heroku-rails-saas'
1
+ require 'rubygems'
2
2
  require 'bundler/setup'
3
+ require 'rails'
4
+ require 'heroku-rails-saas'
5
+ require 'webmock/rspec'
3
6
 
4
7
 
5
8
  RSpec.configure do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-rails-saas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,22 +13,91 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-08-14 00:00:00.000000000Z
16
+ date: 2013-05-02 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
- name: heroku
20
- requirement: &2165278020 !ruby/object:Gem::Requirement
19
+ name: rails
20
+ requirement: !ruby/object:Gem::Requirement
21
21
  none: false
22
22
  requirements:
23
23
  - - ! '>='
24
24
  - !ruby/object:Gem::Version
25
- version: 2.24.1
25
+ version: '0'
26
+ type: :runtime
27
+ prerelease: false
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ - !ruby/object:Gem::Dependency
35
+ name: heroku-api
36
+ requirement: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: 0.3.8
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: 0.3.8
50
+ - !ruby/object:Gem::Dependency
51
+ name: netrc
52
+ requirement: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: 0.7.7
58
+ type: :runtime
59
+ prerelease: false
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 0.7.7
66
+ - !ruby/object:Gem::Dependency
67
+ name: parallel
68
+ requirement: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ version: 0.6.2
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ~>
80
+ - !ruby/object:Gem::Version
81
+ version: 0.6.2
82
+ - !ruby/object:Gem::Dependency
83
+ name: rendezvous
84
+ requirement: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.0.2
26
90
  type: :runtime
27
91
  prerelease: false
28
- version_requirements: *2165278020
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: 0.0.2
29
98
  - !ruby/object:Gem::Dependency
30
99
  name: rspec
31
- requirement: &2165277300 !ruby/object:Gem::Requirement
100
+ requirement: !ruby/object:Gem::Requirement
32
101
  none: false
33
102
  requirements:
34
103
  - - ~>
@@ -36,18 +105,28 @@ dependencies:
36
105
  version: '2.0'
37
106
  type: :development
38
107
  prerelease: false
39
- version_requirements: *2165277300
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ~>
112
+ - !ruby/object:Gem::Version
113
+ version: '2.0'
40
114
  - !ruby/object:Gem::Dependency
41
- name: activesupport
42
- requirement: &2165276480 !ruby/object:Gem::Requirement
115
+ name: webmock
116
+ requirement: !ruby/object:Gem::Requirement
43
117
  none: false
44
118
  requirements:
45
- - - ! '>='
119
+ - - ~>
46
120
  - !ruby/object:Gem::Version
47
- version: '0'
121
+ version: 1.11.0
48
122
  type: :development
49
123
  prerelease: false
50
- version_requirements: *2165276480
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ~>
128
+ - !ruby/object:Gem::Version
129
+ version: 1.11.0
51
130
  description: Manage multiple Heroku instances/apps for a single Rails app using Rake.
52
131
  email: lance.sanchez@gmail.com
53
132
  executables: []
@@ -58,29 +137,41 @@ extra_rdoc_files:
58
137
  - TODO
59
138
  - CHANGELOG
60
139
  files:
140
+ - .bundle/config
141
+ - .gitignore
142
+ - .rspec
143
+ - .rvmrc
144
+ - CHANGELOG
145
+ - Gemfile
146
+ - Gemfile.lock
147
+ - LICENSE
148
+ - README.md
149
+ - Rakefile
150
+ - TODO
151
+ - data/cacert.pem
152
+ - heroku-rails-saas.gemspec
61
153
  - lib/generators/heroku/config_generator.rb
62
154
  - lib/generators/templates/heroku.rake
63
155
  - lib/generators/templates/heroku.yml
64
- - lib/heroku/rails/tasks.rb
156
+ - lib/heroku-rails-saas.rb
65
157
  - lib/heroku-rails-saas/config.rb
66
- - lib/heroku-rails-saas/hash_recursive_merge.rb
158
+ - lib/heroku-rails-saas/displayer.rb
159
+ - lib/heroku-rails-saas/helper.rb
160
+ - lib/heroku-rails-saas/heroku_client.rb
67
161
  - lib/heroku-rails-saas/railtie.rb
68
162
  - lib/heroku-rails-saas/runner.rb
69
- - lib/heroku-rails-saas.rb
163
+ - lib/heroku-rails-saas/version.rb
164
+ - lib/heroku/rails/tasks.rb
70
165
  - spec/fixtures/awesomeapp.yml
166
+ - spec/fixtures/example.netrc
71
167
  - spec/fixtures/heroku-config.yml
72
168
  - spec/fixtures/mediocreapp.yml
73
- - spec/heroku/rails/saas/heroku_config_spec.rb
74
- - spec/heroku/rails/saas/heroku_runner_spec.rb
169
+ - spec/heroku-rails-saas/config_spec.rb
170
+ - spec/heroku-rails-saas/displayer_spec.rb
171
+ - spec/heroku-rails-saas/helper_spec.rb
172
+ - spec/heroku-rails-saas/heorku_client_spec.rb
173
+ - spec/heroku-rails-saas/runner_spec.rb
75
174
  - spec/spec_helper.rb
76
- - heroku-rails.gemspec
77
- - Gemfile
78
- - Gemfile.lock
79
- - CHANGELOG
80
- - LICENSE
81
- - Rakefile
82
- - README.md
83
- - TODO
84
175
  homepage: http://github.com/darkbushido/heroku-rails-saas
85
176
  licenses: []
86
177
  post_install_message:
@@ -94,28 +185,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
185
  - - ! '>='
95
186
  - !ruby/object:Gem::Version
96
187
  version: '0'
97
- segments:
98
- - 0
99
- hash: 2780192577745053897
100
188
  required_rubygems_version: !ruby/object:Gem::Requirement
101
189
  none: false
102
190
  requirements:
103
191
  - - ! '>='
104
192
  - !ruby/object:Gem::Version
105
193
  version: '0'
106
- segments:
107
- - 0
108
- hash: 2780192577745053897
109
194
  requirements: []
110
195
  rubyforge_project: none
111
- rubygems_version: 1.8.6
196
+ rubygems_version: 1.8.24
112
197
  signing_key:
113
198
  specification_version: 3
114
199
  summary: Deployment and configuration tools for Heroku/Rails
115
200
  test_files:
116
201
  - spec/fixtures/awesomeapp.yml
202
+ - spec/fixtures/example.netrc
117
203
  - spec/fixtures/heroku-config.yml
118
204
  - spec/fixtures/mediocreapp.yml
119
- - spec/heroku/rails/saas/heroku_config_spec.rb
120
- - spec/heroku/rails/saas/heroku_runner_spec.rb
205
+ - spec/heroku-rails-saas/config_spec.rb
206
+ - spec/heroku-rails-saas/displayer_spec.rb
207
+ - spec/heroku-rails-saas/helper_spec.rb
208
+ - spec/heroku-rails-saas/heorku_client_spec.rb
209
+ - spec/heroku-rails-saas/runner_spec.rb
121
210
  - spec/spec_helper.rb
211
+ has_rdoc:
@@ -1,39 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = "heroku-rails-saas"
3
- s.version = "0.1.7"
4
-
5
- s.authors = [ "Elijah Miller", "Glenn Roberts", "Jacques Crocker", "Lance Sanchez", "Chris Trinh"]
6
-
7
- s.summary = "Deployment and configuration tools for Heroku/Rails"
8
- s.description = "Manage multiple Heroku instances/apps for a single Rails app using Rake."
9
-
10
- s.email = "lance.sanchez@gmail.com"
11
- s.homepage = "http://github.com/darkbushido/heroku-rails-saas"
12
- s.rubyforge_project = "none"
13
-
14
- s.require_paths = ["lib"]
15
- s.files = Dir['lib/**/*',
16
- 'spec/**/*',
17
- 'heroku-rails.gemspec',
18
- 'Gemfile',
19
- 'Gemfile.lock',
20
- 'CHANGELOG',
21
- 'LICENSE',
22
- 'Rakefile',
23
- 'README.md',
24
- 'TODO']
25
-
26
- s.test_files = Dir['spec/**/*']
27
- s.rdoc_options = ["--charset=UTF-8"]
28
- s.extra_rdoc_files = [
29
- "LICENSE",
30
- "README.md",
31
- "TODO",
32
- "CHANGELOG"
33
- ]
34
-
35
- s.add_runtime_dependency "heroku", ">= 2.24.1"
36
- s.add_development_dependency "rspec", "~> 2.0"
37
- s.add_development_dependency "activesupport"
38
- end
39
-