markdo 0.1.12.alpha → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +15 -9
- data/Dockerfile +21 -7
- data/Guardfile +11 -0
- data/README.md +12 -7
- data/Rakefile +11 -7
- data/bin/markdo +1 -1
- data/docker-compose.yml +9 -0
- data/lib/markdo/cli.rb +23 -55
- data/lib/markdo/command_support.rb +14 -0
- data/lib/markdo/commands.rb +16 -0
- data/lib/markdo/{add_command.rb → commands/add_command.rb} +2 -6
- data/lib/markdo/commands/command.rb +33 -0
- data/lib/markdo/{edit_command.rb → commands/edit_command.rb} +2 -2
- data/lib/markdo/commands/forecast_command.rb +41 -0
- data/lib/markdo/{help_command.rb → commands/help_command.rb} +7 -8
- data/lib/markdo/commands/ics_command.rb +15 -0
- data/lib/markdo/commands/inbox_command.rb +11 -0
- data/lib/markdo/commands/overdue_command.rb +11 -0
- data/lib/markdo/commands/overview_command.rb +16 -0
- data/lib/markdo/commands/process_command.rb +91 -0
- data/lib/markdo/commands/query_command.rb +14 -0
- data/lib/markdo/commands/star_command.rb +11 -0
- data/lib/markdo/commands/summary_command.rb +25 -0
- data/lib/markdo/commands/tag_command.rb +11 -0
- data/lib/markdo/commands/today_command.rb +12 -0
- data/lib/markdo/commands/tomorrow_command.rb +12 -0
- data/lib/markdo/{version_command.rb → commands/version_command.rb} +1 -1
- data/lib/markdo/commands/week_command.rb +16 -0
- data/lib/markdo/data_source.rb +27 -0
- data/lib/markdo/ics_exporter.rb +65 -0
- data/lib/markdo/models/task.rb +46 -0
- data/lib/markdo/models/task_attribute.rb +22 -0
- data/lib/markdo/models/task_collection.rb +75 -0
- data/lib/markdo/version.rb +1 -1
- data/markdo.gemspec +6 -0
- data/script/build +9 -0
- data/spec/fixtures/add_command/Inbox.md +0 -0
- data/spec/fixtures/date_commands/Inbox.md +6 -0
- data/spec/fixtures/date_commands/Sprint.md +6 -0
- data/spec/fixtures/ics_command/Inbox.md +0 -0
- data/{test/fixtures/ics_command.md → spec/fixtures/ics_command/Sprint.md} +0 -0
- data/spec/fixtures/inbox_command/Inbox.md +2 -0
- data/spec/fixtures/inbox_command/Sprint.md +2 -0
- data/spec/fixtures/process_command/Backlog.md +0 -0
- data/spec/fixtures/process_command/Inbox.md +0 -0
- data/spec/fixtures/process_command/Maybe.md +0 -0
- data/spec/fixtures/process_command/Sprint.md +0 -0
- data/spec/fixtures/query_command/Inbox.md +4 -0
- data/spec/fixtures/query_command/Sprint.md +4 -0
- data/spec/fixtures/tag_command/Inbox.md +2 -0
- data/spec/fixtures/tag_command/Sprint.md +2 -0
- data/spec/lib/cli_spec.rb +79 -0
- data/spec/lib/commands/add_command_spec.rb +70 -0
- data/spec/lib/commands/edit_command_spec.rb +32 -0
- data/spec/lib/commands/forecast_command_spec.rb +24 -0
- data/spec/lib/commands/ics_command_spec.rb +30 -0
- data/spec/lib/commands/inbox_command_spec.rb +22 -0
- data/spec/lib/commands/overdue_command_spec.rb +19 -0
- data/spec/lib/commands/overview_command_spec.rb +25 -0
- data/spec/lib/commands/process_command_spec.rb +178 -0
- data/spec/lib/commands/query_command_spec.rb +23 -0
- data/spec/lib/commands/star_command_spec.rb +19 -0
- data/spec/lib/commands/summary_command_spec.rb +23 -0
- data/spec/lib/commands/tag_command_spec.rb +21 -0
- data/spec/lib/commands/today_command_spec.rb +19 -0
- data/spec/lib/commands/tomorrow_command_spec.rb +19 -0
- data/spec/lib/commands/week_command_spec.rb +23 -0
- data/spec/lib/ics_exporter_spec.rb +59 -0
- data/spec/lib/models/task_attribute_spec.rb +85 -0
- data/spec/lib/models/task_collection_spec.rb +168 -0
- data/spec/lib/models/task_spec.rb +79 -0
- data/spec/spec_helper.rb +40 -0
- metadata +189 -42
- data/.ruby-version +0 -1
- data/lib/markdo/command.rb +0 -12
- data/lib/markdo/date_command.rb +0 -9
- data/lib/markdo/forecast_command.rb +0 -61
- data/lib/markdo/ics_command.rb +0 -73
- data/lib/markdo/inbox_command.rb +0 -15
- data/lib/markdo/overdue_command.rb +0 -47
- data/lib/markdo/overview_command.rb +0 -17
- data/lib/markdo/process_command.rb +0 -68
- data/lib/markdo/query_command.rb +0 -24
- data/lib/markdo/rss_command.rb +0 -67
- data/lib/markdo/star_command.rb +0 -9
- data/lib/markdo/summary_command.rb +0 -30
- data/lib/markdo/tag_command.rb +0 -9
- data/lib/markdo/today_command.rb +0 -10
- data/lib/markdo/tomorrow_command.rb +0 -10
- data/lib/markdo/week_command.rb +0 -36
- data/test/fixtures/inbox.md +0 -2
- data/test/fixtures/rss_command.md +0 -4
- data/test/ics_command_test.rb +0 -38
- data/test/inbox_command_test.rb +0 -19
- data/test/rss_command_test.rb +0 -39
- data/test/summary_command_test.rb +0 -19
- data/test/test_helper.rb +0 -3
data/lib/markdo/version.rb
CHANGED
data/markdo.gemspec
CHANGED
@@ -21,4 +21,10 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "minitest"
|
23
23
|
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "simplecov"
|
26
|
+
spec.add_development_dependency "guard"
|
27
|
+
spec.add_development_dependency "guard-rake"
|
28
|
+
spec.add_development_dependency "opal"
|
29
|
+
spec.add_development_dependency "opal-rspec"
|
24
30
|
end
|
data/script/build
ADDED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'markdo/cli'
|
3
|
+
|
4
|
+
module Markdo
|
5
|
+
describe CLI do
|
6
|
+
describe 'given "version"' do
|
7
|
+
it 'prints the version' do
|
8
|
+
command_support = build_command_support
|
9
|
+
|
10
|
+
CLI.new(command_support).run('version')
|
11
|
+
|
12
|
+
assert_version_printed command_support.stdout
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'given "--version"' do
|
17
|
+
it 'prints the version' do
|
18
|
+
command_support = build_command_support
|
19
|
+
|
20
|
+
CLI.new(command_support).run('--version')
|
21
|
+
|
22
|
+
assert_version_printed command_support.stdout
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'given "--help"' do
|
27
|
+
it 'prints help text' do
|
28
|
+
command_support = build_command_support
|
29
|
+
expect(Kernel).to receive(:exit).with(1)
|
30
|
+
|
31
|
+
CLI.new(command_support).run('--help')
|
32
|
+
|
33
|
+
assert_help_printed command_support.stderr
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'given "starred"' do
|
38
|
+
it 'delegates to StarCommand' do
|
39
|
+
command_support = build_command_support
|
40
|
+
expect(StarCommand).to receive(:new).and_return(FakeCommand.new)
|
41
|
+
|
42
|
+
CLI.new(command_support).run('starred')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'given "q"' do
|
47
|
+
it 'delegates to StarCommand' do
|
48
|
+
command_support = build_command_support
|
49
|
+
expect(QueryCommand).to receive(:new).and_return(FakeCommand.new)
|
50
|
+
|
51
|
+
CLI.new(command_support).run('q')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'given an unknown command' do
|
56
|
+
it 'defaults to help text' do
|
57
|
+
command_support = build_command_support
|
58
|
+
expect(Kernel).to receive(:exit).with(1)
|
59
|
+
|
60
|
+
CLI.new(command_support).run('asdf')
|
61
|
+
|
62
|
+
assert_help_printed command_support.stderr
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def assert_version_printed(io)
|
67
|
+
expect(io.string).to match(/v[0-9.]+[a-z0-9]+\n/)
|
68
|
+
end
|
69
|
+
|
70
|
+
def assert_help_printed(io)
|
71
|
+
expect(io.string).to match(/^Markdown-based task manager\./)
|
72
|
+
end
|
73
|
+
|
74
|
+
class FakeCommand
|
75
|
+
def run
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'markdo/commands/add_command'
|
3
|
+
|
4
|
+
module Markdo
|
5
|
+
describe AddCommand do
|
6
|
+
before do
|
7
|
+
skip 'Could not access fixtures' unless File.exists?('spec/fixtures/')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'appends to the inbox' do
|
11
|
+
clear_inbox
|
12
|
+
markdo_add 'Example task'
|
13
|
+
expect(read_inbox).to eq([
|
14
|
+
'- [ ] Example task',
|
15
|
+
])
|
16
|
+
markdo_add 'Another example task'
|
17
|
+
expect(read_inbox).to eq([
|
18
|
+
'- [ ] Example task',
|
19
|
+
'- [ ] Another example task',
|
20
|
+
])
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'given a nil' do
|
24
|
+
it 'appends to the inbox' do
|
25
|
+
clear_inbox
|
26
|
+
markdo_add nil
|
27
|
+
assert_inbox_empty
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'given an empty string' do
|
32
|
+
it 'appends to the inbox' do
|
33
|
+
clear_inbox
|
34
|
+
markdo_add ''
|
35
|
+
assert_inbox_empty
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'given a blank string' do
|
40
|
+
it 'appends to the inbox' do
|
41
|
+
clear_inbox
|
42
|
+
markdo_add ' '
|
43
|
+
assert_inbox_empty
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def clear_inbox
|
48
|
+
File.write('spec/fixtures/add_command/Inbox.md', '')
|
49
|
+
end
|
50
|
+
|
51
|
+
def read_inbox
|
52
|
+
File.
|
53
|
+
readlines('spec/fixtures/add_command/Inbox.md').
|
54
|
+
map { |line| line.chomp }
|
55
|
+
end
|
56
|
+
|
57
|
+
def markdo_add(task_body)
|
58
|
+
command_support = build_command_support({
|
59
|
+
'MARKDO_ROOT' => 'spec/fixtures/add_command',
|
60
|
+
'MARKDO_INBOX' => 'Inbox.md',
|
61
|
+
})
|
62
|
+
|
63
|
+
AddCommand.new(command_support).run(task_body)
|
64
|
+
end
|
65
|
+
|
66
|
+
def assert_inbox_empty
|
67
|
+
expect(read_inbox).to be_empty
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'markdo/commands/inbox_command'
|
3
|
+
|
4
|
+
module Markdo
|
5
|
+
describe EditCommand do
|
6
|
+
it 'edits the Markdo root in your preferred editor' do
|
7
|
+
skip 'Shellwords not supported' unless defined?(Shellwords)
|
8
|
+
|
9
|
+
command_support = build_command_support({
|
10
|
+
'EDITOR' => 'aneditor',
|
11
|
+
'MARKDO_ROOT' => 'spec/fixtures/'
|
12
|
+
})
|
13
|
+
|
14
|
+
expect(Kernel).to receive(:system).with('aneditor spec/fixtures/')
|
15
|
+
|
16
|
+
EditCommand.new(command_support).run
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'does not allow unsafe values for MARKDO_ROOT' do
|
20
|
+
skip 'Shellwords not supported' unless defined?(Shellwords)
|
21
|
+
|
22
|
+
command_support = build_command_support({
|
23
|
+
'EDITOR' => 'aneditor',
|
24
|
+
'MARKDO_ROOT' => '`ruin everything`'
|
25
|
+
})
|
26
|
+
|
27
|
+
expect(Kernel).to receive(:system).with('aneditor \`ruin\ everything\`')
|
28
|
+
|
29
|
+
EditCommand.new(command_support).run
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'markdo/commands/forecast_command'
|
3
|
+
|
4
|
+
module Markdo
|
5
|
+
describe ForecastCommand do
|
6
|
+
it 'outputs forecast counts' do
|
7
|
+
skip 'Dir.glob not supported' unless Dir.respond_to?(:glob)
|
8
|
+
|
9
|
+
command_support = build_command_support_for_date_commands
|
10
|
+
|
11
|
+
ForecastCommand.new(command_support).run
|
12
|
+
|
13
|
+
expect(command_support.stdout.string).to eq(<<-XML)
|
14
|
+
Tu: 0
|
15
|
+
We: 0
|
16
|
+
Th: 0
|
17
|
+
Fr: 0
|
18
|
+
Sa: 0
|
19
|
+
Su: 2
|
20
|
+
Next: 4
|
21
|
+
XML
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'markdo/commands/ics_command'
|
3
|
+
|
4
|
+
module Markdo
|
5
|
+
describe IcsCommand do
|
6
|
+
it 'outputs an iCalendar feed from the input Markdown, skipping invalid dates' do
|
7
|
+
skip 'Dir.glob not supported' unless Dir.respond_to?(:glob)
|
8
|
+
|
9
|
+
command_support = build_command_support({
|
10
|
+
'MARKDO_ROOT' => 'spec/fixtures/ics_command'
|
11
|
+
})
|
12
|
+
|
13
|
+
IcsCommand.new(command_support).run
|
14
|
+
|
15
|
+
expect(command_support.stdout.string).to eq(<<-ICS)
|
16
|
+
BEGIN:VCALENDAR
|
17
|
+
VERSION:2.0
|
18
|
+
CALSCALE:GREGORIAN
|
19
|
+
METHOD:PUBLISH
|
20
|
+
X-WR-CALNAME:Markdo Due Dates
|
21
|
+
BEGIN:VEVENT
|
22
|
+
DTSTART;VALUE=DATE:20160401
|
23
|
+
DTEND;VALUE=DATE:20160401
|
24
|
+
SUMMARY:Task with tag-style due date
|
25
|
+
END:VEVENT
|
26
|
+
END:VCALENDAR
|
27
|
+
ICS
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'markdo/commands/inbox_command'
|
3
|
+
|
4
|
+
module Markdo
|
5
|
+
describe InboxCommand do
|
6
|
+
it 'outputs inbox' do
|
7
|
+
skip 'File.readlines not supported' unless File.respond_to?(:readlines)
|
8
|
+
|
9
|
+
command_support = build_command_support({
|
10
|
+
'MARKDO_ROOT' => 'spec/fixtures/inbox_command',
|
11
|
+
'MARKDO_INBOX' => 'Inbox.md'
|
12
|
+
})
|
13
|
+
|
14
|
+
InboxCommand.new(command_support).run
|
15
|
+
|
16
|
+
expect(command_support.stdout.string).to eq(<<-XML)
|
17
|
+
- [ ] Example 1 in inbox
|
18
|
+
- [ ] Example 2 in inbox
|
19
|
+
XML
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'markdo/commands/overdue_command'
|
3
|
+
|
4
|
+
module Markdo
|
5
|
+
describe OverdueCommand do
|
6
|
+
it 'outputs overdue tasks' do
|
7
|
+
skip 'Dir.glob not supported' unless Dir.respond_to?(:glob)
|
8
|
+
|
9
|
+
command_support = build_command_support_for_date_commands
|
10
|
+
|
11
|
+
OverdueCommand.new(command_support).run
|
12
|
+
|
13
|
+
expect(command_support.stdout.string).to eq(<<-EOF)
|
14
|
+
- [ ] @due(2016-01-01) Overdue in inbox
|
15
|
+
- [ ] @due(2016-01-01) Overdue
|
16
|
+
EOF
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'markdo/commands/overview_command'
|
3
|
+
|
4
|
+
module Markdo
|
5
|
+
describe OverviewCommand do
|
6
|
+
it 'outputs tasks overdue, starred, due today, and due tomorrow' do
|
7
|
+
skip 'Dir.glob not supported' unless Dir.respond_to?(:glob)
|
8
|
+
|
9
|
+
command_support = build_command_support_for_date_commands
|
10
|
+
|
11
|
+
OverviewCommand.new(command_support).run
|
12
|
+
|
13
|
+
expect(command_support.stdout.string).to eq(<<-EOF)
|
14
|
+
- [ ] @due(2016-01-01) Overdue in inbox
|
15
|
+
- [ ] @due(2016-01-01) Overdue
|
16
|
+
- [ ] @star Starred in inbox
|
17
|
+
- [ ] @star Starred
|
18
|
+
- [ ] @due(2016-02-28) Due today in inbox
|
19
|
+
- [ ] @due(2016-02-28) Due today
|
20
|
+
- [ ] @due(2016-02-29) Due tomorrow in inbox
|
21
|
+
- [ ] @due(2016-02-29) Due tomorrow
|
22
|
+
EOF
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'markdo/commands/process_command'
|
3
|
+
|
4
|
+
module Markdo
|
5
|
+
describe ProcessCommand do
|
6
|
+
before do
|
7
|
+
skip 'Could not access fixtures' unless File.exists?('spec/fixtures/')
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
clear_all
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'given the "h" subcommand' do
|
15
|
+
it 'prints help to stdout and makes no changes' do
|
16
|
+
original_content = ['- [ ] Example']
|
17
|
+
write_inbox(original_content)
|
18
|
+
|
19
|
+
stdout = markdo_process(%w(h h))
|
20
|
+
|
21
|
+
expect(stdout.string).to eq(<<-EOF)
|
22
|
+
- [ ] Example
|
23
|
+
File [hisbma]?
|
24
|
+
i - inbox (keep in inbox)
|
25
|
+
s - sprint
|
26
|
+
b - backlog
|
27
|
+
m - maybe
|
28
|
+
a - abort; make no changes
|
29
|
+
- [ ] Example
|
30
|
+
File [hisbma]?
|
31
|
+
i - inbox (keep in inbox)
|
32
|
+
s - sprint
|
33
|
+
b - backlog
|
34
|
+
m - maybe
|
35
|
+
a - abort; make no changes
|
36
|
+
- [ ] Example
|
37
|
+
File [hisbma]?
|
38
|
+
EOF
|
39
|
+
|
40
|
+
expect(read_lines('Inbox')).to eq(original_content)
|
41
|
+
expect(read_lines('Sprint')).to eq([])
|
42
|
+
expect(read_lines('Backlog')).to eq([])
|
43
|
+
expect(read_lines('Maybe')).to eq([])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'given the "i" subcommand' do
|
48
|
+
it 'keeps the task in the inbox' do
|
49
|
+
original_content = ['- [ ] Example']
|
50
|
+
write_inbox(original_content)
|
51
|
+
|
52
|
+
stdout = markdo_process(%w(i))
|
53
|
+
|
54
|
+
assert_prompt_shown(stdout)
|
55
|
+
expect(read_lines('Inbox')).to eq(original_content)
|
56
|
+
expect(read_lines('Sprint')).to eq([])
|
57
|
+
expect(read_lines('Backlog')).to eq([])
|
58
|
+
expect(read_lines('Maybe')).to eq([])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'given the "a" subcommand' do
|
63
|
+
it 'makes no changes' do
|
64
|
+
original_content = ['- [ ] Example']
|
65
|
+
write_inbox(original_content)
|
66
|
+
|
67
|
+
stdout = markdo_process(%w(a))
|
68
|
+
|
69
|
+
assert_prompt_shown(stdout)
|
70
|
+
expect(read_lines('Inbox')).to eq(original_content)
|
71
|
+
expect(read_lines('Sprint')).to eq([])
|
72
|
+
expect(read_lines('Backlog')).to eq([])
|
73
|
+
expect(read_lines('Maybe')).to eq([])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'given the "s" subcommand' do
|
78
|
+
it 'moves the line to "Sprint.md"' do
|
79
|
+
write_inbox(['- [ ] Example'])
|
80
|
+
|
81
|
+
stdout = markdo_process(%w(s))
|
82
|
+
|
83
|
+
assert_prompt_shown(stdout)
|
84
|
+
expect(read_lines('Inbox')).to eq([])
|
85
|
+
expect(read_lines('Sprint')).to eq([
|
86
|
+
'',
|
87
|
+
'## Processed on 2016-06-01',
|
88
|
+
'',
|
89
|
+
'- [ ] Example'
|
90
|
+
])
|
91
|
+
expect(read_lines('Backlog')).to eq([])
|
92
|
+
expect(read_lines('Maybe')).to eq([])
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe 'given the "b" subcommand' do
|
97
|
+
it 'moves the line to "Backlog.md"' do
|
98
|
+
write_inbox(['- [ ] Example'])
|
99
|
+
|
100
|
+
stdout = markdo_process(%w(b))
|
101
|
+
|
102
|
+
assert_prompt_shown(stdout)
|
103
|
+
expect(read_lines('Inbox')).to eq([])
|
104
|
+
expect(read_lines('Sprint')).to eq([])
|
105
|
+
expect(read_lines('Backlog')).to eq([
|
106
|
+
'',
|
107
|
+
'## Processed on 2016-06-01',
|
108
|
+
'',
|
109
|
+
'- [ ] Example'
|
110
|
+
])
|
111
|
+
expect(read_lines('Maybe')).to eq([])
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe 'given the "m" subcommand' do
|
116
|
+
it 'moves the line to "Maybe.md"' do
|
117
|
+
write_inbox(['- [ ] Example'])
|
118
|
+
|
119
|
+
stdout = markdo_process(%w(m))
|
120
|
+
|
121
|
+
assert_prompt_shown(stdout)
|
122
|
+
expect(read_lines('Inbox')).to eq([])
|
123
|
+
expect(read_lines('Sprint')).to eq([])
|
124
|
+
expect(read_lines('Backlog')).to eq([])
|
125
|
+
expect(read_lines('Maybe')).to eq([
|
126
|
+
'',
|
127
|
+
'## Processed on 2016-06-01',
|
128
|
+
'',
|
129
|
+
'- [ ] Example'
|
130
|
+
])
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def clear_all
|
135
|
+
%w(Backlog Inbox Maybe Sprint).each do |filename|
|
136
|
+
File.write("spec/fixtures/process_command/#{filename}.md", '')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def write_inbox(content)
|
141
|
+
File.write('spec/fixtures/process_command/Inbox.md', content.join("\n"))
|
142
|
+
end
|
143
|
+
|
144
|
+
def markdo_process(subcommands)
|
145
|
+
raw_input = subcommands.map { |s| "#{s}\n" }.join
|
146
|
+
stdin = StringIO.new(raw_input)
|
147
|
+
stdout = StringIO.new
|
148
|
+
stderr = StringIO.new
|
149
|
+
today = Date.new(2016, 6, 1)
|
150
|
+
env = {
|
151
|
+
'MARKDO_ROOT' => 'spec/fixtures/process_command',
|
152
|
+
'MARKDO_INBOX' => 'Inbox.md',
|
153
|
+
}
|
154
|
+
command_support = CommandSupport.new(stdin: stdin,
|
155
|
+
stdout: stdout,
|
156
|
+
stderr: stderr,
|
157
|
+
today: today,
|
158
|
+
env: env)
|
159
|
+
|
160
|
+
ProcessCommand.new(command_support).run
|
161
|
+
|
162
|
+
command_support.stdout
|
163
|
+
end
|
164
|
+
|
165
|
+
def read_lines(filename)
|
166
|
+
File.
|
167
|
+
readlines("spec/fixtures/process_command/#{filename}.md").
|
168
|
+
map { |line| line.chomp }
|
169
|
+
end
|
170
|
+
|
171
|
+
def assert_prompt_shown(io)
|
172
|
+
expect(io.string).to eq(<<-EOF)
|
173
|
+
- [ ] Example
|
174
|
+
File [hisbma]?
|
175
|
+
EOF
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|