invoker 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,12 +9,12 @@ describe "Invoker Power configuration" do
9
9
  config = Invoker::Power::Config.create(
10
10
  dns_port: 1200, http_port: 1201, ipfw_rule_number: 010
11
11
  )
12
- File.exists?(Invoker::Power::Config::CONFIG_LOCATION).should == true
12
+ expect(File.exists?(Invoker::Power::Config::CONFIG_LOCATION)).to be_true
13
13
 
14
14
  config = Invoker::Power::Config.load_config()
15
- config.dns_port.should == 1200
16
- config.http_port.should == 1201
17
- config.ipfw_rule_number.should == 010
15
+ expect(config.dns_port).to eq(1200)
16
+ expect(config.http_port).to eq(1201)
17
+ expect(config.ipfw_rule_number).to eq(010)
18
18
  ensure
19
19
  File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
20
20
  File.delete(Invoker::Power::Config::CONFIG_LOCATION)
@@ -0,0 +1,34 @@
1
+ require "spec_helper"
2
+ require "tempfile"
3
+
4
+ describe Invoker::Power::HttpResponse do
5
+ before do
6
+ @http_response = Invoker::Power::HttpResponse.new()
7
+ end
8
+
9
+ it "should allow user to send a file" do
10
+ begin
11
+ file = Tempfile.new("error.html")
12
+ file_content = "Error message"
13
+ file.write(file_content)
14
+ file.close
15
+
16
+ @http_response.use_file_as_body(file.path)
17
+ expect(@http_response.body).to eq(file_content)
18
+ expect(@http_response.http_string).to include(file_content)
19
+ ensure
20
+ file.unlink
21
+ end
22
+ end
23
+
24
+ it "should allow user to set headers" do
25
+ @http_response["Content-Type"] = "text/html"
26
+ expect(@http_response.header["Content-Type"]).to eq("text/html")
27
+ expect(@http_response.http_string).to include("Content-Type")
28
+ end
29
+
30
+ it "should allow user to set status" do
31
+ @http_response.status = 503
32
+ expect(@http_response.http_string).to include(Invoker::Power::HttpResponse::STATUS_MAPS[503])
33
+ end
34
+ end
@@ -7,10 +7,10 @@ describe "PortFinder" do
7
7
  end
8
8
 
9
9
  it "should find a http port" do
10
- @port_finder.http_port.should.not == nil
10
+ expect(@port_finder.http_port).not_to be_nil
11
11
  end
12
12
 
13
13
  it "should find a dns port" do
14
- @port_finder.dns_port.should.not == nil
14
+ expect(@port_finder.dns_port).not_to be_nil
15
15
  end
16
16
  end
@@ -1,34 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "Setup" do
4
- before {
5
- @original_verbosity = $VERBOSE
6
- $VERBOSE = nil
7
- @old_config = Invoker::Power::Config::CONFIG_LOCATION
8
- Invoker::Power::Config.const_set(:CONFIG_LOCATION, "/tmp/.invoker")
9
-
10
- File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
11
- File.delete(Invoker::Power::Config::CONFIG_LOCATION)
12
-
13
- @old_resolver = Invoker::Power::Setup::RESOLVER_FILE
14
- Invoker::Power::Setup.const_set(:RESOLVER_FILE, "/tmp/invoker-dev")
15
-
16
- File.exists?(Invoker::Power::Setup::RESOLVER_FILE) &&
17
- File.delete(Invoker::Power::Setup::RESOLVER_FILE)
18
- }
19
-
20
- after {
21
- File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
22
- File.delete(Invoker::Power::Config::CONFIG_LOCATION)
23
-
24
- Invoker::Power::Config.const_set(:CONFIG_LOCATION, @old_config)
25
-
26
- File.exists?(Invoker::Power::Setup::RESOLVER_FILE) &&
27
- File.delete(Invoker::Power::Setup::RESOLVER_FILE)
28
- Invoker::Power::Setup.const_set(:RESOLVER_FILE, @old_resolver)
29
- $VERBOSE = @original_verbosity
30
- }
31
-
32
4
  describe "When no setup exists" do
33
5
  it "should create a config file with port etc" do
34
6
  setup = Invoker::Power::Setup.new()
@@ -40,8 +12,8 @@ describe "Setup" do
40
12
  setup.setup_invoker
41
13
 
42
14
  config = Invoker::Power::Config.load_config()
43
- config.http_port.should.not == nil
44
- config.dns_port.should.not == nil
15
+ expect(config.http_port).not_to be_nil
16
+ expect(config.dns_port).not_to be_nil
45
17
  end
46
18
  end
47
19
 
@@ -109,4 +81,24 @@ describe "Setup" do
109
81
  setup.uninstall_invoker
110
82
  end
111
83
  end
84
+
85
+ describe "setup on fresh osx install" do
86
+ context "when resolver directory does not exist" do
87
+ before do
88
+ @setup = Invoker::Power::Setup.new()
89
+ FileUtils.rm_rf(Invoker::Power::Setup::RESOLVER_DIR)
90
+ end
91
+
92
+ it "should create the directory and install" do
93
+ @setup.expects(:setup_resolver_file).returns(true)
94
+ @setup.expects(:drop_to_normal_user).returns(true)
95
+ @setup.expects(:flush_dns_rules).returns(true)
96
+ @setup.expects(:install_firewall).once()
97
+
98
+ @setup.setup_invoker()
99
+
100
+ expect(Dir.exists?(Invoker::Power::Setup::RESOLVER_DIR)).to be_true
101
+ end
102
+ end
103
+ end
112
104
  end
@@ -1,12 +1,64 @@
1
- require "bacon"
2
- require "mocha-on-bacon"
3
-
4
- __LIB_PATH__ = File.join(File.dirname(__FILE__), "..")
5
- $: << __LIB_PATH__
6
-
7
1
  require "pry"
8
2
  require "invoker"
9
3
 
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # Require this file using `require "spec_helper"` to ensure that it is only
7
+ # loaded once.
8
+ #
9
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
10
+ RSpec.configure do |config|
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+ config.treat_symbols_as_metadata_keys_with_true_values = true
15
+ config.run_all_when_everything_filtered = true
16
+ config.filter_run :focus
17
+ config.mock_framework = :mocha
18
+
19
+ config.before(:each) do
20
+ @original_verbosity = $VERBOSE
21
+ $VERBOSE = nil
22
+ @old_config = Invoker::Power::Config::CONFIG_LOCATION
23
+ Invoker::Power::Config.const_set(:CONFIG_LOCATION, "/tmp/.invoker")
24
+
25
+ File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
26
+ File.delete(Invoker::Power::Config::CONFIG_LOCATION)
27
+
28
+ @old_resolver = Invoker::Power::Setup::RESOLVER_FILE
29
+ Invoker::Power::Setup.const_set(:RESOLVER_FILE, "/tmp/resolver/invoker-dev")
30
+ Invoker::Power::Setup.const_set(:RESOLVER_DIR, "/tmp/resolver")
31
+
32
+ unless Dir.exists?(Invoker::Power::Setup::RESOLVER_DIR)
33
+ FileUtils.mkdir(Invoker::Power::Setup::RESOLVER_DIR)
34
+ end
35
+
36
+ File.exists?(Invoker::Power::Setup::RESOLVER_FILE) &&
37
+ File.delete(Invoker::Power::Setup::RESOLVER_FILE)
38
+ end
39
+
40
+ config.after(:each) do
41
+ File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
42
+ File.delete(Invoker::Power::Config::CONFIG_LOCATION)
43
+
44
+ Invoker::Power::Config.const_set(:CONFIG_LOCATION, @old_config)
45
+
46
+ File.exists?(Invoker::Power::Setup::RESOLVER_FILE) &&
47
+ File.delete(Invoker::Power::Setup::RESOLVER_FILE)
48
+
49
+ FileUtils.rm_rf(Invoker::Power::Setup::RESOLVER_DIR)
50
+ Invoker::Power::Setup.const_set(:RESOLVER_FILE, @old_resolver)
51
+
52
+ $VERBOSE = @original_verbosity
53
+ end
54
+
55
+ # Run specs in random order to surface order dependencies. If you find an
56
+ # order dependency and want to debug it, you can fix the order by providing
57
+ # the seed, which is printed after each run.
58
+ # --seed 1234
59
+ config.order = 'random'
60
+ end
61
+
10
62
  ENV["INVOKER_TESTS"] = "true"
11
63
 
12
64
  def invoker_config
@@ -26,5 +78,3 @@ def invoker_commander
26
78
  Invoker::COMMANDER
27
79
  end
28
80
  end
29
-
30
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invoker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hemant Kumar
@@ -137,59 +137,59 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.6.0
139
139
  - !ruby/object:Gem::Dependency
140
- name: bacon
140
+ name: dotenv
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ! '>='
143
+ - - ~>
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
145
+ version: 0.9.0
146
+ type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ! '>='
150
+ - - ~>
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: 0.9.0
153
153
  - !ruby/object:Gem::Dependency
154
- name: mocha
154
+ name: rspec
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ! '>='
157
+ - - '>='
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ! '>='
164
+ - - '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: mocha-on-bacon
168
+ name: mocha
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ! '>='
171
+ - - '>='
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ! '>='
178
+ - - '>='
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rake
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ! '>='
185
+ - - '>='
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ! '>='
192
+ - - '>='
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  description: Something small for process management
@@ -200,6 +200,7 @@ extensions: []
200
200
  extra_rdoc_files: []
201
201
  files:
202
202
  - .gitignore
203
+ - .rspec
203
204
  - .travis.yml
204
205
  - Gemfile
205
206
  - MIT-LICENSE
@@ -217,13 +218,17 @@ files:
217
218
  - lib/invoker/logger.rb
218
219
  - lib/invoker/parsers/config.rb
219
220
  - lib/invoker/parsers/option_parser.rb
221
+ - lib/invoker/parsers/procfile.rb
220
222
  - lib/invoker/power.rb
221
223
  - lib/invoker/power/balancer.rb
222
224
  - lib/invoker/power/config.rb
223
225
  - lib/invoker/power/dns.rb
226
+ - lib/invoker/power/http_response.rb
224
227
  - lib/invoker/power/port_finder.rb
225
228
  - lib/invoker/power/powerup.rb
226
229
  - lib/invoker/power/setup.rb
230
+ - lib/invoker/power/templates/404.html
231
+ - lib/invoker/power/templates/503.html
227
232
  - lib/invoker/process_printer.rb
228
233
  - lib/invoker/reactor.rb
229
234
  - lib/invoker/runner.rb
@@ -236,10 +241,11 @@ files:
236
241
  - spec/invoker/event/manager_spec.rb
237
242
  - spec/invoker/invoker_spec.rb
238
243
  - spec/invoker/power/config_spec.rb
244
+ - spec/invoker/power/http_response_spec.rb
239
245
  - spec/invoker/power/port_finder_spec.rb
240
246
  - spec/invoker/power/setup_spec.rb
241
247
  - spec/spec_helper.rb
242
- homepage: http://github.com/code-mancers/invoker
248
+ homepage: http://invoker.codemancers.com
243
249
  licenses:
244
250
  - MIT
245
251
  metadata: {}
@@ -249,17 +255,17 @@ require_paths:
249
255
  - lib
250
256
  required_ruby_version: !ruby/object:Gem::Requirement
251
257
  requirements:
252
- - - ! '>='
258
+ - - '>='
253
259
  - !ruby/object:Gem::Version
254
260
  version: '0'
255
261
  required_rubygems_version: !ruby/object:Gem::Requirement
256
262
  requirements:
257
- - - ! '>='
263
+ - - '>='
258
264
  - !ruby/object:Gem::Version
259
265
  version: '0'
260
266
  requirements: []
261
267
  rubyforge_project:
262
- rubygems_version: 2.0.7
268
+ rubygems_version: 2.0.3
263
269
  signing_key:
264
270
  specification_version: 4
265
271
  summary: Something small for Process management
@@ -271,6 +277,7 @@ test_files:
271
277
  - spec/invoker/event/manager_spec.rb
272
278
  - spec/invoker/invoker_spec.rb
273
279
  - spec/invoker/power/config_spec.rb
280
+ - spec/invoker/power/http_response_spec.rb
274
281
  - spec/invoker/power/port_finder_spec.rb
275
282
  - spec/invoker/power/setup_spec.rb
276
283
  - spec/spec_helper.rb