camping 3.0.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/app_reloader.rb DELETED
@@ -1,69 +0,0 @@
1
- require 'test_helper'
2
- require 'fileutils'
3
- require 'camping/reloader'
4
-
5
- $counter = 0
6
-
7
- module TestCaseReloader
8
- def reloader
9
- @reloader ||= Camping::Reloader.new(file)
10
- end
11
-
12
- def setup
13
- super
14
- reloader.reload!
15
- assert Object.const_defined?(:Reloader), "Reloader didn't load app"
16
- end
17
-
18
- def teardown
19
- super
20
- assert Object.const_defined?(:Reloader), "Test removed app"
21
- reloader.remove_apps
22
- assert !Object.const_defined?(:Reloader), "Reloader didn't remove app"
23
- end
24
- end
25
-
26
- class TestReloader < TestCase
27
- include TestCaseReloader
28
- BASE = File.expand_path('../apps/reloader', __FILE__)
29
-
30
- def file; BASE + '.rb' end
31
-
32
- def setup
33
- $counter = 0
34
- super
35
- end
36
-
37
- def test_counter
38
- assert_equal 1, $counter
39
- end
40
-
41
- def test_forced_reload
42
- reloader.reload!
43
- assert_equal 2, $counter
44
- end
45
-
46
- def test_mtime_reload
47
- reloader.reload
48
- assert_equal 1, $counter
49
-
50
- FileUtils.touch(BASE + '.rb')
51
- sleep 1
52
- reloader.reload
53
- assert_equal 2, $counter
54
-
55
- FileUtils.touch(BASE + '/reload_me.rb')
56
- sleep 1
57
- reloader.reload
58
- assert_equal 3, $counter
59
- end
60
- end
61
-
62
- class TestConfigRu < TestReloader
63
- BASE = File.expand_path('../apps/reloader', __FILE__)
64
- def file; BASE + '/config.ru' end
65
-
66
- def test_name
67
- assert_equal Reloader, reloader.apps[:reloader]
68
- end
69
- end