paradeiser 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Guardfile +16 -11
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/TODO.md +12 -1
- data/bin/par +5 -2
- data/lib/paradeiser.rb +22 -2
- data/lib/paradeiser/controllers/controller.rb +1 -0
- data/lib/paradeiser/controllers/paradeiser_controller.rb +0 -1
- data/lib/paradeiser/models/hook.rb +4 -0
- data/lib/paradeiser/models/repository.rb +1 -1
- data/lib/paradeiser/models/scheduled.rb +4 -0
- data/lib/paradeiser/version.rb +1 -1
- data/paradeiser.gemspec +1 -6
- data/templates/linux/hooks/after-finish-break +2 -0
- data/templates/linux/hooks/after-finish-pomodoro +2 -0
- data/templates/linux/hooks/after-start-break +2 -0
- data/templates/linux/hooks/after-start-pomodoro +2 -0
- data/templates/mac/hooks/after-finish-break +2 -0
- data/templates/mac/hooks/after-finish-pomodoro +2 -0
- data/templates/mac/hooks/after-start-break +2 -0
- data/templates/mac/hooks/after-start-pomodoro +2 -0
- data/test/helper.rb +14 -36
- data/test/integration/test_annotate.rb +15 -13
- data/test/integration/test_finish.rb +7 -5
- data/test/integration/test_interrupt.rb +7 -5
- data/test/integration/test_log.rb +9 -7
- data/test/integration/test_no_args.rb +5 -3
- data/test/integration/test_start.rb +5 -3
- data/test/integration/test_status.rb +8 -6
- data/test/integration/test_unknown.rb +5 -3
- data/test/lib/controller_test.rb +4 -2
- data/test/lib/integration_test.rb +8 -2
- data/test/lib/paradeiser_controller_test.rb +7 -1
- data/test/lib/token_file_registry.rb +19 -0
- data/test/lib/unit_test.rb +47 -0
- data/test/lib/view_test.rb +13 -8
- data/test/scripts/create-failing-hooks +17 -0
- data/test/scripts/fail +5 -0
- data/test/unit/test_break.rb +43 -40
- data/test/unit/test_break_view.rb +17 -14
- data/test/unit/test_breaks_controller.rb +55 -52
- data/test/unit/test_interrupt.rb +27 -24
- data/test/unit/test_paradeiser_controller_export.rb +103 -100
- data/test/unit/test_paradeiser_controller_init.rb +2 -2
- data/test/unit/test_paradeiser_controller_report.rb +72 -69
- data/test/unit/test_paradeiser_controller_status.rb +78 -75
- data/test/unit/test_paradeiser_view_init.rb +5 -3
- data/test/unit/test_paradeiser_view_report.rb +116 -114
- data/test/unit/test_paradeiser_view_status.rb +14 -11
- data/test/unit/test_pomodori_controller.rb +319 -316
- data/test/unit/test_pomodori_view.rb +40 -37
- data/test/unit/test_pomodoro.rb +116 -113
- data/test/unit/test_pomodoro_hooks.rb +172 -170
- data/test/unit/test_repository.rb +98 -95
- data/test/unit/test_scheduler.rb +39 -30
- data/test/unit/test_token_file_registry.rb +40 -0
- metadata +59 -49
@@ -1,88 +1,91 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module ParadeiserTest
|
4
|
+
class TestParadeiserControllerStatus < ParadeiserControllerTest
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
@backend = PStoreMock.new
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
def test_status_idle
|
11
|
+
attrs = invoke(:status, nil, nil, 'exitstatus', 'has_output')
|
12
|
+
assert_equal(-1, attrs[:exitstatus])
|
13
|
+
assert_equal(true, attrs[:has_output])
|
14
|
+
refute_empty(attrs[:stdout])
|
15
|
+
assert_empty(attrs[:stderr])
|
16
|
+
assert_equal(0, @backend.size)
|
17
|
+
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
def test_status_active_pom
|
20
|
+
@backend[:foo] = SchedulableMock.new(
|
21
|
+
:status => 'active',
|
22
|
+
:status_name => :active,
|
23
|
+
:active => true,
|
24
|
+
:name => 'pomodoro',
|
25
|
+
:remaining => 0,
|
26
|
+
:started_at => Time.now)
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
attrs = invoke(:status, nil, nil, '@pom', 'has_output', 'exitstatus')
|
29
|
+
assert_equal(0, attrs[:exitstatus])
|
30
|
+
assert_equal(:active, attrs[:pom].status_name)
|
31
|
+
assert_equal(true, attrs[:has_output])
|
32
|
+
refute_empty(attrs[:stdout])
|
33
|
+
assert_empty(attrs[:stderr])
|
34
|
+
assert_equal(1, @backend.size)
|
35
|
+
end
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
def test_status_finished_pom
|
38
|
+
@backend[:foo] = SchedulableMock.new(
|
39
|
+
:status => 'finished',
|
40
|
+
:status_name => :finished,
|
41
|
+
:finished => true,
|
42
|
+
:name => 'pomodoro',
|
43
|
+
:remaining => 0,
|
44
|
+
:finished_at => Time.now)
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
attrs = invoke(:status, nil, nil, '@pom', 'has_output', 'exitstatus')
|
47
|
+
assert_equal(1, attrs[:exitstatus])
|
48
|
+
assert_equal(:finished, attrs[:pom].status_name)
|
49
|
+
assert_equal(true, attrs[:has_output])
|
50
|
+
refute_empty(attrs[:stdout])
|
51
|
+
assert_empty(attrs[:stderr])
|
52
|
+
assert_equal(1, @backend.size)
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
def test_status_active_break
|
56
|
+
@backend[:foo] = SchedulableMock.new(
|
57
|
+
:status => 'active',
|
58
|
+
:status_name => :active,
|
59
|
+
:active => true,
|
60
|
+
:name => 'break',
|
61
|
+
:remaining => 0,
|
62
|
+
:started_at => Time.now)
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
attrs = invoke(:status, nil, nil, '@pom', 'has_output', 'exitstatus')
|
65
|
+
assert_equal(2, attrs[:exitstatus])
|
66
|
+
assert_equal(:active, attrs[:pom].status_name)
|
67
|
+
assert_equal(true, attrs[:has_output])
|
68
|
+
refute_empty(attrs[:stdout])
|
69
|
+
assert_empty(attrs[:stderr])
|
70
|
+
assert_equal(1, @backend.size)
|
71
|
+
end
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
73
|
+
def test_status_finished_break
|
74
|
+
@backend[:foo] = SchedulableMock.new(
|
75
|
+
:status => 'finished',
|
76
|
+
:status_name => :finished,
|
77
|
+
:finished => true,
|
78
|
+
:name => 'break',
|
79
|
+
:remaining => 0,
|
80
|
+
:finished_at => Time.now)
|
79
81
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
attrs = invoke(:status, nil, nil, '@pom', 'has_output', 'exitstatus')
|
83
|
+
assert_equal(3, attrs[:exitstatus])
|
84
|
+
assert_equal(:finished, attrs[:pom].status_name)
|
85
|
+
assert_equal(true, attrs[:has_output])
|
86
|
+
refute_empty(attrs[:stdout])
|
87
|
+
assert_empty(attrs[:stderr])
|
88
|
+
assert_equal(1, @backend.size)
|
89
|
+
end
|
87
90
|
end
|
88
91
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module ParadeiserTest
|
4
|
+
class TestParadeiserViewInit < ParadeiserViewTest
|
5
|
+
def test_init
|
6
|
+
assert_match(/^Successfully initialized .+\.$/, render(:init))
|
7
|
+
end
|
6
8
|
end
|
7
9
|
end
|
@@ -1,132 +1,134 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module ParadeiserTest
|
4
|
+
class TestParadeiserViewReport < ParadeiserViewTest
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
@annotations = []
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def test_report_0
|
11
|
+
out = render(:report)
|
12
|
+
assert(out)
|
13
|
+
lines = out.lines
|
14
|
+
assert_equal(6, lines.size)
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
i = 0
|
17
|
+
assert_equal('# Pomodoro Report', lines[i].chomp)
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
i += 1
|
20
|
+
assert_match(/^- \d pomodori finished$/, lines[i].chomp)
|
21
|
+
assert_equal('0', lines[i][2])
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
i += 1
|
24
|
+
assert_match(/^- \d pomodori canceled$/, lines[i].chomp)
|
25
|
+
assert_equal('0', lines[i][2])
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
i += 1
|
28
|
+
assert_match(/^- \d internal interrupts$/, lines[i].chomp)
|
29
|
+
assert_equal('0', lines[i][2])
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
i += 1
|
32
|
+
assert_match(/^- \d external interrupts$/, lines[i].chomp)
|
33
|
+
assert_equal('0', lines[i][2])
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
i += 1
|
36
|
+
assert_match(/^- \d breaks \(\d minutes in total\)$/, lines[i].chomp)
|
37
|
+
assert_equal('0', lines[i][2])
|
38
|
+
assert_equal('0', lines[i][12])
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
41
|
+
def test_report_1
|
42
|
+
@finished = 1
|
43
|
+
@canceled = 1
|
44
|
+
@external_interrupts = 1
|
45
|
+
@internal_interrupts = 1
|
46
|
+
@breaks = 1
|
47
|
+
@break_minutes = 1
|
48
|
+
|
49
|
+
out = render(:report)
|
50
|
+
assert(out)
|
51
|
+
lines = out.lines
|
52
|
+
assert_equal(6, lines.size)
|
53
|
+
|
54
|
+
i = 0
|
55
|
+
assert_equal('# Pomodoro Report', lines[i].chomp)
|
56
|
+
|
57
|
+
i += 1
|
58
|
+
assert_match(/^- \d pomodoro finished$/, lines[i].chomp)
|
59
|
+
assert_equal('1', lines[i][2])
|
60
|
+
|
61
|
+
i += 1
|
62
|
+
assert_match(/^- \d pomodoro canceled$/, lines[i].chomp)
|
63
|
+
assert_equal('1', lines[i][2])
|
64
|
+
|
65
|
+
i += 1
|
66
|
+
assert_match(/^- \d internal interrupt$/, lines[i].chomp)
|
67
|
+
assert_equal('1', lines[i][2])
|
68
|
+
|
69
|
+
i += 1
|
70
|
+
assert_match(/^- \d external interrupt$/, lines[i].chomp)
|
71
|
+
assert_equal('1', lines[i][2])
|
72
|
+
|
73
|
+
i += 1
|
74
|
+
assert_match(/^- \d break \(\d minute in total\)$/, lines[i].chomp)
|
75
|
+
assert_equal('1', lines[i][2])
|
76
|
+
assert_equal('1', lines[i][11])
|
77
|
+
end
|
77
78
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
79
|
+
def test_report_2
|
80
|
+
@finished = 2
|
81
|
+
@canceled = 2
|
82
|
+
@external_interrupts = 2
|
83
|
+
@internal_interrupts = 2
|
84
|
+
@breaks = 2
|
85
|
+
@break_minutes = 2
|
86
|
+
|
87
|
+
out = render(:report)
|
88
|
+
assert(out)
|
89
|
+
lines = out.lines
|
90
|
+
assert_equal(6, lines.size)
|
91
|
+
|
92
|
+
i = 0
|
93
|
+
assert_equal('# Pomodoro Report', lines[i].chomp)
|
94
|
+
|
95
|
+
i += 1
|
96
|
+
assert_match(/^- \d pomodori finished$/, lines[i].chomp)
|
97
|
+
assert_equal('2', lines[i][2])
|
98
|
+
|
99
|
+
i += 1
|
100
|
+
assert_match(/^- \d pomodori canceled$/, lines[i].chomp)
|
101
|
+
assert_equal('2', lines[i][2])
|
102
|
+
|
103
|
+
i += 1
|
104
|
+
assert_match(/^- \d internal interrupts$/, lines[i].chomp)
|
105
|
+
assert_equal('2', lines[i][2])
|
106
|
+
|
107
|
+
i += 1
|
108
|
+
assert_match(/^- \d external interrupts$/, lines[i].chomp)
|
109
|
+
assert_equal('2', lines[i][2])
|
110
|
+
|
111
|
+
i += 1
|
112
|
+
assert_match(/^- \d breaks \(\d minutes in total\)$/, lines[i].chomp)
|
113
|
+
assert_equal('2', lines[i][2])
|
114
|
+
assert_equal('2', lines[i][12])
|
115
|
+
end
|
115
116
|
|
116
|
-
|
117
|
-
|
117
|
+
def test_report_annotations
|
118
|
+
@annotations = ['seven eleven', 'fourty two', 'something real']
|
118
119
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
120
|
+
out = render(:report)
|
121
|
+
assert(out)
|
122
|
+
lines = out.lines
|
123
|
+
assert_equal(11, lines.size)
|
123
124
|
|
124
|
-
|
125
|
-
|
125
|
+
i = 7
|
126
|
+
assert_equal('## Annotations', lines[i].chomp)
|
126
127
|
|
127
|
-
|
128
|
-
|
129
|
-
|
128
|
+
i += 1
|
129
|
+
@annotations.each_with_index do |annotation, ai|
|
130
|
+
assert_equal("* #{annotation}", lines[i + ai].chomp)
|
131
|
+
end
|
130
132
|
end
|
131
133
|
end
|
132
134
|
end
|
@@ -1,17 +1,20 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module ParadeiserTest
|
4
|
+
class TestParadeiserViewStatus < ParadeiserViewTest
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
@pom = produce(Pomodoro)
|
8
|
+
@pom.id = 1
|
9
|
+
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
def test_active
|
12
|
+
assert_match(/^Pomodoro #1 is active for another .* minutes \(started at .*\)\.$/m, render(:status))
|
13
|
+
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
def test_finished
|
16
|
+
finish!
|
17
|
+
assert_match(/^Nothing active. Last pomodoro was finished at .*\.$/m, render(:status))
|
18
|
+
end
|
16
19
|
end
|
17
20
|
end
|