paradeiser 0.4.0 → 0.5.0

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