camping 3.2.4 → 3.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,30 +15,3 @@ namespace 'test' do
15
15
  end
16
16
  end
17
17
 
18
- # def delete_file(filename="")
19
- # return if !File.exist? filename
20
- # begin
21
- # f = File.open(filename, 'r')
22
- # ensure
23
- # f.close unless f.nil? or f.closed?
24
- # File.delete(filename) if File.exist? filename
25
- # end
26
- # end
27
-
28
- ## Integration Test
29
- # desc "Perform an integration test"
30
- # task :integration do
31
- # `bundle install` # remove gems
32
- # `bundle clean --force` # remove gems
33
- # puts Dir.pwd
34
- # # `gem install` # add bundler.
35
- # `bundle install` # rewrites Gemfile.lock
36
- # `bundle add camping --path=../../`
37
- # # `bundle add camping puma`
38
- # # `bundle add minitest -g=test`
39
- # # `bundle add minitest-reporters -g=test`
40
- # # `bundle add rack-test -g=test`
41
- # # `bundle add minitest-hooks -g=test`
42
- # # t.libs << "/"
43
- # # t.test_files = FileList['test/test_*.rb']
44
- # end
@@ -0,0 +1,7 @@
1
+ module Starty
2
+
3
+ def message = "Hello Friends"
4
+
5
+ def name = "Starty"
6
+
7
+ end
@@ -16,11 +16,9 @@ module TestCaseLoader
16
16
  move_to_reloader
17
17
  loader.reload!
18
18
  assert Object.const_defined?(:Reloader), "Reloader didn't load app"
19
- # puts "before_all called"
20
19
  end
21
20
 
22
21
  def after_all
23
- # puts "after_all called"
24
22
  assert Object.const_defined?(:Reloader), "Test removed app"
25
23
  loader.remove_constants
26
24
  assert !Object.const_defined?(:Reloader), "Loader didn't remove app"
@@ -40,7 +38,6 @@ class TestLoader < TestCase
40
38
  super
41
39
  $counter = 0
42
40
  loader.reload!
43
- # puts "setup called"
44
41
  end
45
42
 
46
43
  def test_counter
@@ -71,11 +68,11 @@ class TestLoader < TestCase
71
68
  end
72
69
  end
73
70
 
74
- # class TestConfigRu < TestLoader
75
- # BASE = File.expand_path('../apps/reloader', __FILE__)
76
- # def file; BASE + '/config.ru' end
71
+ class TestConfigRu < TestLoader
72
+ BASE = File.expand_path('../apps/reloader', __FILE__)
73
+ def file; BASE + '/config.ru' end
77
74
 
78
- # def test_name
79
- # assert_equal Reloader, loader.apps[:reloader]
80
- # end
81
- # end
75
+ def test_name
76
+ assert_equal Reloader, loader.apps[:reloader]
77
+ end
78
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ $:.unshift(File.expand_path('../lib', __dir__))
4
+ # $:.unshift(File.dirname(__FILE__) + '../../lib')
5
+
6
+ require_relative '../../lib/camping'
7
+ require_relative '../../lib/camping/server'
8
+
9
+ require 'minitest/global_expectations/autorun'
10
+ require 'stringio'
11
+
12
+ require 'minitest/reporters'
13
+ Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(:color => true)]
@@ -0,0 +1,103 @@
1
+ require_relative 'helper'
2
+
3
+ require 'tempfile'
4
+ require 'socket'
5
+ require 'webrick'
6
+ require 'open-uri'
7
+ require 'net/http'
8
+ require 'net/https'
9
+
10
+ begin
11
+ require 'stackprof'
12
+ require 'tmpdir'
13
+ rescue LoadError
14
+ else
15
+ test_profile = true
16
+ end
17
+
18
+ describe Camping::Server do
19
+ argv = Camping::Server::ARGV = []
20
+ define_method(:argv) { argv }
21
+
22
+ before {
23
+ argv.clear
24
+ @original_dir = Dir.pwd
25
+ Dir.chdir "test/integration"
26
+ }
27
+
28
+ after {
29
+ Dir.chdir @original_dir
30
+ }
31
+
32
+ # Probably need to revise this for the camping port
33
+ def app
34
+ lambda { |env| [200, { 'content-type' => 'text/plain' }, ['success']] }
35
+ end
36
+
37
+ # learn what this is doing.
38
+ def with_stderr
39
+ old, $stderr = $stderr, StringIO.new
40
+ yield $stderr
41
+ ensure
42
+ $stderr = old
43
+ end
44
+
45
+ # first copied test to make sure this works right.
46
+ it "overrides :config if :app is passed in" do
47
+ server = Rackup::Server.new(app: "FOO")
48
+ server.app.must_equal "FOO"
49
+ end
50
+
51
+ # Fails a lot
52
+ # it "runs a server" do
53
+ # pidfile = Tempfile.open('pidfile') { |f| break f }
54
+ # FileUtils.rm pidfile.path
55
+ # server = Camping::Server.new(
56
+ # app: "FOO",
57
+ # environment: 'none',
58
+ # pid: pidfile.path,
59
+ # Port: TCPServer.open('localhost', '0'){|s| s.addr[1] },
60
+ # Host: 'localhost',
61
+ # Logger: WEBrick::Log.new(nil, WEBrick::BasicLog::WARN),
62
+ # AccessLog: [],
63
+ # daemonize: false,
64
+ # server: 'webrick'
65
+ # )
66
+ # t = Thread.new { server.start { |s| Thread.current[:server] = s } }
67
+ # t.join(0.01) until t[:server] && t[:server].status != :Stop
68
+ # body = if URI.respond_to?(:open)
69
+ # URI.open("http://localhost:#{server.options[:Port]}/") { |f| f.read }
70
+ # else
71
+ # open("http://localhost:#{server.options[:Port]}/") { |f| f.read }
72
+ # end
73
+ # body.must_include 'Let&#39;s go Camping'
74
+ # Process.kill(:INT, $$)
75
+ # t.join
76
+ # open(pidfile.path) { |f| f.read.must_equal $$.to_s }
77
+ # end
78
+
79
+ it "Loads the kindling initializers" do
80
+ pidfile = Tempfile.open('pidfile') { |f| break f }
81
+ FileUtils.rm pidfile.path
82
+ server = Camping::Server.new
83
+
84
+ starty_file = false
85
+ starty_name = "Starty"
86
+
87
+ t = Thread.new {
88
+ server.start { |s|
89
+ Thread.current[:server] = s
90
+ starty_file = Object.constants.include? :Starty
91
+ starty_name = Starty.name
92
+ }
93
+ }
94
+ t.join(0.01) until t[:server] && t[:server].status != :Stop
95
+
96
+ starty_file.must_equal true
97
+ starty_name.must_equal "Starty"
98
+
99
+ Process.kill(:INT, $$)
100
+ t.join
101
+ end
102
+
103
+ end
data/test/test_helper.rb CHANGED
@@ -18,7 +18,6 @@ require 'minitest/reporters'
18
18
  require 'minitest/hooks'
19
19
  Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(:color => true)]
20
20
 
21
-
22
21
  module CommandLineCommands
23
22
 
24
23
  def move_to_tmp
@@ -47,30 +46,11 @@ module CommandLineCommands
47
46
 
48
47
  # deletes the temporary directories found in the /apps directory for reloader testing.
49
48
  def leave_reloader
50
- Dir.chdir @original_dir
49
+ leave_dir
51
50
  `rm -rf test/apps/reloader/apps` if File.exist?('test/apps/reloader/apps')
52
51
  `rm -rf test/apps/reloader/lib` if File.exist?('test/apps/reloader/lib')
53
52
  end
54
53
 
55
- # move_to_app
56
- # Moves to an app directory,
57
- # @app_name: String,
58
- def move_to_app(app_name = "")
59
- @original_dir = Dir.pwd
60
- Dir.chdir "test"
61
- Dir.chdir "apps"
62
- Dir.chdir directory
63
- Dir.mkdir("apps") unless Dir.exist?("apps")
64
- Dir.mkdir("lib") unless Dir.exist?("lib")
65
- end
66
-
67
- def leave_app(app_name = "", purge_directorys = [])
68
- Dir.chdir @original_dir
69
- purge_directorys.each do |dir|
70
- `rm -rf test/apps/#{app_name}/#{dir}` if File.exist?('test/apps/#{app_name}/#{dir}')
71
- end
72
- end
73
-
74
54
  # Moves to the loader directory
75
55
  def move_to_loader
76
56
  @original_dir = Dir.pwd
@@ -81,11 +61,15 @@ module CommandLineCommands
81
61
  Dir.mkdir("lib") unless Dir.exist?("lib")
82
62
  end
83
63
 
84
- # deletes the temporary directories found in the /apps directory for reloader testing.
85
- def leave_loader
86
- Dir.chdir @original_dir
64
+ # generic move_to(dir) method
65
+ def move_to(dir)
66
+ @original_dir = Dir.pwd
67
+ Dir.chdir dir
87
68
  end
88
69
 
70
+ # generic leave_dir method
71
+ def leave_dir = Dir.chdir @original_dir
72
+
89
73
  def write(file, content)
90
74
  raise "cannot write nil" unless file
91
75
  file = tmp_file(file)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camping
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.4
4
+ version: 3.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - why the lucky stiff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-11 00:00:00.000000000 Z
11
+ date: 2024-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -186,6 +186,62 @@ dependencies:
186
186
  - - "~>"
187
187
  - !ruby/object:Gem::Version
188
188
  version: 1.0.4
189
+ - !ruby/object:Gem::Dependency
190
+ name: bundler
191
+ requirement: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ type: :development
197
+ prerelease: false
198
+ version_requirements: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ - !ruby/object:Gem::Dependency
204
+ name: minitest
205
+ requirement: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - "~>"
208
+ - !ruby/object:Gem::Version
209
+ version: '5.0'
210
+ type: :development
211
+ prerelease: false
212
+ version_requirements: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - "~>"
215
+ - !ruby/object:Gem::Version
216
+ version: '5.0'
217
+ - !ruby/object:Gem::Dependency
218
+ name: minitest-global_expectations
219
+ requirement: !ruby/object:Gem::Requirement
220
+ requirements:
221
+ - - ">="
222
+ - !ruby/object:Gem::Version
223
+ version: '0'
224
+ type: :development
225
+ prerelease: false
226
+ version_requirements: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ - !ruby/object:Gem::Dependency
232
+ name: minitest-sprint
233
+ requirement: !ruby/object:Gem::Requirement
234
+ requirements:
235
+ - - ">="
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
+ type: :development
239
+ prerelease: false
240
+ version_requirements: !ruby/object:Gem::Requirement
241
+ requirements:
242
+ - - ">="
243
+ - !ruby/object:Gem::Version
244
+ version: '0'
189
245
  description:
190
246
  email: why@ruby-lang.org
191
247
  executables:
@@ -237,20 +293,20 @@ files:
237
293
  - lib/camping/ar.rb
238
294
  - lib/camping/campguide.rb
239
295
  - lib/camping/commands.rb
240
- - lib/camping/gear/filters.rb
241
- - lib/camping/gear/firewatch.rb
242
- - lib/camping/gear/inspection.rb
243
- - lib/camping/gear/kuddly.rb
244
- - lib/camping/gear/nancy.rb
245
296
  - lib/camping/loader.rb
246
297
  - lib/camping/loads.rb
247
298
  - lib/camping/mab.rb
299
+ - lib/camping/sequel.rb
248
300
  - lib/camping/server.rb
249
301
  - lib/camping/session.rb
250
302
  - lib/camping/template.rb
251
303
  - lib/camping/tools.rb
252
304
  - lib/camping/version.rb
253
- - lib/campingtrip.md
305
+ - lib/gear/filters.rb
306
+ - lib/gear/firewatch.rb
307
+ - lib/gear/inspection.rb
308
+ - lib/gear/kuddly.rb
309
+ - lib/gear/nancy.rb
254
310
  - test/app_camping_gear.rb
255
311
  - test/app_camping_tools.rb
256
312
  - test/app_config.rb
@@ -291,8 +347,11 @@ files:
291
347
  - test/integration/Rakefile
292
348
  - test/integration/camp.rb
293
349
  - test/integration/config.kdl
350
+ - test/integration/kindling/starty.rb
294
351
  - test/integration/test/test_helper.rb
295
352
  - test/reload_reloader.rb
353
+ - test/server/helper.rb
354
+ - test/server/spec_server.rb
296
355
  - test/test_helper.rb
297
356
  homepage: http://rubycamping.org/
298
357
  licenses: