my_todo 2.8.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18cbf31412cafa361da1286224e29d1582e20bab
4
- data.tar.gz: 5851503d07bc55819b9cf6e8aa7f32d4cec3dcd8
3
+ metadata.gz: 093228595b114cced5a32a36ad34238f403ed5dc
4
+ data.tar.gz: 6f1c939f68f4f6249235f6520a42b038420431d6
5
5
  SHA512:
6
- metadata.gz: 44a29568efb99789a382022f4d48c3c7900a9a8a4b9bab49aeb3750ba7bd9b342ebbeb8d15a9caaa6214d968a8c17471063f662b89648dcd0eb6686483a0f0b4
7
- data.tar.gz: d2dd52251018244a1a8420fc3cade88e778ff741b27e14458d46b42f326023d85119db30f597528c77a78ba9f4c0e84c638eba7b8fad033c65761f1743dfd8d0
6
+ metadata.gz: cae431c8ee769fece3442cb705bc60871a6067306ee9aa48ffd323325995fa4dbb9c8f80556cbb6cfaaf81dcbfb27088dd4a3f31a182a96d2d3b07e0ccef3337
7
+ data.tar.gz: fed9ceeb3af9c1043d389b878fa1a26b7174ecc88d2e2acc7713ee726cc6d6e23f93f48e6b7666ca3e11770f043e4e84ee45908f65eb67375f64222605e9e909
data/README.md CHANGED
@@ -92,7 +92,7 @@ NOTE: In development, all commands must be run with the RAILS_ENV included. This
92
92
 
93
93
  ## Testing
94
94
 
95
- Run `RAILS_ENV=test bin/my_todo rake db:migrate` to create the test db. Then run `rake` to run the RSpec tests.
95
+ Run `RAILS_ENV=test bin/my_todo rake db:migrate` to create the test db. Then run `RAILS_ENV=test bundle exec rake` to run the RSpec tests.
96
96
 
97
97
  ## Releasing
98
98
  To release a new version,
Binary file
Binary file
@@ -0,0 +1,28 @@
1
+ module Finders
2
+ def item
3
+ @item ||= Item.where(id: options[:id]).first
4
+ end
5
+
6
+ def item_notes
7
+ @item_notes ||= item.notes
8
+ end
9
+
10
+ def all_items
11
+ @items = case options[:status]
12
+ when 'all'
13
+ Item.all
14
+ when 'done'
15
+ Item.where(done: true)
16
+ else
17
+ Item.where(done: false)
18
+ end
19
+ end
20
+
21
+ def detailed_statuses
22
+ @detailed_statuses ||= Item::DETAILED_STATUSES
23
+ end
24
+
25
+ def list_statuses
26
+ detailed_statuses.each_with_index {|status, index| say "#{index}: #{status}"}
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ module MyTodoActions
2
+ def ask_status
3
+ list_statuses
4
+ @status = ask("Choose a status for item", default: 1)
5
+ end
6
+
7
+ def create_item(options)
8
+ ask_status
9
+ @item = Item.create!(options.merge({detailed_status: detailed_statuses[@status.to_i]}).except(:tags))
10
+ options[:tags].split(' ').each{|tag| item.tags.create(name: tag) }
11
+ end
12
+
13
+ def update_item(options)
14
+ ask_status
15
+ new_status = detailed_statuses[@status.to_i]
16
+ item.detailed_status != new_status ? item.update!(options.merge({detailed_status: new_status})) : item.update!(options)
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Templates
2
+ p __dir__
3
+ def print_list
4
+ say ERB.new(File.read("#{__dir__}/../templates/list.erb"), nil, '-').result(binding)
5
+ end
6
+
7
+ def print_notes
8
+ say ERB.new(File.read("#{__dir__}/../templates/notes.erb"), nil, '-').result(binding)
9
+ end
10
+
11
+ def print_search_results
12
+ say ERB.new(File.read("#{__dir__}/../templates/results.erb"), nil, '-').result(binding)
13
+ end
14
+
15
+ def print_item
16
+ say ERB.new(File.read("#{__dir__}/../templates/item.erb"), nil, '-').result(binding)
17
+ end
18
+ end
@@ -0,0 +1,2 @@
1
+ ID: <%= item.id %> | Created On: <%= item.created_at.strftime("%Y-%m-%d") %> | Tags: <%= item.tags.map(&:name).join(', ') %> | Status: <%= item.detailed_status %> | Complete: <%= item.done %>
2
+ <%= item.body %>
@@ -0,0 +1,7 @@
1
+
2
+ <% @items.each do |item| -%>
3
+ ID: <%= item.id %> | Created On: <%= item.created_at.strftime("%Y-%m-%d") %> | Tags: <%= item.tags.map(&:name).join(', ') %> | Status: <%= item.detailed_status %> | Complete: <%= item.done %>
4
+
5
+ <%= item.body %>
6
+ <%= '*' * 100 %>
7
+ <% end -%>
@@ -0,0 +1,9 @@
1
+ <% if item_notes.any? -%>
2
+ Notes for <%= item.id %>: <%= item.body %>
3
+ <% item_notes.each do |note| -%>
4
+ ID: <%= note.id %> | Created On: <%= note.created_at.strftime("%Y-%m-%d")%>
5
+ <%= note.body %>
6
+ <% end %>
7
+ <% else -%>
8
+ No Notes for item <%= item.id %>
9
+ <% end %>
@@ -1,10 +1,13 @@
1
1
 
2
+ <% @items.each do |item| -%>
2
3
  ID: <%= item.id %> | Created On: <%= item.created_at.strftime("%Y-%m-%d") %> | Tags: <%= item.tags.map(&:name).join(', ') %> | Status: <%= item.detailed_status %> | Complete: <%= item.done %>
3
4
  <%= item.body %>
5
+
4
6
  <% if item.notes.any? -%>
5
- Notes:
6
7
  <% item.notes.each do |note| -%>
7
- ID: <%= note.id %> | Created On: <%= note.created_at.strftime("%Y-%m-%d")%>
8
- <%= note.body %>
9
- <% end %>
10
- <% end %>
8
+ [<%= note.id %>] <%= note.body %>
9
+ <%= '-' * 100 %>
10
+ <% end -%>
11
+ <% end -%>
12
+ <%= '*' * 100 %>
13
+ <% end -%>
@@ -1,3 +1,3 @@
1
1
  module MyTodo
2
- VERSION = "2.8.0"
2
+ VERSION = "3.0.0"
3
3
  end
data/lib/my_todo.rb CHANGED
@@ -13,7 +13,9 @@ require_relative 'my_todo/models/item'
13
13
  require_relative 'my_todo/models/stub'
14
14
  require_relative 'my_todo/models/tag'
15
15
  require_relative 'my_todo/models/note'
16
-
16
+ require_relative 'my_todo/modules/templates'
17
+ require_relative 'my_todo/modules/finders'
18
+ require_relative 'my_todo/modules/my_todo_actions'
17
19
  module MyTodo
18
20
  # Todo tasks using thor gem
19
21
  class Todo < Thor
@@ -22,59 +24,19 @@ module MyTodo
22
24
 
23
25
  # Private methods
24
26
  no_commands do
25
- def output(item)
26
- say ERB.new(File.read("#{__dir__}/my_todo/templates/output.erb"), nil, '-').result(binding)
27
- end
28
-
29
- def item
30
- @item ||= Item.where(id: options[:id]).first
31
- end
32
-
33
- def detailed_statuses
34
- @detailed_statuses ||= Item::DETAILED_STATUSES
35
- end
36
-
37
- def list_statuses
38
- detailed_statuses.each_with_index {|status, index| say "#{index}: #{status}"}
39
- end
40
-
41
- def ask_status
42
- list_statuses
43
- @status = ask("Choose a status for item", default: 1)
44
- end
45
-
46
- def all_items(status)
47
- case status
48
- when 'all'
49
- Item.all
50
- when 'done'
51
- Item.where(done: true)
52
- else
53
- Item.where(done: false)
54
- end
55
- end
56
-
57
- def create_item(options)
58
- ask_status
59
- @item = Item.create!(options.merge({detailed_status: detailed_statuses[@status.to_i]}).except(:tags))
60
- options[:tags].split(' ').each{|tag| item.tags.create(name: tag) }
61
- end
62
-
63
- def update_item(options)
64
- ask_status
65
- new_status = detailed_statuses[@status.to_i]
66
- item.detailed_status != new_status ? item.update!(options.merge({detailed_status: new_status})) : item.update!(options)
67
- end
27
+ include Templates
28
+ include Finders
29
+ include MyTodoActions
68
30
  end
69
31
 
70
- desc 'list([STATUS])', 'list todos. Default: undone, [all], [done], [undone]'
71
- def list(status=nil)
72
- items = all_items(status)
73
- say "ToDos FOUND: #{items.count}"
74
- items.each {|item| output(item)}
32
+ desc 'list --status=done', 'List todos. Default: undone, [all], [done], [undone]'
33
+ option :status, default: nil
34
+ def list
35
+ say "ToDos FOUND: #{all_items.count}"
36
+ print_list
75
37
  end
76
38
 
77
- desc "create --body='some text' [--done=true] [--tags='tag1 tag2']", 'create a todo'
39
+ desc "create --body='some text' [--done=true] [--tags='tag1 tag2']", 'Create a todo'
78
40
  option :body
79
41
  option :done, default: false
80
42
  option :tags, default: 'default'
@@ -83,13 +45,13 @@ module MyTodo
83
45
  begin
84
46
  say 'ToDo CREATED!'
85
47
  create_item(options)
86
- output @item
48
+ print_item
87
49
  rescue ActiveRecord::RecordInvalid => e
88
50
  say e.message
89
51
  end
90
52
  end
91
53
 
92
- desc "update --id=TODO_ID --body='some text' [--done=true]", 'update an existing todo'
54
+ desc "update --id=TODO_ID --body='some text' [--done=true]", 'Change an existing todo'
93
55
  option :id
94
56
  option :body
95
57
  option :done
@@ -98,17 +60,16 @@ module MyTodo
98
60
  begin
99
61
  update_item(options)
100
62
  say 'ToDo UPDATED!'
101
- output item
63
+ print_item
102
64
  rescue ActiveRecord::RecordInvalid => e
103
65
  say e.message
104
66
  end
105
67
  end
106
68
 
107
- desc 'delete(TODO_ID)', 'destroy a todo'
108
- def delete(id)
69
+ desc 'delete', 'Destroy a todo'
70
+ option :id, required: true
71
+ def delete
109
72
  begin
110
- item = Item.find_by_id(id)
111
- output item
112
73
  item.destroy!
113
74
  say 'ToDo DESTROYED!'
114
75
  rescue StandardError => e
@@ -116,57 +77,68 @@ module MyTodo
116
77
  end
117
78
  end
118
79
 
119
- desc 'search(TEXT)', 'search for todo by item body, tag name or note body'
120
- def search(text)
121
- items = Item.ransack(body_or_detailed_status_or_tags_name_or_notes_body_cont: text).result
122
- say "ToDos FOUND: #{items.count}"
80
+ desc 'search', 'Find a todo by item body, tag name or note body'
81
+ option :text, required: true
82
+ def search
83
+ @items = Item.ransack(body_or_detailed_status_or_tags_name_or_notes_body_cont: options[:text]).result
84
+ say "ToDos FOUND: #{@items.count}"
123
85
  say "Search based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont"
124
- items.each {|item| output item}
86
+ print_search_results
125
87
  end
126
88
 
127
- desc "tag --id=TODO_ID --tag=TAG_NAME", 'add a tag to an existing todo'
89
+ desc "tag --id=TODO_ID --tag=TAG_NAME", 'Add a tag to an existing todo'
128
90
  option :id
129
91
  option :tag
130
92
  def tag
131
93
  begin
132
94
  item.tags.create!(name: options[:tag])
133
- output item.reload
95
+ print_list item.reload
134
96
  rescue StandardError => e
135
97
  say e.message
136
98
  end
137
99
  end
138
100
 
139
- desc 'rm_tag --id=TODO_ID --tag=TAG_NAME', 'remove tag from an existing todo'
101
+ desc 'rm_tag --id=TODO_ID --tag=TAG_NAME', 'Remove tag from an existing todo'
140
102
  option :id
141
103
  option :tag
142
104
  def rm_tag
143
105
  begin
144
106
  item.tags.where(name: options[:tag]).first.destroy!
145
- output item.reload
107
+ print_list item.reload
146
108
  rescue StandardError => e
147
109
  say e.message
148
110
  end
149
111
  end
150
112
 
151
- desc "note --id=TODO_ID --body='text'", 'adds note to existing item'
113
+ desc "add_note --id=TODO_ID --body='text'", 'Adds note to existing item'
152
114
  option :id
153
115
  option :body
154
- def note
116
+ def add_note
155
117
  begin
156
118
  item.notes.create(body: options[:body])
157
- output item.reload
119
+ print_notes
158
120
  rescue StandardError => e
159
121
  say e.message
160
122
  end
161
123
  end
162
124
 
163
- desc 'rm_note --id=TODO_ID --noteid=NOTE_ID', 'remove note for exsiting item'
125
+ desc 'rm_note --id=TODO_ID --noteid=NOTE_ID', 'Remove note for exsiting item'
164
126
  option :id
165
127
  option :noteid
166
128
  def rm_note
167
129
  begin
168
130
  item.notes.where(id: options[:noteid]).first.destroy!
169
- output item.reload
131
+ print_list item.reload
132
+ rescue StandardError => e
133
+ say e.message
134
+ end
135
+ end
136
+
137
+ desc 'notes --id=TODO_ID', 'Display notes for a given todo'
138
+ option :id
139
+ def notes
140
+ begin
141
+ print_notes
170
142
  rescue StandardError => e
171
143
  say e.message
172
144
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe MyTodo do
4
+ describe 'add_note' do
5
+ before {@todo = FactoryGirl.create(:item)}
6
+ context 'successful creation' do
7
+ it 'creates a note' do
8
+ expect{MyTodo::Todo.start(%W[add_note --id=#{@todo.id} --body=note_text])}.to change{Note.count}.by(1)
9
+ end
10
+
11
+ it 'associates note to item' do
12
+ MyTodo::Todo.start(%W[add_note --id=#{@todo.id} --body=note_text])
13
+ expect(@todo.notes.size).to eq 1
14
+ end
15
+
16
+ it 'displays item with notes' do
17
+ expect{MyTodo::Todo.start(%W[add_note --id=#{@todo.id} --body=note_text])}.to output("Notes for 1: Some Body\nID: 1 | Created On: 2016-12-12\nnote_text\n\n\n").to_stdout
18
+ end
19
+ end
20
+
21
+ context 'unsuccessful creation' do
22
+ it 'returns exception if partent item is not found' do
23
+ expect{MyTodo::Todo.start(%W[add_note --id=#{@todo.id + 1}])}.to output("undefined method `notes' for nil:NilClass\n").to_stdout
24
+ end
25
+ end
26
+ end
27
+ end
@@ -33,7 +33,7 @@ describe MyTodo do
33
33
  end
34
34
 
35
35
  it 'displays the created todo item' do
36
- expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\n\nID: 1 | Created On: 2016-10-08 | Tags: default | Status: In Progress | Complete: false\nwierdness_of_text\n\n").to_stdout
36
+ expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nID: 1 | Created On: #{Date.today} | Tags: default | Status: In Progress | Complete: false\nwierdness_of_text\n").to_stdout
37
37
  end
38
38
  end
39
39
 
@@ -43,7 +43,7 @@ describe MyTodo do
43
43
  end
44
44
 
45
45
  it 'displays the created todo item with tag' do
46
- expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text --tags=tag1))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\n\nID: 1 | Created On: 2016-10-08 | Tags: tag1 | Status: In Progress | Complete: false\nwierdness_of_text\n\n").to_stdout
46
+ expect{MyTodo::Todo.start(%w(create --body=wierdness_of_text --tags=tag1))}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nID: 1 | Created On: #{Date.today} | Tags: tag1 | Status: In Progress | Complete: false\nwierdness_of_text\n").to_stdout
47
47
  end
48
48
  end
49
49
 
@@ -56,7 +56,7 @@ describe MyTodo do
56
56
  end
57
57
 
58
58
  it 'displays the created to item with complete set to true' do
59
- expect{MyTodo::Todo.start(%w[create --body=wierdness_of_text --done=true])}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\n\nID: 1 | Created On: 2016-10-08 | Tags: default | Status: In Progress | Complete: true\nwierdness_of_text\n\n").to_stdout
59
+ expect{MyTodo::Todo.start(%w[create --body=wierdness_of_text --done=true])}.to output("ToDo CREATED!\n0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nID: 1 | Created On: #{Date.today} | Tags: default | Status: In Progress | Complete: true\nwierdness_of_text\n").to_stdout
60
60
  end
61
61
  end
62
62
  end
@@ -5,11 +5,11 @@ describe MyTodo do
5
5
  before {@todo = FactoryGirl.create(:item)}
6
6
 
7
7
  it 'destroys todo item' do
8
- expect{MyTodo::Todo.start(%W(delete #{@todo.id}))}.to change{Item.count}.by(-1)
8
+ expect{MyTodo::Todo.start(%W(delete --id=#{@todo.id}))}.to change{Item.count}.by(-1)
9
9
  end
10
10
 
11
11
  it 'returns nil exception if todo item is invalid' do
12
- expect{MyTodo::Todo.start(%W[delete #{@todo.id + 1}])}.to output("undefined method `id' for nil:NilClass\n").to_stdout
12
+ expect{MyTodo::Todo.start(%W[delete --id=#{@todo.id + 1}])}.to output("undefined method `destroy!' for nil:NilClass\n").to_stdout
13
13
  end
14
14
  end
15
15
  end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe MyTodo do
4
+ describe 'list' do
5
+ before do
6
+ @todo1 = FactoryGirl.create :item, done: true
7
+ @todo2 = FactoryGirl.create :item, done: false
8
+ end
9
+
10
+ it 'displays items with done set to true' do
11
+ expect{MyTodo::Todo.start(%w[list --status=done])}.to output("ToDos FOUND: 1\n\nID: 1 | Created On: #{Date.today} | Tags: | Status: | Complete: true\n\nSome Body\n****************************************************************************************************\n").to_stdout
12
+ end
13
+
14
+ it 'displays items with done set to false by default' do
15
+ expect{MyTodo::Todo.start(%w[list])}.to output("ToDos FOUND: 1\n\nID: 2 | Created On: #{Date.today} | Tags: | Status: | Complete: false\n\nSome Body\n****************************************************************************************************\n").to_stdout
16
+ end
17
+
18
+ it 'displays all items' do
19
+ expect{MyTodo::Todo.start(%w[list --status=all])}.to output("ToDos FOUND: 2\n\nID: 1 | Created On: #{Date.today} | Tags: | Status: | Complete: true\n\nSome Body\n****************************************************************************************************\nID: 2 | Created On: #{Date.today} | Tags: | Status: | Complete: false\n\nSome Body\n****************************************************************************************************\n").to_stdout
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe MyTodo do
4
+ describe 'notes' do
5
+ before {@todo = FactoryGirl.create(:item)}
6
+
7
+ context 'item has a note' do
8
+ before {@todo.notes.create(body: 'What a world!')}
9
+
10
+ it 'displays note' do
11
+ expect{MyTodo::Todo.start(%W[notes --id=#{@todo.id}])}.to output("Notes for 1: Some Body\nID: 1 | Created On: 2016-12-12\nWhat a world!\n\n\n").to_stdout
12
+ end
13
+ end
14
+
15
+ context "doesn't have a note" do
16
+ it 'displays no notes message' do
17
+ expect{MyTodo::Todo.start(%W[notes --id=#{@todo.id}])}.to output("No Notes for item #{@todo.id}\n\n").to_stdout
18
+ end
19
+ end
20
+
21
+ context 'unsuccessful creation' do
22
+ it 'returns exception if partent item is not found' do
23
+ expect{MyTodo::Todo.start(%W[add_note --id=#{@todo.id + 1}])}.to output("undefined method `notes' for nil:NilClass\n").to_stdout
24
+ end
25
+ end
26
+ end
27
+ end
@@ -12,22 +12,26 @@ describe MyTodo do
12
12
  end
13
13
 
14
14
  it 'finds todo item by body' do
15
- expect{MyTodo::Todo.start( %w[search nfl])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 1 | Created On: 2016-10-08 | Tags: tag1 | Status: | Complete: \nnfl\n\n").to_stdout
15
+ expect{MyTodo::Todo.start( %w[search --text=nfl])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 1 | Created On: #{Date.today} | Tags: tag1 | Status: | Complete: \nnfl\n\n****************************************************************************************************\n").to_stdout
16
16
  end
17
17
 
18
18
  it 'finds todo items by associated tag' do
19
- expect{MyTodo::Todo.start( %w[search tag1])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 1 | Created On: 2016-10-08 | Tags: tag1 | Status: | Complete: \nnfl\n\n").to_stdout
19
+ expect{MyTodo::Todo.start( %w[search --text=tag1])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 1 | Created On: #{Date.today} | Tags: tag1 | Status: | Complete: \nnfl\n\n****************************************************************************************************\n").to_stdout
20
20
  end
21
21
 
22
22
  it 'finds todo items by detailed status' do
23
23
  @todo2.update!(detailed_status: 'None')
24
- expect{MyTodo::Todo.start( %w[search None])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 2 | Created On: 2016-10-08 | Tags: | Status: None | Complete: \nrocks\n\n").to_stdout
24
+ expect{MyTodo::Todo.start( %w[search --text=None])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 2 | Created On: #{Date.today} | Tags: | Status: None | Complete: \nrocks\n\n****************************************************************************************************\n").to_stdout
25
+ end
26
+
27
+ it 'finds todo items by notes' do
28
+ expect{MyTodo::Todo.start( %w[search --text=note1])}.to output("ToDos FOUND: 1\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\nID: 3 | Created On: 2016-12-12 | Tags: | Status: | Complete: \nalways\n\n [1] note1\n ----------------------------------------------------------------------------------------------------\n****************************************************************************************************\n").to_stdout
25
29
  end
26
30
  end
27
31
 
28
32
  context 'unsuccessful search' do
29
33
  it 'returns no results when searching on invalid body' do
30
- expect{MyTodo::Todo.start( %w(search no_body))}.to output("ToDos FOUND: 0\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n").to_stdout
34
+ expect{MyTodo::Todo.start( %w(search --text=no_body))}.to output("ToDos FOUND: 0\nSearch based on ransack search: body_or_detailed_status_or_tags_name_or_notes_body_cont\n\n").to_stdout
31
35
  end
32
36
  end
33
37
  end
@@ -1,10 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe MyTodo do
4
- def shell
5
- @shell ||= Thor::Shell::Basic.new
6
- end
7
-
8
4
  describe 'update' do
9
5
  before do
10
6
  expect(Thor::LineEditor).to receive(:readline).with("Choose a status for item (1) ", {:default=>1}).and_return("In Progress")
@@ -13,7 +9,7 @@ describe MyTodo do
13
9
 
14
10
  context 'successful update' do
15
11
  it 'displays the update' do
16
- expect{MyTodo::Todo.start(%W[update --id=#{@todo.id} --body=hello])}.to output("0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nToDo UPDATED!\n\nID: 1 | Created On: 2016-10-08 | Tags: | Status: None | Complete: \nhello\n\n").to_stdout
12
+ expect{MyTodo::Todo.start(%W[update --id=#{@todo.id} --body=hello])}.to output("0: None\n1: In Progress\n2: Complete\n3: Punted\n4: Waiting Feedback\nToDo UPDATED!\nID: 1 | Created On: #{Date.today} | Tags: | Status: None | Complete: \nhello\n").to_stdout
17
13
  end
18
14
  end
19
15
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # code climent must be loaded and started before RAILS_ENV is declared
2
2
  require "codeclimate-test-reporter"
3
3
  CodeClimate::TestReporter.start
4
+ ENV['CODECLIMATE_REPO_TOKEN'] = ENV['MYTOD_CC']
4
5
  ENV["RAILS_ENV"] = 'test'
5
6
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
6
7
  require 'database_cleaner'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_todo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-08 00:00:00.000000000 Z
11
+ date: 2016-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -269,15 +269,23 @@ files:
269
269
  - lib/my_todo/models/note.rb
270
270
  - lib/my_todo/models/stub.rb
271
271
  - lib/my_todo/models/tag.rb
272
+ - lib/my_todo/modules/finders.rb
273
+ - lib/my_todo/modules/my_todo_actions.rb
274
+ - lib/my_todo/modules/templates.rb
272
275
  - lib/my_todo/templates/config.yml.erb
273
- - lib/my_todo/templates/output.erb
276
+ - lib/my_todo/templates/item.erb
277
+ - lib/my_todo/templates/list.erb
278
+ - lib/my_todo/templates/notes.erb
279
+ - lib/my_todo/templates/results.erb
274
280
  - lib/my_todo/templates/standalone_migrations.yml.erb
275
281
  - lib/my_todo/version.rb
276
282
  - lib/setup.rb
277
283
  - my_todo.gemspec
284
+ - spec/actions/add_note_spec.rb
278
285
  - spec/actions/create_spec.rb
279
286
  - spec/actions/delete_spec.rb
280
- - spec/actions/note_spec.rb
287
+ - spec/actions/list_spec.rb
288
+ - spec/actions/notes_spec.rb
281
289
  - spec/actions/rm_note_spec.rb
282
290
  - spec/actions/rm_tag_spec.rb
283
291
  - spec/actions/search_spec.rb
@@ -310,14 +318,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
310
318
  version: '0'
311
319
  requirements: []
312
320
  rubyforge_project:
313
- rubygems_version: 2.5.1
321
+ rubygems_version: 2.4.8
314
322
  signing_key:
315
323
  specification_version: 4
316
324
  summary: A basic todo application with tags.
317
325
  test_files:
326
+ - spec/actions/add_note_spec.rb
318
327
  - spec/actions/create_spec.rb
319
328
  - spec/actions/delete_spec.rb
320
- - spec/actions/note_spec.rb
329
+ - spec/actions/list_spec.rb
330
+ - spec/actions/notes_spec.rb
321
331
  - spec/actions/rm_note_spec.rb
322
332
  - spec/actions/rm_tag_spec.rb
323
333
  - spec/actions/search_spec.rb
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe MyTodo do
4
- describe 'note' do
5
- before {@todo = FactoryGirl.create(:item)}
6
- context 'successful creation' do
7
- it 'creates a note' do
8
- expect{MyTodo::Todo.start(%W[note --id=#{@todo.id} --body=note_text])}.to change{Note.count}.by(1)
9
- end
10
-
11
- it 'associates note to item' do
12
- MyTodo::Todo.start(%W[note --id=#{@todo.id} --body=note_text])
13
- expect(@todo.notes.size).to eq 1
14
- end
15
-
16
- it 'displays item with notes' do
17
- expect{MyTodo::Todo.start(%W[note --id=#{@todo.id} --body=note_text])}.to output("\nID: 1 | Created On: 2016-10-08 | Tags: | Status: | Complete: \nSome Body\nNotes:\nID: 1 | Created On: 2016-10-08\nnote_text\n\n\n").to_stdout
18
- end
19
- end
20
-
21
- context 'unsuccessful creation' do
22
- it 'returns exception if note is not found' do
23
- expect{MyTodo::Todo.start(%W[note --id=#{@todo.id + 1}])}.to output("undefined method `notes' for nil:NilClass\n").to_stdout
24
- end
25
- end
26
- end
27
- end