todotxt 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +2 -0
- data/README.md +40 -18
- data/Rakefile +1 -4
- data/bin/todotxt +5 -5
- data/features/edit.feature +1 -1
- data/features/files.feature +53 -0
- data/features/initialize.feature +0 -11
- data/features/move.feature +13 -0
- data/features/step_definitions/environment_steps.rb +8 -4
- data/features/step_definitions/list_steps.rb +5 -1
- data/lib/todotxt.rb +9 -8
- data/lib/todotxt/cli.rb +96 -142
- data/lib/todotxt/clihelpers.rb +21 -24
- data/lib/todotxt/config.rb +45 -16
- data/lib/todotxt/regex.rb +5 -5
- data/lib/todotxt/todo.rb +44 -30
- data/lib/todotxt/todofile.rb +11 -11
- data/lib/todotxt/todolist.rb +31 -19
- data/lib/todotxt/version.rb +1 -1
- data/spec/config_spec.rb +41 -21
- data/spec/fixtures/config_no_todo.cfg +2 -0
- data/spec/todo_spec.rb +77 -90
- data/spec/todofile_spec.rb +17 -12
- data/spec/todolist_spec.rb +65 -66
- data/todotxt.gemspec +19 -21
- metadata +50 -61
data/lib/todotxt/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -1,52 +1,72 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'todotxt/config'
|
3
3
|
|
4
4
|
describe Todotxt::Config do
|
5
5
|
before(:each) do
|
6
|
-
ENV[
|
7
|
-
@config_file = File.join ENV[
|
6
|
+
ENV['HOME'] = File.join '/', 'tmp'
|
7
|
+
@config_file = File.join ENV['HOME'], '.todotxt.cfg'
|
8
8
|
end
|
9
9
|
|
10
|
-
context
|
10
|
+
context 'valid config' do
|
11
11
|
before(:each) do
|
12
|
-
@cfg = Todotxt::Config.new
|
12
|
+
@cfg = Todotxt::Config.new(config_file: 'spec/fixtures/config_new.cfg')
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should have a "files"' do
|
16
|
-
@cfg.files.keys.
|
16
|
+
expect(@cfg.files.keys).to include('todo')
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should not be deprecated' do
|
20
|
-
@cfg.
|
20
|
+
expect(@cfg).not_to be_deprecated
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#files' do
|
24
|
+
it 'should return a list of TodoFile objects as configured in config' do
|
25
|
+
expect(@cfg.files).to be_kind_of(Hash)
|
26
|
+
expect(@cfg.files).to match('todo' => Todotxt::TodoFile.new('/tmp/todo.txt'))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
describe '#file' do
|
30
|
+
it "should return the 'todo' file from the 'files' hash" do
|
31
|
+
expect(@cfg.file).to match(@cfg.files['todo'])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'invalid config' do
|
37
|
+
it 'not allow both "files" and "todo_txt_path"' do
|
38
|
+
expect do
|
39
|
+
Todotxt::Config.new(config_file: 'spec/fixtures/config_both.cfg')
|
40
|
+
end.to raise_error 'Bad configuration file: use either files or todo_txt_path'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should complain when there is no "todo" in files and no file is requested' do
|
44
|
+
expect do
|
45
|
+
Todotxt::Config.new(config_file: 'spec/fixtures/config_no_todo.cfg').file
|
46
|
+
end.to raise_error "Bad configuration file: 'todo' is a required file."
|
21
47
|
end
|
22
48
|
end
|
23
49
|
|
24
|
-
context
|
50
|
+
context 'old style config' do
|
25
51
|
before(:each) do
|
26
|
-
@cfg = Todotxt::Config.new
|
52
|
+
@cfg = Todotxt::Config.new(config_file: 'spec/fixtures/config_old.cfg')
|
27
53
|
end
|
28
54
|
|
29
55
|
it 'should place "todo_txt_path" under files' do
|
30
|
-
@cfg.files.keys.
|
56
|
+
expect(@cfg.files.keys).to include('todo')
|
31
57
|
end
|
32
58
|
|
33
59
|
it 'should be deprecated' do
|
34
|
-
@cfg.
|
60
|
+
expect(@cfg).to be_deprecated
|
35
61
|
end
|
36
62
|
end
|
37
63
|
|
38
|
-
|
39
|
-
expect do
|
40
|
-
Todotxt::Config.new "spec/fixtures/config_both.cfg"
|
41
|
-
end.to raise_error "Bad configuration file: use either files or todo_txt_path"
|
42
|
-
end
|
43
|
-
|
44
|
-
context "#generate!" do
|
64
|
+
context '#generate!' do
|
45
65
|
it 'should create a template' do
|
46
|
-
File.delete @config_file if File.
|
66
|
+
File.delete @config_file if File.exist? @config_file
|
47
67
|
todo = Todotxt::Config.new
|
48
68
|
todo.generate!
|
49
|
-
File.
|
69
|
+
expect(File.exist?(@config_file)).to be_truthy
|
50
70
|
end
|
51
71
|
end
|
52
72
|
end
|
data/spec/todo_spec.rb
CHANGED
@@ -1,141 +1,128 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'todotxt/todo'
|
3
3
|
|
4
4
|
describe Todotxt::Todo do
|
5
|
-
|
6
|
-
|
7
|
-
todo
|
8
|
-
todo.to_s.should eql("an item")
|
5
|
+
it 'creates a todo item string' do
|
6
|
+
todo = Todotxt::Todo.new 'an item'
|
7
|
+
expect(todo.to_s).to match('an item')
|
9
8
|
end
|
10
9
|
|
11
|
-
it
|
12
|
-
todo = Todotxt::Todo.new
|
13
|
-
|
14
|
-
todo.
|
15
|
-
todo.
|
16
|
-
todo.
|
17
|
-
todo.
|
18
|
-
todo.done.should eql true
|
10
|
+
it 'parses metadata when creating a simple item' do
|
11
|
+
todo = Todotxt::Todo.new 'x an item +project1 +project2 @context1 @context2'
|
12
|
+
expect(todo.to_s).to match('x an item +project1 +project2 @context1 @context2')
|
13
|
+
expect(todo.priority).to be_nil
|
14
|
+
expect(todo.projects).to contain_exactly('+project1', '+project2')
|
15
|
+
expect(todo.contexts).to contain_exactly('@context1', '@context2')
|
16
|
+
expect(todo.done).to be_truthy
|
19
17
|
end
|
20
18
|
|
21
|
-
it
|
22
|
-
todo = Todotxt::Todo.new
|
23
|
-
|
24
|
-
todo.
|
25
|
-
todo.
|
26
|
-
todo.
|
27
|
-
todo.
|
28
|
-
todo.done.should eql true
|
19
|
+
it 'parses metadata when creating an item with priority' do
|
20
|
+
todo = Todotxt::Todo.new '(A) x an item +project1 +project2 @context1 @context2'
|
21
|
+
expect(todo.to_s).to match('(A) x an item +project1 +project2 @context1 @context2')
|
22
|
+
expect(todo.priority).to match('A')
|
23
|
+
expect(todo.projects).to contain_exactly('+project1', '+project2')
|
24
|
+
expect(todo.contexts).to contain_exactly('@context1', '@context2')
|
25
|
+
expect(todo.done).to be_truthy
|
29
26
|
end
|
30
27
|
|
31
|
-
it
|
32
|
-
todo = Todotxt::Todo.new
|
33
|
-
todo.due.
|
28
|
+
it 'parses a due date' do
|
29
|
+
todo = Todotxt::Todo.new '(A) x 2012-12-12 an item +project1 +project2 @context1 @context2'
|
30
|
+
expect(todo.due).to eql(Chronic.parse('12 December 2012').to_date)
|
34
31
|
|
35
|
-
todo = Todotxt::Todo.new
|
36
|
-
todo.due.
|
32
|
+
todo = Todotxt::Todo.new '2012-1-2 an item +project1 +project2 @context1 @context2'
|
33
|
+
expect(todo.due).to eql(Chronic.parse('2 January 2012').to_date)
|
37
34
|
|
38
|
-
todo = Todotxt::Todo.new
|
39
|
-
todo.due.
|
35
|
+
todo = Todotxt::Todo.new '42 folders'
|
36
|
+
expect(todo.due).to be_nil
|
40
37
|
end
|
41
38
|
|
42
|
-
it
|
43
|
-
todo = Todotxt::Todo.new
|
44
|
-
|
45
|
-
todo.line.should eql "2"
|
39
|
+
it 'stores line number when creating an item' do
|
40
|
+
todo = Todotxt::Todo.new 'an item', '2'
|
41
|
+
expect(todo.line).to match('2')
|
46
42
|
end
|
47
43
|
|
48
|
-
it
|
49
|
-
todo = Todotxt::Todo.new
|
50
|
-
|
44
|
+
it 'sets an item as done' do
|
45
|
+
todo = Todotxt::Todo.new 'an item'
|
51
46
|
todo.do
|
52
47
|
|
53
|
-
todo.to_s.
|
54
|
-
todo.done.
|
48
|
+
expect(todo.to_s).to match 'x an item'
|
49
|
+
expect(todo.done).to be_truthy
|
55
50
|
end
|
56
51
|
|
57
|
-
it
|
58
|
-
todo = Todotxt::Todo.new
|
52
|
+
it 'sets an item as not done' do
|
53
|
+
todo = Todotxt::Todo.new 'x an item'
|
59
54
|
|
60
55
|
todo.undo
|
61
56
|
|
62
|
-
todo.to_s.
|
63
|
-
todo.done.
|
57
|
+
expect(todo.to_s).to match('an item')
|
58
|
+
expect(todo.done).to be_falsy
|
64
59
|
end
|
65
60
|
|
66
|
-
it
|
67
|
-
todo = Todotxt::Todo.new
|
68
|
-
|
69
|
-
todo.prioritize "a"
|
61
|
+
it 'adds priority to an item' do
|
62
|
+
todo = Todotxt::Todo.new 'an item'
|
63
|
+
todo.prioritize 'a'
|
70
64
|
|
71
|
-
todo.to_s.
|
72
|
-
todo.priority.
|
65
|
+
expect(todo.to_s).to match('(A) an item')
|
66
|
+
expect(todo.priority).to match('A')
|
73
67
|
end
|
74
68
|
|
75
|
-
it
|
76
|
-
todo = Todotxt::Todo.new
|
77
|
-
|
78
|
-
todo.prioritize "z"
|
69
|
+
it 'changes priority of an item' do
|
70
|
+
todo = Todotxt::Todo.new '(A) an item'
|
71
|
+
todo.prioritize 'z'
|
79
72
|
|
80
|
-
todo.to_s.
|
81
|
-
todo.priority.
|
73
|
+
expect(todo.to_s).to match('(Z) an item')
|
74
|
+
expect(todo.priority).to match('Z')
|
82
75
|
end
|
83
76
|
|
84
|
-
it
|
85
|
-
todo = Todotxt::Todo.new
|
86
|
-
|
77
|
+
it 'removes priority from an item' do
|
78
|
+
todo = Todotxt::Todo.new '(A) an item'
|
87
79
|
todo.prioritize
|
88
80
|
|
89
|
-
todo.to_s.
|
90
|
-
todo.priority.
|
81
|
+
expect(todo.to_s).to match('an item')
|
82
|
+
expect(todo.priority).to be_nil
|
91
83
|
end
|
92
84
|
|
93
|
-
it
|
94
|
-
todo = Todotxt::Todo.new
|
95
|
-
|
96
|
-
todo.append "more text"
|
85
|
+
it 'appends text to an item' do
|
86
|
+
todo = Todotxt::Todo.new 'an item'
|
87
|
+
todo.append 'more text'
|
97
88
|
|
98
|
-
todo.to_s.
|
89
|
+
expect(todo.to_s).to match('an item more text')
|
99
90
|
end
|
100
91
|
|
101
|
-
it
|
102
|
-
todo = Todotxt::Todo.new
|
103
|
-
|
104
|
-
todo.prepend "more text"
|
92
|
+
it 'prepends text to an item' do
|
93
|
+
todo = Todotxt::Todo.new 'an item'
|
94
|
+
todo.prepend 'more text'
|
105
95
|
|
106
|
-
todo.to_s.
|
96
|
+
expect(todo.to_s).to match('more text an item')
|
107
97
|
end
|
108
98
|
|
109
|
-
it
|
110
|
-
todo = Todotxt::Todo.new
|
99
|
+
it 'preserves priority when prepending text to an item' do
|
100
|
+
todo = Todotxt::Todo.new '(A) an item'
|
101
|
+
todo.prepend 'more text'
|
111
102
|
|
112
|
-
todo.
|
113
|
-
|
114
|
-
todo.to_s.should eql "(A) more text an item"
|
115
|
-
todo.priority.should eql "A"
|
103
|
+
expect(todo.to_s).to match('(A) more text an item')
|
104
|
+
expect(todo.priority).to match('A')
|
116
105
|
end
|
117
106
|
|
118
|
-
it
|
119
|
-
todo = Todotxt::Todo.new
|
120
|
-
|
121
|
-
todo.replace "(A) a replacement item"
|
107
|
+
it 'replaces an item with new text' do
|
108
|
+
todo = Todotxt::Todo.new 'an item'
|
109
|
+
todo.replace '(A) a replacement item'
|
122
110
|
|
123
|
-
todo.to_s.
|
124
|
-
todo.priority.
|
111
|
+
expect(todo.to_s).to match('(A) a replacement item')
|
112
|
+
expect(todo.priority).to match('A')
|
125
113
|
end
|
126
114
|
|
127
|
-
it
|
128
|
-
todo1 = Todotxt::Todo.new
|
129
|
-
todo2 = Todotxt::Todo.new
|
115
|
+
it 'sorts based on line number' do
|
116
|
+
todo1 = Todotxt::Todo.new 'an item 1', 1
|
117
|
+
todo2 = Todotxt::Todo.new 'an item 2', 2
|
130
118
|
|
131
|
-
(todo1 <=> todo2).
|
119
|
+
expect(todo1 <=> todo2).to eql -1
|
132
120
|
end
|
133
121
|
|
134
|
-
it
|
135
|
-
todo1 = Todotxt::Todo.new
|
136
|
-
todo2 = Todotxt::Todo.new
|
122
|
+
it 'values items with priority higher when sorting' do
|
123
|
+
todo1 = Todotxt::Todo.new 'an item 1', 1
|
124
|
+
todo2 = Todotxt::Todo.new '(A) an item 2', 2
|
137
125
|
|
138
|
-
(todo1 <=> todo2).
|
126
|
+
expect(todo1 <=> todo2).to eql 1
|
139
127
|
end
|
140
|
-
|
141
128
|
end
|
data/spec/todofile_spec.rb
CHANGED
@@ -1,31 +1,36 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'todotxt/config'
|
3
|
+
require 'todotxt/todofile'
|
4
4
|
|
5
5
|
describe Todotxt::TodoFile do
|
6
6
|
before(:each) do
|
7
|
-
@todo_path =
|
8
|
-
Todotxt::Config.
|
9
|
-
{todo:@todo_path}
|
10
|
-
end
|
7
|
+
@todo_path = '/tmp/todo.txt'
|
8
|
+
allow_any_instance_of(Todotxt::Config).to receive(:files).and_return(todo: @todo_path)
|
11
9
|
end
|
12
10
|
after(:each) do
|
13
|
-
File.delete @todo_path if File.
|
11
|
+
File.delete @todo_path if File.exist? @todo_path
|
14
12
|
end
|
15
13
|
|
16
14
|
it 'should create a new file when initializing' do
|
17
15
|
file = Todotxt::TodoFile.new(@todo_path)
|
18
|
-
file.
|
16
|
+
expect(file).to be_kind_of(Todotxt::TodoFile)
|
19
17
|
end
|
20
18
|
|
21
19
|
it 'should create a new file via the key in config' do
|
22
20
|
file = Todotxt::TodoFile.from_key(:todo)
|
23
|
-
file.
|
21
|
+
expect(file).to be_kind_of(Todotxt::TodoFile)
|
24
22
|
end
|
25
23
|
|
26
24
|
it 'should throw an error for undefined keys' do
|
27
|
-
expect
|
25
|
+
expect do
|
28
26
|
Todotxt::TodoFile.from_key(:does_not_exist)
|
29
|
-
|
27
|
+
end.to raise_error 'Key not found in config'
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#==' do
|
31
|
+
it 'should compare using paths' do
|
32
|
+
expect(Todotxt::TodoFile.new(@todo_path)).to eq(Todotxt::TodoFile.new(@todo_path))
|
33
|
+
expect(Todotxt::TodoFile.new(@todo_path)).not_to eq(Todotxt::TodoFile.new('/other/path'))
|
34
|
+
end
|
30
35
|
end
|
31
36
|
end
|
data/spec/todolist_spec.rb
CHANGED
@@ -1,117 +1,116 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'todotxt/todolist'
|
3
|
+
require 'todotxt/todofile'
|
4
4
|
|
5
5
|
describe Todotxt::TodoList do
|
6
|
-
|
7
|
-
describe "with simple list" do
|
6
|
+
describe 'with simple list' do
|
8
7
|
before :each do
|
9
|
-
@file = Todotxt::TodoFile.new File.join(File.dirname(__FILE__),
|
8
|
+
@file = Todotxt::TodoFile.new File.join(File.dirname(__FILE__), 'fixtures', 'simple_todo.txt')
|
10
9
|
@list = Todotxt::TodoList.new @file
|
11
10
|
end
|
12
11
|
|
13
|
-
it
|
14
|
-
@list.todos[0].to_s.
|
15
|
-
@list.todos[1].to_s.
|
16
|
-
@list.todos[2].to_s.
|
17
|
-
@list.todos[3].to_s.
|
12
|
+
it 'parses a file on creation' do
|
13
|
+
expect(@list.todos[0].to_s).to match('First item')
|
14
|
+
expect(@list.todos[1].to_s).to match('Second item')
|
15
|
+
expect(@list.todos[2].to_s).to match('Third item')
|
16
|
+
expect(@list.todos[3].to_s).to match('x First done item')
|
18
17
|
|
19
|
-
@list.todos[0].line.
|
20
|
-
@list.todos[1].line.
|
21
|
-
@list.todos[2].line.
|
22
|
-
@list.todos[3].line.
|
18
|
+
expect(@list.todos[0].line).to eql 1
|
19
|
+
expect(@list.todos[1].line).to eql 2
|
20
|
+
expect(@list.todos[2].line).to eql 3
|
21
|
+
expect(@list.todos[3].line).to eql 4
|
23
22
|
end
|
24
23
|
|
25
|
-
it
|
26
|
-
@list.add
|
27
|
-
|
28
|
-
@list.todos[4].
|
29
|
-
@list.todos[4].line.should eql 5
|
24
|
+
it 'adds a new item' do
|
25
|
+
@list.add 'Fourth item'
|
26
|
+
expect(@list.todos[4].to_s).to match('Fourth item')
|
27
|
+
expect(@list.todos[4].line).to eql 5
|
30
28
|
end
|
31
29
|
|
32
|
-
it
|
30
|
+
it 'removes an item' do
|
33
31
|
@list.remove 1
|
34
|
-
|
35
|
-
@list.todos[0].to_s.should eql "Second item"
|
32
|
+
expect(@list.todos[0].to_s).to match('Second item')
|
36
33
|
end
|
37
34
|
|
38
|
-
it
|
35
|
+
it 'finds item by line' do
|
39
36
|
todo = @list.find_by_line 3
|
40
|
-
|
41
|
-
todo.to_s.should eql "Third item"
|
37
|
+
expect(todo.to_s).to match('Third item')
|
42
38
|
end
|
43
39
|
|
44
|
-
it
|
45
|
-
@list.filter
|
46
|
-
|
47
|
-
@list.todos.count.should eql 1
|
40
|
+
it 'filters list when searching' do
|
41
|
+
@list.filter 'First'
|
42
|
+
expect(@list.todos.count).to eql 1
|
48
43
|
end
|
49
44
|
|
50
|
-
it
|
51
|
-
@list.filter
|
52
|
-
|
53
|
-
@list.todos.count.should eql 1
|
45
|
+
it 'filters list when searching case-sensitive' do
|
46
|
+
@list.filter 'first'
|
47
|
+
expect(@list.todos.count).to eql 1
|
54
48
|
end
|
55
49
|
|
56
|
-
it
|
57
|
-
@list.add
|
58
|
-
date = DateTime.parse(
|
59
|
-
@list.on_date(date).count.
|
60
|
-
@list.on_date(date).
|
50
|
+
it 'fetches items for a certain date' do
|
51
|
+
@list.add '2012-12-12 item'
|
52
|
+
date = DateTime.parse('2012-12-12')
|
53
|
+
expect(@list.on_date(date).count).to eql 1
|
54
|
+
expect(@list.on_date(date)).to match([@list.todos.last])
|
61
55
|
end
|
62
56
|
|
63
|
-
it
|
64
|
-
@list.add
|
65
|
-
@list.add
|
66
|
-
date = DateTime.parse(
|
67
|
-
@list.before_date(date).count.
|
57
|
+
it 'fetchs items before a cereain date' do
|
58
|
+
@list.add '2012-11-11 item'
|
59
|
+
@list.add '2012-12-12 item'
|
60
|
+
date = DateTime.parse('2012-12-12')
|
61
|
+
expect(@list.before_date(date).count).to eql 1
|
68
62
|
end
|
69
63
|
|
70
|
-
it
|
71
|
-
@list.filter
|
72
|
-
|
73
|
-
@list.todos.count.should eql 2
|
64
|
+
it 'includes done items in search when told to do so' do
|
65
|
+
@list.filter 'first', with_done: true
|
66
|
+
expect(@list.todos.count).to eql 2
|
74
67
|
end
|
75
68
|
|
76
|
-
it
|
77
|
-
@list.filter
|
78
|
-
|
79
|
-
@list.todos.count.should eql 1
|
69
|
+
it 'only includes done items in search when told to do so' do
|
70
|
+
@list.filter 'first', only_done: true
|
71
|
+
expect(@list.todos.count).to eql 1
|
80
72
|
end
|
81
73
|
|
82
|
-
it
|
74
|
+
it 'renders plain text' do
|
83
75
|
comparison_string = <<EOF
|
84
76
|
First item
|
85
77
|
Second item
|
86
78
|
Third item
|
87
79
|
x First done item
|
88
80
|
EOF
|
89
|
-
@list.to_txt.
|
81
|
+
expect(@list.to_txt).to match(comparison_string.strip)
|
90
82
|
end
|
91
83
|
end
|
92
84
|
|
93
|
-
describe
|
85
|
+
describe 'with complex list' do
|
94
86
|
before :each do
|
95
|
-
@file = Todotxt::TodoFile.new File.join(File.dirname(__FILE__),
|
87
|
+
@file = Todotxt::TodoFile.new File.join(File.dirname(__FILE__), 'fixtures', 'complex_todo.txt')
|
96
88
|
@list = Todotxt::TodoList.new @file
|
97
89
|
end
|
98
90
|
|
99
|
-
it
|
100
|
-
@list.todos[0].to_s.
|
101
|
-
@list.todos[0].line.
|
91
|
+
it 'sorts itself automatically on parse' do
|
92
|
+
expect(@list.todos[0].to_s).to match('(A) an item')
|
93
|
+
expect(@list.todos[0].line).to eql(3)
|
102
94
|
end
|
103
95
|
|
104
|
-
it
|
105
|
-
@list.add
|
96
|
+
it 're-sorts itself after adding a new item' do
|
97
|
+
@list.add '(B) A new item'
|
106
98
|
|
107
|
-
@list.todos[1].to_s.
|
108
|
-
@list.todos[1].line.
|
99
|
+
expect(@list.todos[1].to_s).to match('(B) A new item')
|
100
|
+
expect(@list.todos[1].line).to eql(4)
|
109
101
|
end
|
110
102
|
|
111
|
-
it
|
112
|
-
@list.projects.
|
113
|
-
@list.contexts.
|
103
|
+
it 'lists all projects and contexts in the list' do
|
104
|
+
expect(@list.projects).to contain_exactly('+project1', '+project2')
|
105
|
+
expect(@list.contexts).to contain_exactly('@context1', '@context2')
|
114
106
|
end
|
115
107
|
end
|
116
108
|
|
109
|
+
describe 'with line-number provided' do
|
110
|
+
it 'starts counting at the number' do
|
111
|
+
@file = Todotxt::TodoFile.new File.join(File.dirname(__FILE__), 'fixtures', 'simple_todo.txt')
|
112
|
+
@list = Todotxt::TodoList.new @file, 42
|
113
|
+
expect(@list.todos[0].line).to eql 43
|
114
|
+
end
|
115
|
+
end
|
117
116
|
end
|