troo 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
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,102 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ module Troo
4
+ module Decorators
5
+ describe List do
6
+ let(:described_class) { List }
7
+ let(:default) { true }
8
+ let(:options) { {} }
9
+
10
+ before { @list = Fabricate(:list, default: default) }
11
+ after { database_cleanup }
12
+
13
+ describe '#initialize' do
14
+ subject { described_class.new(@list, options) }
15
+
16
+ it 'assigns the list to an instance variable' do
17
+ subject.instance_variable_get('@list').must_equal(@list)
18
+ end
19
+
20
+ it 'assigns the options to an instance variable' do
21
+ subject.instance_variable_get('@options')
22
+ .must_equal(options)
23
+ end
24
+ end
25
+
26
+ describe '#short' do
27
+ subject { described_class.new(@list, options).short }
28
+
29
+ it 'returns a one line overview of the list' do
30
+ subject.must_equal(" * \e[32m\e[4m(1) \e[0m\e[32m\e[4mMy " \
31
+ "Test List\e[0m\n")
32
+ end
33
+
34
+ context 'when the ansicolor option is false' do
35
+ let(:options) { { ansicolor: false } }
36
+
37
+ it 'returns a one line overview of the board' do
38
+ subject.must_equal(" * (1) My Test List\n")
39
+ end
40
+ end
41
+ end
42
+
43
+ describe '#name_str' do
44
+ subject { described_class.new(@list).name_str }
45
+
46
+ it 'returns the formatted list name' do
47
+ subject.must_equal("\e[32m\e[4mMy Test List\e[0m")
48
+ end
49
+ end
50
+
51
+ describe '#default_str' do
52
+ subject { described_class.new(@list).default_str }
53
+
54
+ it 'returns the formatted card default indicator' do
55
+ subject.must_equal(' * ')
56
+ end
57
+ end
58
+
59
+ describe '#id_str' do
60
+ subject { described_class.new(@list).id_str }
61
+
62
+ it 'returns the formatted list id' do
63
+ subject.must_equal("\e[32m\e[4m(1) \e[0m")
64
+ end
65
+ end
66
+
67
+ describe '#name' do
68
+ subject { described_class.new(@list).name }
69
+
70
+ it 'returns the list name' do
71
+ subject.must_equal(@list.name)
72
+ end
73
+ end
74
+
75
+ describe '#default' do
76
+ subject { described_class.new(@list).default }
77
+
78
+ context 'when default' do
79
+ it 'return an indicator' do
80
+ subject.must_equal('*')
81
+ end
82
+ end
83
+
84
+ context 'when not default' do
85
+ let(:default) { false }
86
+
87
+ it 'returns nothing' do
88
+ subject.must_equal('')
89
+ end
90
+ end
91
+ end
92
+
93
+ describe '#id' do
94
+ subject { described_class.new(@list).id }
95
+
96
+ it 'returns the list id' do
97
+ subject.must_equal(@list.id.to_s)
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,50 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ module Troo
4
+ module Decorators
5
+ describe Member do
6
+ let(:described_class) { Member }
7
+ let(:options) { {} }
8
+
9
+ before { @member = Fabricate(:member) }
10
+ after { database_cleanup }
11
+
12
+ describe '#initialize' do
13
+ subject { described_class.new(@member, options) }
14
+
15
+ it 'assigns the member to an instance variable' do
16
+ subject.instance_variable_get('@member').must_equal(@member)
17
+ end
18
+
19
+ it 'assigns the options to an instance variable' do
20
+ subject.instance_variable_get('@options')
21
+ .must_equal(options)
22
+ end
23
+ end
24
+
25
+ describe '#username' do
26
+ subject { described_class.new(@member).username }
27
+
28
+ it "returns the member's username" do
29
+ subject.must_equal("@#{@member.username}")
30
+ end
31
+ end
32
+
33
+ describe '#name' do
34
+ subject { described_class.new(@member).name }
35
+
36
+ it "returns the member's full name" do
37
+ subject.must_equal(@member.full_name)
38
+ end
39
+ end
40
+
41
+ describe '#initials' do
42
+ subject { described_class.new(@member).initials }
43
+
44
+ it "returns the member's initials" do
45
+ subject.must_equal(@member.initials)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,66 +1,99 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  module Troo
4
4
  module External
5
5
  describe Board do
6
6
  let(:described_class) { Board }
7
- let(:board_id) { "526d8e130a14a9d846001d96" }
8
- let(:options) { { } }
7
+ let(:board_id) { '526d8e130a14a9d846001d96' }
8
+ let(:options) { {} }
9
9
 
10
- describe ".initialize" do
11
- subject { described_class.new(board_id, options) }
10
+ describe '.fetch' do
11
+ subject { described_class.fetch(board_id, options) }
12
12
 
13
- it "assigns the external_id" do
14
- subject.instance_variable_get("@external_id").must_equal(board_id)
15
- end
13
+ context 'when the all option is set' do
14
+ let(:options) { { mode: :all } }
16
15
 
17
- it "assigns the options" do
18
- subject.instance_variable_get("@options").must_equal(options)
19
- end
20
- end
16
+ before do
17
+ VCR.insert_cassette(:boards_all,
18
+ decode_compressed_response: true)
19
+ end
20
+ after { VCR.eject_cassette }
21
21
 
22
- describe ".fetch" do
23
- before { VCR.insert_cassette(:board_by_id, decode_compressed_response: true) }
24
- after { VCR.eject_cassette }
22
+ it 'returns multiple boards' do
23
+ subject.size.must_equal(1)
24
+ end
25
25
 
26
- subject { described_class.fetch(board_id, options) }
26
+ context 'when no boards can be found' do
27
+ before { Trello::Board.stubs(:all).raises(Trello::Error) }
27
28
 
28
- it "returns a single board" do
29
- subject.size.must_equal(1)
30
- end
29
+ it 'returns an empty collection' do
30
+ subject.must_equal([])
31
+ end
32
+ end
31
33
 
32
- it "returns a board with the board_id" do
33
- subject.first.external_board_id.must_equal(board_id)
34
- end
34
+ context 'and the option is :list' do
35
+ let(:options) { { mode: :list } }
35
36
 
36
- it "returns a board with the correct name" do
37
- subject.first.name.must_equal("Troo App")
38
- end
37
+ it 'returns an empty collection' do
38
+ subject.must_equal([])
39
+ end
40
+ end
41
+
42
+ context 'and the option is :card' do
43
+ let(:options) { { mode: :card } }
39
44
 
40
- context "when the board cannot be found" do
41
- before { Trello::Board.stubs(:find).raises(Trello::Error) }
45
+ it 'returns an empty collection' do
46
+ subject.must_equal([])
47
+ end
48
+ end
49
+
50
+ context 'and the option is :member' do
51
+ let(:options) { { mode: :member } }
42
52
 
43
- it "returns an empty collection" do
44
- subject.must_equal([])
53
+ it 'returns an empty collection' do
54
+ subject.must_equal([])
55
+ end
45
56
  end
46
57
  end
47
- end
48
58
 
49
- describe ".fetch_all" do
50
- before { VCR.insert_cassette(:boards_all, decode_compressed_response: true) }
51
- after { VCR.eject_cassette }
59
+ context 'when the all option is not set' do
60
+ before do
61
+ VCR.insert_cassette(:board_by_id,
62
+ decode_compressed_response: true)
63
+ end
64
+ after { VCR.eject_cassette }
52
65
 
53
- subject { described_class.fetch_all }
66
+ it 'returns a single board' do
67
+ subject.size.must_equal(1)
68
+ end
54
69
 
55
- it "returns multiple boards" do
56
- subject.size.must_equal(1)
57
- end
70
+ it 'returns a board with the board_id' do
71
+ subject.first.external_board_id.must_equal(board_id)
72
+ end
73
+
74
+ it 'returns a board with the correct name' do
75
+ subject.first.name.must_equal('Troo App')
76
+ end
77
+
78
+ context 'when the board cannot be found' do
79
+ before { Trello::Board.stubs(:find).raises(Trello::Error) }
80
+
81
+ it 'returns an empty collection' do
82
+ subject.must_equal([])
83
+ end
84
+ end
85
+
86
+ context 'when the access token is invalid' do
87
+ before do
88
+ Trello::Board.stubs(:find)
89
+ .raises(Trello::InvalidAccessToken)
90
+ end
58
91
 
59
- context "when no boards can be found" do
60
- before { Trello::Board.stubs(:all).raises(Trello::Error) }
92
+ subject { described_class.new(board_id, options).fetch }
61
93
 
62
- it "returns an empty collection" do
63
- subject.must_equal([])
94
+ it 'catches the exception and re-raises' do
95
+ proc { subject }.must_raise(Troo::InvalidAccessToken)
96
+ end
64
97
  end
65
98
  end
66
99
  end
@@ -1,116 +1,128 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  module Troo
4
4
  module External
5
5
  describe Card do
6
6
  let(:described_class) { Card }
7
- let(:card_id) { "526d8f19ddb279532e005259" }
7
+ let(:card_id) { '526d8f19ddb279532e005259' }
8
8
  let(:options) { {} }
9
9
 
10
10
  before { @card = Fabricate(:card) }
11
11
  after { database_cleanup }
12
12
 
13
- describe ".initialize" do
14
- subject { described_class.new("some_id", options) }
15
-
16
- it "assigns the external_id" do
17
- subject.instance_variable_get("@external_id").must_equal("some_id")
18
- end
19
-
20
- it "assigns the options" do
21
- subject.instance_variable_get("@options").must_equal(options)
13
+ describe 'when the mode is board' do
14
+ before do
15
+ VCR.insert_cassette(:cards_by_board_id,
16
+ decode_compressed_response: true)
22
17
  end
23
- end
24
-
25
- describe "when the mode is board" do
26
- before { VCR.insert_cassette(:cards_by_board_id, decode_compressed_response: true) }
27
18
  after { VCR.eject_cassette }
28
19
 
29
- let(:board_id) { "526d8e130a14a9d846001d96" }
20
+ let(:board_id) { '526d8e130a14a9d846001d96' }
30
21
  let(:options) { { mode: :board, comments: false } }
31
22
 
32
23
  subject { described_class.fetch(board_id, options) }
33
24
 
34
- it "returns multiple cards" do
25
+ it 'returns multiple cards' do
35
26
  subject.size.must_equal(2)
36
27
  end
37
28
 
38
- context "when the board cannot be found" do
29
+ context 'when the board cannot be found' do
39
30
  before { Trello::Board.stubs(:find).raises(Trello::Error) }
40
31
 
41
- it "returns an empty collection" do
32
+ it 'returns an empty collection' do
42
33
  subject.must_equal([])
43
34
  end
44
35
  end
36
+
37
+ context 'when the access token is invalid' do
38
+ before do
39
+ Trello::Board.stubs(:find)
40
+ .raises(Trello::InvalidAccessToken)
41
+ end
42
+
43
+ subject { described_class.new(board_id, options).fetch }
44
+
45
+ it 'catches the exception and re-raises' do
46
+ proc { subject }.must_raise(Troo::InvalidAccessToken)
47
+ end
48
+ end
45
49
  end
46
50
 
47
- describe "when the mode is list" do
48
- before { VCR.insert_cassette(:cards_by_list_id, decode_compressed_response: true) }
51
+ describe 'when the mode is list' do
52
+ before do
53
+ VCR.insert_cassette(:cards_by_list_id,
54
+ decode_compressed_response: true)
55
+ end
49
56
  after { VCR.eject_cassette }
50
57
 
51
- let(:list_id) { "526d8e130a14a9d846001d97" }
58
+ let(:list_id) { '526d8e130a14a9d846001d97' }
52
59
  let(:options) { { mode: :list, comments: false } }
53
60
 
54
61
  subject { described_class.fetch(list_id, options) }
55
62
 
56
- it "returns multiple cards" do
63
+ it 'returns multiple cards' do
57
64
  subject.size.must_equal(1)
58
65
  end
59
66
 
60
- context "when the list cannot be found" do
67
+ context 'when the list cannot be found' do
61
68
  before { Trello::List.stubs(:find).raises(Trello::Error) }
62
69
 
63
- it "returns an empty collection" do
70
+ it 'returns an empty collection' do
64
71
  subject.must_equal([])
65
72
  end
66
73
  end
67
74
  end
68
75
 
69
- describe "when the mode is card" do
70
- before { VCR.insert_cassette(:card_by_card_id, decode_compressed_response: true) }
76
+ describe 'when the mode is card' do
77
+ before do
78
+ VCR.insert_cassette(:card_by_card_id,
79
+ decode_compressed_response: true)
80
+ end
71
81
  after { VCR.eject_cassette }
72
82
 
73
- let(:card_id) { "526d8f19ddb279532e005259" }
83
+ let(:card_id) { '526d8f19ddb279532e005259' }
74
84
  let(:options) { { mode: :card, comments: false } }
75
85
 
76
86
  subject { described_class.fetch(card_id, options) }
77
87
 
78
- it "returns a single card" do
88
+ it 'returns a single card' do
79
89
  subject.size.must_equal(1)
80
90
  end
81
91
 
82
- context "when the card cannot be found" do
92
+ context 'when the card cannot be found' do
83
93
  before { Trello::Card.stubs(:find).raises(Trello::Error) }
84
94
 
85
- it "returns an empty collection" do
95
+ it 'returns an empty collection' do
86
96
  subject.must_equal([])
87
97
  end
88
98
  end
89
99
  end
90
100
 
91
- describe "when the comments options is enabled" do
101
+ describe 'when the comments options is enabled' do
92
102
  before do
93
103
  Trello::Card.stubs(:find).returns(resource)
94
104
  External::Comment.stubs(:fetch)
95
105
  end
96
106
 
97
- let(:resource) { OpenStruct.new(id: "526d8f19ddb279532e005259") }
107
+ let(:resource) do
108
+ OpenStruct.new(id: '526d8f19ddb279532e005259')
109
+ end
98
110
  let(:options) { { mode: :card, comments: true } }
99
111
 
100
112
  subject { described_class.fetch(card_id, options) }
101
113
 
102
- it "fetches the comments for the card" do
114
+ it 'fetches the comments for the card' do
103
115
  subject.size.must_equal(1)
104
116
  end
105
117
  end
106
118
 
107
- describe "when the mode is member" do
108
- let(:member_id) { "5195fdb5a8c01a2318004f5d" }
119
+ describe 'when the mode is member' do
120
+ let(:member_id) { '5195fdb5a8c01a2318004f5d' }
109
121
  let(:options) { { mode: :member, comments: false } }
110
122
 
111
123
  subject { described_class.fetch(member_id, options) }
112
124
 
113
- it "returns an empty collection" do
125
+ it 'returns an empty collection' do
114
126
  subject.must_equal([])
115
127
  end
116
128
  end
@@ -1,4 +1,4 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  module Troo
4
4
  module External
@@ -6,91 +6,101 @@ module Troo
6
6
  let(:described_class) { Comment }
7
7
  let(:options) { {} }
8
8
 
9
- describe ".initialize" do
10
- subject { described_class.new("some_id", options) }
11
-
12
- it "assigns the external_id" do
13
- subject.instance_variable_get("@external_id").must_equal("some_id")
14
- end
15
-
16
- it "assigns the options" do
17
- subject.instance_variable_get("@options").must_equal(options)
9
+ describe 'when the mode is board' do
10
+ before do
11
+ VCR.insert_cassette(:comments_by_board_id,
12
+ decode_compressed_response: true)
18
13
  end
19
- end
20
-
21
- describe "when the mode is board" do
22
- before { VCR.insert_cassette(:comments_by_board_id, decode_compressed_response: true) }
23
14
  after { VCR.eject_cassette }
24
15
 
25
- let(:board_id) { "526d8e130a14a9d846001d96" }
16
+ let(:board_id) { '526d8e130a14a9d846001d96' }
26
17
  let(:options) { { mode: :board } }
27
18
 
28
19
  subject { described_class.fetch(board_id, options) }
29
20
 
30
- it "returns multiple comments" do
21
+ it 'returns multiple comments' do
31
22
  subject.size.must_equal(2)
32
23
  end
33
24
 
34
- context "when the board cannot be found" do
25
+ context 'when the board cannot be found' do
35
26
  before { Trello::Board.stubs(:find).raises(Trello::Error) }
36
27
 
37
- it "returns an empty collection" do
28
+ it 'returns an empty collection' do
38
29
  subject.must_equal([])
39
30
  end
40
31
  end
32
+
33
+ context 'when the access token is invalid' do
34
+ before do
35
+ Trello::Board.stubs(:find)
36
+ .raises(Trello::InvalidAccessToken)
37
+ end
38
+
39
+ subject { described_class.new(board_id, options).fetch }
40
+
41
+ it 'catches the exception and re-raises' do
42
+ proc { subject }.must_raise(Troo::InvalidAccessToken)
43
+ end
44
+ end
41
45
  end
42
46
 
43
- describe "when the mode is list" do
44
- before { VCR.insert_cassette(:comments_by_list_id, decode_compressed_response: true) }
47
+ describe 'when the mode is list' do
48
+ before do
49
+ VCR.insert_cassette(:comments_by_list_id,
50
+ decode_compressed_response: true)
51
+ end
45
52
  after { VCR.eject_cassette }
46
53
 
47
- let(:list_id) { "526d8e130a14a9d846001d97" }
54
+ let(:list_id) { '526d8e130a14a9d846001d97' }
48
55
  let(:options) { { mode: :list } }
49
56
 
50
57
  subject { described_class.fetch(list_id, options) }
51
58
 
52
- it "returns comments with the list_id" do
59
+ it 'returns comments with the list_id' do
53
60
  subject.size.must_equal(0)
54
61
  end
55
62
 
56
- context "when the list cannot be found" do
63
+ context 'when the list cannot be found' do
57
64
  before { Trello::List.stubs(:find).raises(Trello::Error) }
58
65
 
59
- it "returns an empty collection" do
66
+ it 'returns an empty collection' do
60
67
  subject.must_equal([])
61
68
  end
62
69
  end
63
70
  end
64
71
 
65
- describe "when the mode is card" do
66
- before { VCR.insert_cassette(:comments_by_card_id, decode_compressed_response: true) }
72
+ describe 'when the mode is card' do
73
+ before do
74
+ VCR.insert_cassette(:comments_by_card_id,
75
+ decode_compressed_response: true)
76
+ end
67
77
  after { VCR.eject_cassette }
68
78
 
69
- let(:card_id) { "526d8f19ddb279532e005259" }
79
+ let(:card_id) { '526d8f19ddb279532e005259' }
70
80
  let(:options) { { mode: :card } }
71
81
 
72
82
  subject { described_class.fetch(card_id, options) }
73
83
 
74
- it "returns a comment with the card_id" do
84
+ it 'returns a comment with the card_id' do
75
85
  subject.size.must_equal(2)
76
86
  end
77
87
 
78
- context "when the card cannot be found" do
88
+ context 'when the card cannot be found' do
79
89
  before { Trello::Card.stubs(:find).raises(Trello::Error) }
80
90
 
81
- it "returns an empty collection" do
91
+ it 'returns an empty collection' do
82
92
  subject.must_equal([])
83
93
  end
84
94
  end
85
95
  end
86
96
 
87
- describe "when the mode is member" do
88
- let(:member_id) { "5195fdb5a8c01a2318004f5d" }
97
+ describe 'when the mode is member' do
98
+ let(:member_id) { '5195fdb5a8c01a2318004f5d' }
89
99
  let(:options) { { mode: :member } }
90
100
 
91
101
  subject { described_class.fetch(member_id, options) }
92
102
 
93
- it "returns an empty collection" do
103
+ it 'returns an empty collection' do
94
104
  subject.must_equal([])
95
105
  end
96
106
  end