troo 0.0.7 → 0.0.8

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.
Files changed (271) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +2 -0
  4. data/Guardfile +3 -1
  5. data/Rakefile +7 -0
  6. data/bin/troo +3 -8
  7. data/config/.gitkeep +0 -0
  8. data/config/cucumber.yml +8 -0
  9. data/features/add/board.feature +26 -0
  10. data/features/add/card.feature +34 -0
  11. data/features/add/comment.feature +21 -0
  12. data/features/add/list.feature +24 -0
  13. data/features/cleanup.feature +13 -0
  14. data/features/default/board.feature +21 -0
  15. data/features/default/card.feature +21 -0
  16. data/features/default/list.feature +21 -0
  17. data/features/refresh/all.feature +7 -0
  18. data/features/refresh/board.feature +26 -0
  19. data/features/refresh/card.feature +27 -0
  20. data/features/refresh/list.feature +27 -0
  21. data/features/show/board.feature +32 -0
  22. data/features/show/card.feature +62 -0
  23. data/features/show/comment.feature +39 -0
  24. data/features/show/list.feature +37 -0
  25. data/features/status.feature +46 -1
  26. data/features/step_definitions/fabrication_steps.rb +34 -0
  27. data/features/step_definitions/troo_steps.rb +16 -0
  28. data/features/support/env.rb +22 -24
  29. data/features/troo.feature +31 -1
  30. data/lib/troo/actions/create_board.rb +10 -7
  31. data/lib/troo/actions/create_card.rb +5 -4
  32. data/lib/troo/actions/create_comment.rb +15 -13
  33. data/lib/troo/actions/create_list.rb +5 -4
  34. data/lib/troo/actions/move_card.rb +4 -3
  35. data/lib/troo/{external/board_adaptor.rb → adaptors/board.rb} +3 -14
  36. data/lib/troo/{external/card_adaptor.rb → adaptors/card.rb} +4 -15
  37. data/lib/troo/{external/comment_adaptor.rb → adaptors/comment.rb} +6 -17
  38. data/lib/troo/{external/list_adaptor.rb → adaptors/list.rb} +3 -14
  39. data/lib/troo/{external/member_adaptor.rb → adaptors/member.rb} +3 -14
  40. data/lib/troo/adaptors/resource.rb +17 -0
  41. data/lib/troo/cli/add.rb +53 -0
  42. data/lib/troo/cli/default.rb +25 -0
  43. data/lib/troo/cli/main.rb +46 -0
  44. data/lib/troo/cli/refresh.rb +31 -0
  45. data/lib/troo/cli/show.rb +41 -0
  46. data/lib/troo/cli/thor_fixes.rb +13 -0
  47. data/lib/troo/commands/add/board.rb +26 -0
  48. data/lib/troo/commands/add/card.rb +33 -0
  49. data/lib/troo/commands/add/comment.rb +33 -0
  50. data/lib/troo/commands/add/list.rb +33 -0
  51. data/lib/troo/commands/add/resource.rb +21 -0
  52. data/lib/troo/commands/commands.rb +28 -0
  53. data/lib/troo/commands/default/board.rb +25 -0
  54. data/lib/troo/commands/default/card.rb +25 -0
  55. data/lib/troo/commands/default/list.rb +25 -0
  56. data/lib/troo/commands/default/resource.rb +26 -0
  57. data/lib/troo/commands/refresh/all.rb +41 -0
  58. data/lib/troo/commands/refresh/board.rb +28 -0
  59. data/lib/troo/commands/refresh/card.rb +29 -0
  60. data/lib/troo/commands/refresh/list.rb +29 -0
  61. data/lib/troo/commands/refresh/resource.rb +42 -0
  62. data/lib/troo/commands/show/board.rb +13 -0
  63. data/lib/troo/commands/show/boards.rb +35 -0
  64. data/lib/troo/commands/show/card.rb +13 -0
  65. data/lib/troo/commands/show/comments.rb +21 -0
  66. data/lib/troo/commands/show/list.rb +13 -0
  67. data/lib/troo/commands/show/resource.rb +41 -0
  68. data/lib/troo/commands/status/board.rb +30 -0
  69. data/lib/troo/commands/status/card.rb +30 -0
  70. data/lib/troo/commands/status/list.rb +30 -0
  71. data/lib/troo/commands/status/resource.rb +34 -0
  72. data/lib/troo/decorators/board.rb +66 -0
  73. data/lib/troo/decorators/card.rb +105 -0
  74. data/lib/troo/decorators/comment.rb +36 -0
  75. data/lib/troo/decorators/list.rb +60 -0
  76. data/lib/troo/decorators/member.rb +28 -0
  77. data/lib/troo/external/board.rb +14 -26
  78. data/lib/troo/external/card.rb +2 -19
  79. data/lib/troo/external/comment.rb +5 -23
  80. data/lib/troo/external/list.rb +2 -20
  81. data/lib/troo/external/member.rb +2 -20
  82. data/lib/troo/external/resource.rb +21 -6
  83. data/lib/troo/helpers/command_helpers.rb +37 -0
  84. data/lib/troo/{display → helpers}/decorator_helpers.rb +23 -17
  85. data/lib/troo/{models → helpers}/model_helpers.rb +1 -1
  86. data/lib/troo/models/behaviours/set_default.rb +49 -0
  87. data/lib/troo/models/board.rb +10 -7
  88. data/lib/troo/models/card.rb +33 -15
  89. data/lib/troo/models/comment.rb +8 -5
  90. data/lib/troo/models/list.rb +10 -6
  91. data/lib/troo/models/member.rb +7 -4
  92. data/lib/troo/models/persistence/board.rb +19 -0
  93. data/lib/troo/models/persistence/card.rb +19 -0
  94. data/lib/troo/models/persistence/comment.rb +19 -0
  95. data/lib/troo/models/persistence/list.rb +19 -0
  96. data/lib/troo/models/persistence/member.rb +19 -0
  97. data/lib/troo/models/persistence/resource.rb +50 -0
  98. data/lib/troo/models/refresh.rb +1 -1
  99. data/lib/troo/models/remote/comment.rb +21 -0
  100. data/lib/troo/models/remote/resource.rb +25 -0
  101. data/lib/troo/models/retrieval/board.rb +29 -0
  102. data/lib/troo/models/retrieval/card.rb +33 -0
  103. data/lib/troo/models/retrieval/comment.rb +25 -0
  104. data/lib/troo/models/retrieval/list.rb +29 -0
  105. data/lib/troo/models/retrieval/member.rb +25 -0
  106. data/lib/troo/models/retrieval/resource.rb +36 -0
  107. data/lib/troo/presentation/sentence.rb +57 -0
  108. data/lib/troo/presentation/template.rb +4 -3
  109. data/lib/troo/presenters/board.rb +81 -0
  110. data/lib/troo/presenters/card.rb +30 -0
  111. data/lib/troo/presenters/comment.rb +38 -0
  112. data/lib/troo/presenters/list.rb +44 -0
  113. data/lib/troo/presenters/member.rb +32 -0
  114. data/lib/troo/troo.rb +79 -65
  115. data/lib/troo/version.rb +1 -2
  116. data/lib/troo.rb +36 -8
  117. data/test/lib/troo/actions/create_board_test.rb +34 -15
  118. data/test/lib/troo/actions/create_card_test.rb +35 -18
  119. data/test/lib/troo/actions/create_comment_test.rb +38 -16
  120. data/test/lib/troo/actions/create_list_test.rb +31 -15
  121. data/test/lib/troo/actions/move_card_test.rb +23 -15
  122. data/test/lib/troo/adaptors/board_test.rb +38 -0
  123. data/test/lib/troo/adaptors/card_test.rb +49 -0
  124. data/test/lib/troo/adaptors/comment_test.rb +41 -0
  125. data/test/lib/troo/adaptors/list_test.rb +38 -0
  126. data/test/lib/troo/adaptors/member_test.rb +44 -0
  127. data/test/lib/troo/commands/add/board_test.rb +43 -0
  128. data/test/lib/troo/commands/add/card_test.rb +44 -0
  129. data/test/lib/troo/commands/add/comment_test.rb +44 -0
  130. data/test/lib/troo/commands/add/list_test.rb +44 -0
  131. data/test/lib/troo/commands/add/resource_test.rb +25 -0
  132. data/test/lib/troo/commands/default/board_test.rb +37 -0
  133. data/test/lib/troo/commands/default/card_test.rb +37 -0
  134. data/test/lib/troo/commands/default/list_test.rb +37 -0
  135. data/test/lib/troo/commands/default/resource_test.rb +20 -0
  136. data/test/lib/troo/commands/refresh/all_test.rb +39 -0
  137. data/test/lib/troo/commands/refresh/board_test.rb +62 -0
  138. data/test/lib/troo/commands/refresh/card_test.rb +62 -0
  139. data/test/lib/troo/commands/refresh/list_test.rb +62 -0
  140. data/test/lib/troo/commands/refresh/resource_test.rb +20 -0
  141. data/test/lib/troo/commands/show/board_test.rb +65 -0
  142. data/test/lib/troo/commands/show/boards_test.rb +36 -0
  143. data/test/lib/troo/commands/show/card_test.rb +64 -0
  144. data/test/lib/troo/commands/show/comments_test.rb +64 -0
  145. data/test/lib/troo/commands/show/list_test.rb +64 -0
  146. data/test/lib/troo/commands/show/resource_test.rb +25 -0
  147. data/test/lib/troo/commands/status/board_test.rb +43 -0
  148. data/test/lib/troo/commands/status/card_test.rb +43 -0
  149. data/test/lib/troo/commands/status/list_test.rb +43 -0
  150. data/test/lib/troo/commands/status/resource_test.rb +19 -0
  151. data/test/lib/troo/decorators/board_test.rb +129 -0
  152. data/test/lib/troo/decorators/card_test.rb +237 -0
  153. data/test/lib/troo/decorators/comment_test.rb +74 -0
  154. data/test/lib/troo/decorators/list_test.rb +102 -0
  155. data/test/lib/troo/decorators/member_test.rb +50 -0
  156. data/test/lib/troo/external/board_test.rb +74 -41
  157. data/test/lib/troo/external/card_test.rb +49 -37
  158. data/test/lib/troo/external/comment_test.rb +43 -33
  159. data/test/lib/troo/external/list_test.rb +37 -30
  160. data/test/lib/troo/external/member_test.rb +37 -30
  161. data/test/lib/troo/external/resource_test.rb +18 -1
  162. data/test/lib/troo/helpers/command_helpers_test.rb +82 -0
  163. data/test/lib/troo/{display → helpers}/decorator_helpers_test.rb +6 -6
  164. data/test/lib/troo/helpers/model_helpers_test.rb +103 -0
  165. data/test/lib/troo/models/behaviours/set_default_test.rb +54 -0
  166. data/test/lib/troo/models/board_test.rb +13 -14
  167. data/test/lib/troo/models/card_test.rb +64 -33
  168. data/test/lib/troo/models/comment_test.rb +18 -19
  169. data/test/lib/troo/models/list_test.rb +15 -15
  170. data/test/lib/troo/models/member_test.rb +18 -18
  171. data/test/lib/troo/models/persistence/board_test.rb +62 -0
  172. data/test/lib/troo/models/persistence/card_test.rb +61 -0
  173. data/test/lib/troo/models/persistence/comment_test.rb +69 -0
  174. data/test/lib/troo/models/persistence/list_test.rb +60 -0
  175. data/test/lib/troo/models/persistence/member_test.rb +60 -0
  176. data/test/lib/troo/models/refresh_test.rb +12 -11
  177. data/test/lib/troo/models/remote/comment_test.rb +56 -0
  178. data/test/lib/troo/models/remote/resource_test.rb +26 -0
  179. data/test/lib/troo/models/retrieval/board_test.rb +93 -0
  180. data/test/lib/troo/models/retrieval/card_test.rb +101 -0
  181. data/test/lib/troo/models/retrieval/comment_test.rb +46 -0
  182. data/test/lib/troo/models/retrieval/list_test.rb +93 -0
  183. data/test/lib/troo/models/retrieval/member_test.rb +58 -0
  184. data/test/lib/troo/presentation/sentence_test.rb +57 -0
  185. data/test/lib/troo/presentation/template_test.rb +17 -16
  186. data/test/lib/troo/presenters/board_test.rb +79 -0
  187. data/test/lib/troo/presenters/card_test.rb +41 -0
  188. data/test/lib/troo/presenters/comment_test.rb +49 -0
  189. data/test/lib/troo/presenters/list_test.rb +50 -0
  190. data/test/lib/troo/presenters/member_test.rb +40 -0
  191. data/test/support/fabrication.rb +31 -32
  192. data/test/support/vcr_setup.rb +7 -9
  193. data/test/system_test.sh +55 -0
  194. data/test/test_helper.rb +10 -10
  195. data/troo.gemspec +1 -0
  196. metadata +232 -134
  197. data/features/add_board.feature +0 -1
  198. data/features/add_card.feature +0 -1
  199. data/features/add_comment.feature +0 -1
  200. data/features/add_list.feature +0 -1
  201. data/features/move_card_to_list.feature +0 -1
  202. data/features/refresh.feature +0 -1
  203. data/features/set_default.feature +0 -7
  204. data/features/show_board.feature +0 -1
  205. data/features/show_boards.feature +0 -1
  206. data/features/show_card.feature +0 -1
  207. data/features/show_comments.feature +0 -1
  208. data/features/show_list.feature +0 -1
  209. data/features/version.feature +0 -8
  210. data/lib/troo/actions/refresh_all.rb +0 -79
  211. data/lib/troo/actions/set_default.rb +0 -46
  212. data/lib/troo/cli/add_cli.rb +0 -83
  213. data/lib/troo/cli/cli_helpers.rb +0 -34
  214. data/lib/troo/cli/default_cli.rb +0 -32
  215. data/lib/troo/cli/main_cli.rb +0 -132
  216. data/lib/troo/cli/show_cli.rb +0 -64
  217. data/lib/troo/display/board_decorator.rb +0 -62
  218. data/lib/troo/display/board_presenter.rb +0 -71
  219. data/lib/troo/display/card_decorator.rb +0 -100
  220. data/lib/troo/display/card_presenter.rb +0 -27
  221. data/lib/troo/display/comment_decorator.rb +0 -33
  222. data/lib/troo/display/comment_presenter.rb +0 -31
  223. data/lib/troo/display/list_decorator.rb +0 -57
  224. data/lib/troo/display/list_presenter.rb +0 -41
  225. data/lib/troo/display/member_decorator.rb +0 -25
  226. data/lib/troo/display/member_presenter.rb +0 -59
  227. data/lib/troo/models/board_persistence.rb +0 -25
  228. data/lib/troo/models/board_retrieval.rb +0 -45
  229. data/lib/troo/models/card_persistence.rb +0 -25
  230. data/lib/troo/models/card_retrieval.rb +0 -49
  231. data/lib/troo/models/comment_persistence.rb +0 -25
  232. data/lib/troo/models/comment_retrieval.rb +0 -32
  233. data/lib/troo/models/list_persistence.rb +0 -25
  234. data/lib/troo/models/list_retrieval.rb +0 -45
  235. data/lib/troo/models/member_persistence.rb +0 -25
  236. data/lib/troo/models/member_retrieval.rb +0 -36
  237. data/lib/troo/models/persistence.rb +0 -39
  238. data/test/lib/troo/actions/refresh_all_test.rb +0 -68
  239. data/test/lib/troo/actions/set_default_test.rb +0 -44
  240. data/test/lib/troo/cli/add_cli_test.rb +0 -216
  241. data/test/lib/troo/cli/cli_helpers_test.rb +0 -24
  242. data/test/lib/troo/cli/default_cli_test.rb +0 -85
  243. data/test/lib/troo/cli/main_cli_test.rb +0 -234
  244. data/test/lib/troo/cli/show_cli_test.rb +0 -251
  245. data/test/lib/troo/display/board_decorator_test.rb +0 -126
  246. data/test/lib/troo/display/board_presenter_test.rb +0 -77
  247. data/test/lib/troo/display/card_decorator_test.rb +0 -213
  248. data/test/lib/troo/display/card_presenter_test.rb +0 -38
  249. data/test/lib/troo/display/comment_decorator_test.rb +0 -70
  250. data/test/lib/troo/display/comment_presenter_test.rb +0 -47
  251. data/test/lib/troo/display/list_decorator_test.rb +0 -98
  252. data/test/lib/troo/display/list_presenter_test.rb +0 -48
  253. data/test/lib/troo/display/member_decorator_test.rb +0 -47
  254. data/test/lib/troo/display/member_presenter_test.rb +0 -70
  255. data/test/lib/troo/external/board_adaptor_test.rb +0 -36
  256. data/test/lib/troo/external/card_adaptor_test.rb +0 -50
  257. data/test/lib/troo/external/comment_adaptor_test.rb +0 -41
  258. data/test/lib/troo/external/list_adaptor_test.rb +0 -38
  259. data/test/lib/troo/external/member_adaptor_test.rb +0 -44
  260. data/test/lib/troo/models/board_persistence_test.rb +0 -61
  261. data/test/lib/troo/models/board_retrieval_test.rb +0 -93
  262. data/test/lib/troo/models/card_persistence_test.rb +0 -60
  263. data/test/lib/troo/models/card_retrieval_test.rb +0 -101
  264. data/test/lib/troo/models/comment_persistence_test.rb +0 -65
  265. data/test/lib/troo/models/comment_retrieval_test.rb +0 -46
  266. data/test/lib/troo/models/list_persistence_test.rb +0 -60
  267. data/test/lib/troo/models/list_retrieval_test.rb +0 -93
  268. data/test/lib/troo/models/member_persistence_test.rb +0 -59
  269. data/test/lib/troo/models/member_retrieval_test.rb +0 -58
  270. data/test/lib/troo/models/model_helpers_test.rb +0 -103
  271. data/test/lib/troo/models/persistence_test.rb +0 -6
@@ -0,0 +1,64 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ module Commands
5
+ module Show
6
+ describe List do
7
+ let(:described_class) { List }
8
+ let(:type) { :list }
9
+ let(:id) { '1' }
10
+ let(:default) { false }
11
+ let(:resource) {}
12
+ let(:presenter) { stub }
13
+
14
+ before do
15
+ @list = Fabricate.build(:list, default: default)
16
+ Retrieval::List.stubs(:retrieve).returns(resource)
17
+ Presenters::List.stubs(:new).returns(presenter)
18
+ presenter.stubs(:show).returns(@list.name)
19
+ end
20
+
21
+ after { database_cleanup }
22
+
23
+ describe '.dispatch' do
24
+ subject { described_class.dispatch(type, id) }
25
+
26
+ context 'when a resource ID is provided' do
27
+ context 'and the resource exists' do
28
+ let(:resource) { @list }
29
+
30
+ it 'presents the lists' do
31
+ subject.must_match(/#{@list.name}/)
32
+ end
33
+ end
34
+
35
+ context 'but the resource does not exist' do
36
+ it 'returns a polite message' do
37
+ subject.must_match(/List cannot be found/)
38
+ end
39
+ end
40
+ end
41
+
42
+ context 'when a resource ID is not provided' do
43
+ let(:id) {}
44
+
45
+ context 'and a default resource is set' do
46
+ let(:default) { true }
47
+ let(:resource) { @list }
48
+
49
+ it 'presents the lists' do
50
+ subject.must_match(/#{@list.name}/)
51
+ end
52
+ end
53
+
54
+ context 'and a default resource is not set' do
55
+ it 'returns a polite message' do
56
+ subject.must_match(/to set a default list first/)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,25 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ module Commands
5
+ module Show
6
+ describe Resource do
7
+ let(:described_class) { Resource }
8
+ let(:type) {}
9
+ let(:id) {}
10
+
11
+ describe '#initialize' do
12
+ subject { described_class.new(type, id) }
13
+
14
+ it 'assigns the type to an instance variable' do
15
+ subject.instance_variable_get('@type').must_equal(type)
16
+ end
17
+
18
+ it 'assigns the id to an instance variable' do
19
+ subject.instance_variable_get('@id').must_equal(id)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,43 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ module Commands
5
+ module Status
6
+ describe Board do
7
+ let(:described_class) { Board }
8
+ let(:default) { true }
9
+
10
+ describe '.dispatch' do
11
+ subject { described_class.dispatch }
12
+
13
+ before { @board = Fabricate(:board, default: default) }
14
+ after { database_cleanup }
15
+
16
+ context 'when a default is set' do
17
+ it 'returns a polite message' do
18
+ subject.must_match(/1 board found/)
19
+ end
20
+ end
21
+
22
+ context 'when no default is set' do
23
+ let(:default) { false }
24
+
25
+ context 'and the resource exists' do
26
+ it 'returns a polite message' do
27
+ subject.must_match(/No default board set/)
28
+ end
29
+ end
30
+
31
+ context 'and no resources exist' do
32
+ before { Troo::Board.stubs(:count).returns(0) }
33
+
34
+ it 'returns a polite message' do
35
+ subject.must_match(/No boards found/)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,43 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ module Commands
5
+ module Status
6
+ describe Card do
7
+ let(:described_class) { Card }
8
+ let(:default) { true }
9
+
10
+ describe '.dispatch' do
11
+ subject { described_class.dispatch }
12
+
13
+ before { @card = Fabricate(:card, default: default) }
14
+ after { database_cleanup }
15
+
16
+ context 'when a default is set' do
17
+ it 'returns a polite message' do
18
+ subject.must_match(/1 card found/)
19
+ end
20
+ end
21
+
22
+ context 'when no default is set' do
23
+ let(:default) { false }
24
+
25
+ context 'and the resource exist' do
26
+ it 'returns a polite message' do
27
+ subject.must_match(/No default card set/)
28
+ end
29
+ end
30
+
31
+ context 'and no resources exist' do
32
+ before { Troo::Card.stubs(:count).returns(0) }
33
+
34
+ it 'returns a polite message' do
35
+ subject.must_match(/No cards found/)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,43 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ module Commands
5
+ module Status
6
+ describe List do
7
+ let(:described_class) { List }
8
+ let(:default) { true }
9
+
10
+ describe '.dispatch' do
11
+ subject { described_class.dispatch }
12
+
13
+ before { @list = Fabricate(:list, default: default) }
14
+ after { database_cleanup }
15
+
16
+ context 'when a default is set' do
17
+ it 'returns a polite message' do
18
+ subject.must_match(/1 list found/)
19
+ end
20
+ end
21
+
22
+ context 'when no default is set' do
23
+ let(:default) { false }
24
+
25
+ context 'and the resource exists' do
26
+ it 'returns a polite message' do
27
+ subject.must_match(/No default list set/)
28
+ end
29
+ end
30
+
31
+ context 'and no resources exist' do
32
+ before { Troo::List.stubs(:count).returns(0) }
33
+
34
+ it 'returns a polite message' do
35
+ subject.must_match(/No lists found/)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,19 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ module Commands
5
+ module Status
6
+ describe Resource do
7
+ let(:described_class) { Resource }
8
+
9
+ # describe ".dispatch" do
10
+ # subject { described_class.dispatch }
11
+
12
+ # it "will be tested by the integration tests" do
13
+ # skip
14
+ # end
15
+ # end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,129 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ module Troo
4
+ module Decorators
5
+ describe Board do
6
+ let(:described_class) { Board }
7
+ let(:default) { true }
8
+ let(:options) { {} }
9
+
10
+ before { @board = Fabricate(:board, default: default) }
11
+ after { database_cleanup }
12
+
13
+ describe '#initialize' do
14
+ subject { described_class.new(@board, options) }
15
+
16
+ it 'assigns the board to an instance variable' do
17
+ subject.instance_variable_get('@board').must_equal(@board)
18
+ end
19
+
20
+ it 'assigns the options to an instance variable' do
21
+ subject.instance_variable_get('@options').must_equal(options)
22
+ end
23
+ end
24
+
25
+ describe '#short' do
26
+ subject { described_class.new(@board, options).short }
27
+
28
+ it 'returns a one line overview of the board' do
29
+ subject.must_equal(" * \e[34m\e[4m(1) \e[0m\e[34m\e[4mMy " \
30
+ "Test Board\e[0m\n")
31
+ end
32
+
33
+ context 'when the ansicolor option is false' do
34
+ let(:options) { { ansicolor: false } }
35
+
36
+ it 'returns a one line overview of the board' do
37
+ subject.must_equal(" * (1) My Test Board\n")
38
+ end
39
+ end
40
+ end
41
+
42
+ describe '#name_str' do
43
+ subject { described_class.new(@board).name_str }
44
+
45
+ it 'returns the formatted board name' do
46
+ subject.must_equal("\e[34m\e[4mMy Test Board\e[0m")
47
+ end
48
+ end
49
+
50
+ describe '#default_str' do
51
+ subject { described_class.new(@board).default_str }
52
+
53
+ it 'returns the formatted board default indicator' do
54
+ subject.must_equal(' * ')
55
+ end
56
+ end
57
+
58
+ describe '#id_str' do
59
+ subject { described_class.new(@board).id_str }
60
+
61
+ it 'returns the formatted board id' do
62
+ subject.must_equal("\e[34m\e[4m(1) \e[0m")
63
+ end
64
+ end
65
+
66
+ describe '#description' do
67
+ subject { described_class.new(@board).description }
68
+
69
+ context 'when the board has a description' do
70
+ it 'returns the board description' do
71
+ subject.must_equal(@board.description)
72
+ end
73
+ end
74
+
75
+ context 'when the board has no description' do
76
+ before { @board.stubs(:description) }
77
+
78
+ it 'returns N/A' do
79
+ subject.must_equal('N/A')
80
+ end
81
+ end
82
+ end
83
+
84
+ describe '#name' do
85
+ subject { described_class.new(@board).name }
86
+
87
+ context 'when the board has a name' do
88
+ it 'returns the board name' do
89
+ subject.must_equal(@board.name)
90
+ end
91
+ end
92
+
93
+ context 'when the board has no name' do
94
+ before { @board.stubs(:name) }
95
+
96
+ it 'returns N/A' do
97
+ subject.must_equal('N/A')
98
+ end
99
+ end
100
+ end
101
+
102
+ describe '#default' do
103
+ subject { described_class.new(@board).default }
104
+
105
+ context 'when default' do
106
+ it 'return an indicator' do
107
+ subject.must_equal('*')
108
+ end
109
+ end
110
+
111
+ context 'when not default' do
112
+ let(:default) { false }
113
+
114
+ it 'returns nothing' do
115
+ subject.must_equal('')
116
+ end
117
+ end
118
+ end
119
+
120
+ describe '#id' do
121
+ subject { described_class.new(@board).id }
122
+
123
+ it 'returns the board id' do
124
+ subject.must_equal(@board.id.to_s)
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,237 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ module Troo
4
+ module Decorators
5
+ describe Card do
6
+ let(:described_class) { Card }
7
+ let(:described_instance) { described_class.new(@card, options) }
8
+ let(:default) { true }
9
+ let(:description) { 'Finish Troo for fame and fortune.' }
10
+ let(:options) { {} }
11
+
12
+ before do
13
+ @board = Fabricate(:board)
14
+ @list = Fabricate(:list)
15
+ @card = Fabricate(:card,
16
+ desc: description,
17
+ default: default)
18
+ @comment = Fabricate(:comment)
19
+ @comment_2 = Fabricate(:comment,
20
+ text: 'My Other Test Comment')
21
+ @comment_3 = Fabricate(:comment,
22
+ text: 'My Lithium Comment')
23
+ @comment_4 = Fabricate(:comment,
24
+ text: 'My Beryllium Comment')
25
+ @member = Fabricate(:member)
26
+ @member_2 = Fabricate(:member,
27
+ username: 'mysterywoman',
28
+ external_member_id: 'some_member_id')
29
+ end
30
+
31
+ after { database_cleanup }
32
+
33
+ describe '#initialize' do
34
+ subject { described_instance }
35
+
36
+ it 'assigns the card to an instance variable' do
37
+ subject.instance_variable_get('@card').must_equal(@card)
38
+ end
39
+
40
+ it 'assigns the options to an instance variable' do
41
+ subject.instance_variable_get('@options')
42
+ .must_equal(options)
43
+ end
44
+ end
45
+
46
+ describe '#short' do
47
+ subject { described_instance.short }
48
+
49
+ it 'returns a one line overview of the card' do
50
+ subject.must_equal(" * \e[35m\e[4m(67) \e[0m\e[35m\e[4m" \
51
+ "My Test Card\e[0m\n")
52
+ end
53
+
54
+ context 'when the ansicolor option is false' do
55
+ let(:options) { { ansicolor: false } }
56
+
57
+ it 'returns a one line overview of the card' do
58
+ subject.must_equal(" * (67) My Test Card\n")
59
+ end
60
+ end
61
+ end
62
+
63
+ describe '#name_str' do
64
+ subject { described_instance.name_str }
65
+
66
+ it 'returns the formatted card name' do
67
+ subject.must_equal("\e[35m\e[4mMy Test Card\e[0m")
68
+ end
69
+ end
70
+
71
+ describe '#default_str' do
72
+ subject { described_instance.default_str }
73
+
74
+ it 'returns the formatted card default indicator' do
75
+ subject.must_equal(' * ')
76
+ end
77
+ end
78
+
79
+ describe '#id_str' do
80
+ subject { described_instance.id_str }
81
+
82
+ it 'returns the formatted card id' do
83
+ subject.must_equal("\e[35m\e[4m(67) \e[0m")
84
+ end
85
+ end
86
+
87
+ describe '#name' do
88
+ subject { described_instance.name }
89
+
90
+ it 'returns the card name' do
91
+ subject.must_equal(@card.name)
92
+ end
93
+ end
94
+
95
+ describe '#default' do
96
+ subject { described_instance.default }
97
+
98
+ context 'when default' do
99
+ it 'return an indicator' do
100
+ subject.must_equal('*')
101
+ end
102
+ end
103
+
104
+ context 'when not default' do
105
+ let(:default) { false }
106
+
107
+ it 'returns nothing' do
108
+ subject.must_equal('')
109
+ end
110
+ end
111
+ end
112
+
113
+ describe '#id' do
114
+ subject { described_instance.id }
115
+
116
+ it 'returns the card id' do
117
+ subject.must_equal(@card.short_id)
118
+ end
119
+ end
120
+
121
+ describe '#description' do
122
+ subject { described_instance.description }
123
+
124
+ context 'when there are further details' do
125
+ it 'returns the description' do
126
+ subject.must_equal(@card.desc)
127
+ end
128
+ end
129
+
130
+ context 'when there are no further details' do
131
+ let(:description) { nil }
132
+
133
+ it 'returns a polite message' do
134
+ subject.must_match(/no further details/)
135
+ end
136
+ end
137
+ end
138
+
139
+ describe '#comments' do
140
+ subject { described_instance.comments }
141
+
142
+ context 'when there are more than 3 comments' do
143
+ it 'returns the comments' do
144
+ subject.must_match(/There are more comments/)
145
+ subject.must_match(/My Test Comment/)
146
+ subject.must_match(/My Other Test Comment/)
147
+ subject.must_match(/My Lithium Comment/)
148
+ subject.wont_match(/My Beryllium Comment/)
149
+ end
150
+ end
151
+
152
+ context 'when there are 3 or less comments' do
153
+ before do
154
+ @comment_3.delete
155
+ @comment_4.delete
156
+ end
157
+
158
+ it 'returns the comments' do
159
+ subject.must_match(/My Test Comment/)
160
+ subject.must_match(/My Other Test Comment/)
161
+ end
162
+ end
163
+
164
+ context 'when there are no comments' do
165
+ before do
166
+ @comment.delete
167
+ @comment_2.delete
168
+ @comment_3.delete
169
+ @comment_4.delete
170
+ end
171
+
172
+ it 'returns a polite message' do
173
+ subject.must_equal('No comments have been left.')
174
+ end
175
+ end
176
+ end
177
+
178
+ describe '#members' do
179
+ subject { described_instance.members }
180
+
181
+ context 'when there are members' do
182
+ it 'returns the members' do
183
+ subject.must_equal('@gavinlaking1')
184
+ end
185
+ end
186
+
187
+ context 'when there are no members' do
188
+ before do
189
+ @card.external_member_ids = nil
190
+ @member.delete
191
+ @member_2.delete
192
+ end
193
+
194
+ it 'returns a polite message' do
195
+ subject.must_equal('No members have been assigned.')
196
+ end
197
+ end
198
+ end
199
+
200
+ describe '#last_activity_date' do
201
+ subject { described_instance.last_activity_date }
202
+
203
+ context 'when the last activity date is set' do
204
+ it 'returns the last activity date' do
205
+ subject.must_equal('Tue, Dec 17 at 21:48')
206
+ end
207
+ end
208
+
209
+ context 'when the last activity date is not set' do
210
+ before { @card.stubs(:last_activity_date) }
211
+
212
+ it "returns 'N/A'" do
213
+ subject.must_equal('N/A')
214
+ end
215
+ end
216
+ end
217
+
218
+ describe '#board' do
219
+ subject { described_instance.board }
220
+
221
+ it 'returns the board details' do
222
+ subject.must_equal " \e[35m\e[4m(1) \e[0m\e[35m\e[4mMy " \
223
+ "Test Board\e[0m\n"
224
+ end
225
+ end
226
+
227
+ describe '#list' do
228
+ subject { described_class.new(@card).list }
229
+
230
+ it 'returns the list details' do
231
+ subject.must_equal " \e[35m\e[4m(1) \e[0m\e[35m\e[4mMy " \
232
+ "Test List\e[0m\n"
233
+ end
234
+ end
235
+ end
236
+ end
237
+ end
@@ -0,0 +1,74 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ module Troo
4
+ module Decorators
5
+ describe Comment do
6
+ let(:described_class) { Comment }
7
+ let(:default) { true }
8
+ let(:options) { {} }
9
+
10
+ before do
11
+ @comment = Fabricate(:comment)
12
+ @member = Fabricate(:member)
13
+ end
14
+
15
+ after { database_cleanup }
16
+
17
+ describe '#initialize' do
18
+ subject { described_class.new(@comment, options) }
19
+
20
+ it 'assigns the comment to an instance variable' do
21
+ subject.instance_variable_get('@comment')
22
+ .must_equal(@comment)
23
+ end
24
+
25
+ it 'assigns the options to an instance variable' do
26
+ subject.instance_variable_get('@options')
27
+ .must_equal(options)
28
+ end
29
+ end
30
+
31
+ describe '#as_view' do
32
+ subject { described_class.new(@comment).as_view }
33
+
34
+ it 'returns the rendered comment' do
35
+ subject.must_match(/gavinlaking1/)
36
+ subject.must_match(/My Test Comment/)
37
+ subject.must_match(/Tue, Dec 17 at 22:01/)
38
+ end
39
+ end
40
+
41
+ describe '#member_username' do
42
+ subject { described_class.new(@comment).member_username }
43
+
44
+ it 'returns the comment member username' do
45
+ subject.must_equal(@comment.member.username + ':')
46
+ end
47
+ end
48
+
49
+ describe '#text' do
50
+ subject { described_class.new(@comment).text }
51
+
52
+ it 'returns the comment text' do
53
+ subject.must_equal(@comment.text)
54
+ end
55
+ end
56
+
57
+ describe '#date' do
58
+ subject { described_class.new(@comment).date }
59
+
60
+ it 'returns the comment date' do
61
+ subject.must_equal('Tue, Dec 17 at 22:01')
62
+ end
63
+ end
64
+
65
+ describe '#id' do
66
+ subject { described_class.new(@comment).id }
67
+
68
+ it 'returns the comment id' do
69
+ subject.must_equal("(#{@comment.id})")
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end