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
@@ -1,84 +1,91 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  module Troo
4
4
  module External
5
5
  describe List do
6
6
  let(:described_class) { List }
7
7
 
8
- describe ".initialize" do
9
- subject { described_class.new("some_id", {}) }
10
-
11
- it "assigns the external_id" do
12
- subject.instance_variable_get("@external_id").must_equal "some_id"
13
- end
14
-
15
- it "assigns the options" do
16
- subject.instance_variable_get("@options").must_equal({})
8
+ describe 'when the mode is board' do
9
+ before do
10
+ VCR.insert_cassette(:lists_by_board_id,
11
+ decode_compressed_response: true)
17
12
  end
18
- end
19
-
20
- describe "when the mode is board" do
21
- before { VCR.insert_cassette(:lists_by_board_id, decode_compressed_response: true) }
22
13
  after { VCR.eject_cassette }
23
14
 
24
- let(:board_id) { "526d8e130a14a9d846001d96" }
15
+ let(:board_id) { '526d8e130a14a9d846001d96' }
25
16
  let(:options) { { mode: :board } }
26
17
 
27
18
  subject { described_class.fetch(board_id, options) }
28
19
 
29
- it "returns multiple lists" do
20
+ it 'returns multiple lists' do
30
21
  subject.size.must_equal(4)
31
22
  end
32
23
 
33
- context "when the board cannot be found" do
24
+ context 'when the board cannot be found' do
34
25
  before { Trello::Board.stubs(:find).raises(Trello::Error) }
35
26
 
36
- it "returns an empty collection" do
27
+ it 'returns an empty collection' do
37
28
  subject.must_equal([])
38
29
  end
39
30
  end
31
+
32
+ context 'when the access token is invalid' do
33
+ before do
34
+ Trello::Board.stubs(:find)
35
+ .raises(Trello::InvalidAccessToken)
36
+ end
37
+
38
+ subject { described_class.new(board_id, options).fetch }
39
+
40
+ it 'catches the exception and re-raises' do
41
+ proc { subject }.must_raise(Troo::InvalidAccessToken)
42
+ end
43
+ end
40
44
  end
41
45
 
42
- describe "when the mode is list" do
43
- before { VCR.insert_cassette(:list_by_list_id, decode_compressed_response: true) }
46
+ describe 'when the mode is list' do
47
+ before do
48
+ VCR.insert_cassette(:list_by_list_id,
49
+ decode_compressed_response: true)
50
+ end
44
51
  after { VCR.eject_cassette }
45
52
 
46
- let(:list_id) { "526d8e130a14a9d846001d97" }
53
+ let(:list_id) { '526d8e130a14a9d846001d97' }
47
54
  let(:options) { { mode: :list } }
48
55
 
49
56
  subject { described_class.fetch(list_id, options) }
50
57
 
51
- it "returns a list with the list_id" do
58
+ it 'returns a list with the list_id' do
52
59
  subject.size.must_equal(1)
53
60
  end
54
61
 
55
- context "when the list cannot be found" do
62
+ context 'when the list cannot be found' do
56
63
  before { Trello::List.stubs(:find).raises(Trello::Error) }
57
64
 
58
- it "returns an empty collection" do
65
+ it 'returns an empty collection' do
59
66
  subject.must_equal([])
60
67
  end
61
68
  end
62
69
  end
63
70
 
64
- describe "when the mode is card" do
65
- let(:card_id) { "526d8f19ddb279532e005259" }
71
+ describe 'when the mode is card' do
72
+ let(:card_id) { '526d8f19ddb279532e005259' }
66
73
  let(:options) { { mode: :card } }
67
74
 
68
75
  subject { described_class.fetch(card_id, options) }
69
76
 
70
- it "returns an empty collection" do
77
+ it 'returns an empty collection' do
71
78
  subject.must_equal([])
72
79
  end
73
80
  end
74
81
 
75
- describe "when the mode is member" do
76
- let(:member_id) { "5195fdb5a8c01a2318004f5d" }
82
+ describe 'when the mode is member' do
83
+ let(:member_id) { '5195fdb5a8c01a2318004f5d' }
77
84
  let(:options) { { mode: :member } }
78
85
 
79
86
  subject { described_class.fetch(member_id, options) }
80
87
 
81
- it "returns an empty collection" do
88
+ it 'returns an empty collection' do
82
89
  subject.must_equal([])
83
90
  end
84
91
  end
@@ -1,83 +1,90 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  module Troo
4
4
  module External
5
5
  describe Member do
6
6
  let(:described_class) { Member }
7
7
 
8
- describe ".initialize" do
9
- subject { described_class.new("some_id", {}) }
10
-
11
- it "assigns the external_id" do
12
- subject.instance_variable_get("@external_id").must_equal("some_id")
13
- end
14
-
15
- it "assigns the options" do
16
- subject.instance_variable_get("@options").must_equal({})
8
+ describe 'when the mode is board' do
9
+ before do
10
+ VCR.insert_cassette(:members_by_board_id,
11
+ decode_compressed_response: true)
17
12
  end
18
- end
19
-
20
- describe "when the mode is board" do
21
- before { VCR.insert_cassette(:members_by_board_id, decode_compressed_response: true) }
22
13
  after { VCR.eject_cassette }
23
14
 
24
- let(:board_id) { "526d8e130a14a9d846001d96" }
15
+ let(:board_id) { '526d8e130a14a9d846001d96' }
25
16
  let(:options) { { mode: :board } }
26
17
 
27
18
  subject { described_class.fetch(board_id, options) }
28
19
 
29
- it "returns multiple members" do
20
+ it 'returns multiple members' do
30
21
  subject.size.must_equal(1)
31
22
  end
32
23
 
33
- context "when the board cannot be found" do
24
+ context 'when the board cannot be found' do
34
25
  before { Trello::Board.stubs(:find).raises(Trello::Error) }
35
26
 
36
- it "returns an empty collection" do
27
+ it 'returns an empty collection' do
37
28
  subject.must_equal([])
38
29
  end
39
30
  end
31
+
32
+ context 'when the access token is invalid' do
33
+ before do
34
+ Trello::Board.stubs(:find)
35
+ .raises(Trello::InvalidAccessToken)
36
+ end
37
+
38
+ subject { described_class.new(board_id, options).fetch }
39
+
40
+ it 'catches the exception and re-raises' do
41
+ proc { subject }.must_raise(Troo::InvalidAccessToken)
42
+ end
43
+ end
40
44
  end
41
45
 
42
- describe "when the mode is list" do
43
- let(:list_id) { "526d8e130a14a9d846001d97" }
46
+ describe 'when the mode is list' do
47
+ let(:list_id) { '526d8e130a14a9d846001d97' }
44
48
  let(:options) { { mode: :list } }
45
49
 
46
50
  subject { described_class.fetch(list_id, options) }
47
51
 
48
- it "returns an empty collection" do
52
+ it 'returns an empty collection' do
49
53
  subject.must_equal([])
50
54
  end
51
55
  end
52
56
 
53
- describe "when the mode is card" do
54
- let(:card_id) { "526d8f19ddb279532e005259" }
57
+ describe 'when the mode is card' do
58
+ let(:card_id) { '526d8f19ddb279532e005259' }
55
59
  let(:options) { { mode: :card } }
56
60
 
57
61
  subject { described_class.fetch(card_id, options) }
58
62
 
59
- it "returns an empty collection" do
63
+ it 'returns an empty collection' do
60
64
  subject.must_equal([])
61
65
  end
62
66
  end
63
67
 
64
- describe "when the mode is member" do
65
- before { VCR.insert_cassette(:member_by_member_id, decode_compressed_response: true) }
68
+ describe 'when the mode is member' do
69
+ before do
70
+ VCR.insert_cassette(:member_by_member_id,
71
+ decode_compressed_response: true)
72
+ end
66
73
  after { VCR.eject_cassette }
67
74
 
68
- let(:member_id) { "5195fdb5a8c01a2318004f5d" }
75
+ let(:member_id) { '5195fdb5a8c01a2318004f5d' }
69
76
  let(:options) { { mode: :member } }
70
77
 
71
78
  subject { described_class.fetch(member_id, options) }
72
79
 
73
- it "returns a member with the member_id" do
80
+ it 'returns a member with the member_id' do
74
81
  subject.size.must_equal(1)
75
82
  end
76
83
 
77
- context "when the member cannot be found" do
84
+ context 'when the member cannot be found' do
78
85
  before { Trello::Member.stubs(:find).raises(Trello::Error) }
79
86
 
80
- it "returns an empty collection" do
87
+ it 'returns an empty collection' do
81
88
  subject.must_equal([])
82
89
  end
83
90
  end
@@ -1,8 +1,25 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  module Troo
4
4
  module External
5
5
  describe Resource do
6
+ let(:described_class) { Resource }
7
+ let(:external_id) { '526d8e130a14a9d846001d96' }
8
+ let(:options) { {} }
9
+
10
+ describe '.initialize' do
11
+ subject { described_class.new(external_id, options) }
12
+
13
+ it 'assigns the external_id to an instance variable' do
14
+ subject.instance_variable_get('@external_id')
15
+ .must_equal(external_id)
16
+ end
17
+
18
+ it 'assigns the options to an instance variable' do
19
+ subject.instance_variable_get('@options')
20
+ .must_equal(options)
21
+ end
22
+ end
6
23
  end
7
24
  end
8
25
  end
@@ -0,0 +1,82 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ class CommandHelpersDummy
4
+ include Troo::CommandHelpers
5
+
6
+ def initialize(type, id)
7
+ @type, @id = type, id
8
+ end
9
+
10
+ private
11
+
12
+ attr_accessor :type
13
+ end
14
+
15
+ module Troo
16
+ describe CommandHelpers do
17
+ let(:described_class) { CommandHelpersDummy }
18
+ let(:described_instance) { described_class.new(type, id) }
19
+ let(:type) { :board }
20
+ let(:id) { nil }
21
+
22
+ describe '#error_no_default' do
23
+ subject { described_instance.error_no_default }
24
+
25
+ context 'when the type is comments' do
26
+ let(:type) { :comments }
27
+
28
+ it 'returns the no default set error message' do
29
+ subject.must_match(/to set a default card first/)
30
+ end
31
+ end
32
+
33
+ context 'when the type is not comments' do
34
+ it 'returns the no default set error message' do
35
+ subject.must_match(/to set a default board first/)
36
+ end
37
+ end
38
+ end
39
+
40
+ describe '#error_not_found' do
41
+ subject { described_instance.error_not_found }
42
+
43
+ context 'when the type is comments' do
44
+ let(:type) { :comments }
45
+
46
+ it 'returns the not found error message' do
47
+ subject.must_match(/Card cannot be found/)
48
+ end
49
+ end
50
+
51
+ context 'when the type is not comments' do
52
+ it 'returns the no default set error message' do
53
+ subject.must_match(/Board cannot be found/)
54
+ end
55
+ end
56
+ end
57
+
58
+ describe '#type_str' do
59
+ subject { described_instance.type_str }
60
+
61
+ it 'returns the type as a string' do
62
+ subject.must_equal('board')
63
+ end
64
+ end
65
+
66
+ describe '#type_capitalize' do
67
+ subject { described_instance.type_capitalize }
68
+
69
+ it 'returns the type as a capitalized string' do
70
+ subject.must_equal('Board')
71
+ end
72
+ end
73
+
74
+ describe '#type_pluralize' do
75
+ subject { described_instance.type_pluralize }
76
+
77
+ it 'returns the type as a pluralized string' do
78
+ subject.must_equal('boards')
79
+ end
80
+ end
81
+ end
82
+ end
@@ -1,4 +1,4 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  class DecoratorHelpersDummy
4
4
  include Troo::DecoratorHelpers
@@ -9,18 +9,18 @@ module Troo
9
9
  let(:described_class) { DecoratorHelpersDummy }
10
10
  let(:described_instance) { described_class.new }
11
11
 
12
- describe "#title" do
12
+ describe '#title' do
13
13
  before do
14
- described_instance.stubs(:default).returns("*")
14
+ described_instance.stubs(:default).returns('*')
15
15
  described_instance.stubs(:id).returns(67)
16
- described_instance.stubs(:name).returns("My Test Dummy")
16
+ described_instance.stubs(:name).returns('My Test Dummy')
17
17
  described_instance.stubs(:options).returns({})
18
18
  end
19
19
 
20
20
  subject { described_instance.title }
21
21
 
22
- it "returns a formatted string representing the card title" do
23
- subject.must_match /\* \(67\) My Test Dummy/
22
+ it 'returns a formatted string representing the card title' do
23
+ subject.must_match(/\* \(67\) My Test Dummy/)
24
24
  end
25
25
  end
26
26
  end
@@ -0,0 +1,103 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ class ModelHelpersDummy < Ohm::Model
4
+ include Troo::ModelHelpers
5
+
6
+ attribute :name
7
+ attribute :default
8
+
9
+ index :name
10
+ index :default
11
+ end
12
+
13
+ module Troo
14
+ describe ModelHelpersDummy do
15
+ let(:described_class) { ModelHelpersDummy }
16
+
17
+ before do
18
+ @dumb = ModelHelpersDummy.create(
19
+ name: 'My Dumb Model',
20
+ default: false)
21
+ @dumber = ModelHelpersDummy.create(
22
+ name: 'My Dumber Model',
23
+ default: true)
24
+ end
25
+
26
+ after { database_cleanup }
27
+
28
+ describe '.first' do
29
+ subject { described_class.first(criteria) }
30
+
31
+ context 'when no criteria are provided' do
32
+ let(:criteria) {}
33
+
34
+ it 'returns the first model stored of that type' do
35
+ subject.name.must_equal('My Dumb Model')
36
+ end
37
+ end
38
+
39
+ context 'when criteria are provided' do
40
+ let(:criteria) { { name: 'My Dumber Model' } }
41
+
42
+ it 'returns the first model matching the criteria' do
43
+ subject.name.must_equal('My Dumber Model')
44
+ end
45
+ end
46
+ end
47
+
48
+ describe '.update' do
49
+ subject { described_class.update(criteria) }
50
+
51
+ context 'when no criteria are provided' do
52
+ let(:criteria) {}
53
+
54
+ it 'returns false; no update was performed' do
55
+ subject.must_equal(false)
56
+ end
57
+ end
58
+
59
+ context 'when criteria are provided' do
60
+ let(:criteria) { { name: 'My Updated Model' } }
61
+
62
+ it 'updates all records with the criteria' do
63
+ subject.must_equal(true)
64
+ ModelHelpersDummy.all.each do |dummy|
65
+ dummy.name.must_equal('My Updated Model')
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ describe '.default' do
72
+ subject { described_class.default }
73
+
74
+ context 'when there is no default model' do
75
+ it 'returns the model' do
76
+ subject.must_equal(@dumber)
77
+ end
78
+ end
79
+
80
+ context 'when there is a default model' do
81
+ before { @dumber.delete }
82
+
83
+ it { subject.must_equal(nil) }
84
+ end
85
+ end
86
+
87
+ describe '.count' do
88
+ subject { described_class.count }
89
+
90
+ it 'returns the number of this model persisted' do
91
+ subject.must_equal(2)
92
+ end
93
+ end
94
+
95
+ describe '#external_attributes' do
96
+ subject { @dumb.external_attributes }
97
+
98
+ it 'returns the attributes of the model which Trello affects' do
99
+ subject.must_equal(name: 'My Dumb Model')
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,54 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ describe Behaviours::NullEntity do
5
+ let(:described_class) { Behaviours::NullEntity }
6
+
7
+ describe '#default?' do
8
+ subject { described_class.new.default? }
9
+
10
+ it { subject.must_equal false }
11
+ end
12
+ end
13
+
14
+ describe Behaviours::SetDefault do
15
+ let(:described_class) { Behaviours::SetDefault }
16
+
17
+ describe '.initialize' do
18
+ let(:entity) { :some_model }
19
+
20
+ subject { described_class.new(entity) }
21
+
22
+ it 'assigns the entity to an instance variable' do
23
+ subject.instance_variable_get('@entity').must_equal(entity)
24
+ end
25
+ end
26
+
27
+ describe '#set_default!' do
28
+ before do
29
+ @board_1 = Fabricate(:board, default: true)
30
+ @board_2 = Fabricate(:board, default: false)
31
+ end
32
+
33
+ after { database_cleanup }
34
+
35
+ subject { described_class.for(entity) }
36
+
37
+ context 'when the entity is already the default' do
38
+ let(:entity) { @board_1 }
39
+
40
+ it { subject.must_equal true }
41
+ end
42
+
43
+ context 'when the entity is not already the default' do
44
+ let(:entity) { @board_2 }
45
+
46
+ it 'sets the specified entity to be the default' do
47
+ subject.default.must_equal(true)
48
+
49
+ subject.must_equal(@board_2)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,4 +1,4 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  module Troo
4
4
  describe Board do
@@ -7,29 +7,29 @@ module Troo
7
7
 
8
8
  subject { described_instance }
9
9
 
10
- context "attributes" do
11
- it "should have a name attribute" do
12
- subject.name.must_equal "My Test Board"
10
+ context 'attributes' do
11
+ it 'should have a name attribute' do
12
+ subject.name.must_equal 'My Test Board'
13
13
  end
14
14
 
15
- it "should have a description attribute" do
16
- subject.description.must_equal "A very brief description..."
15
+ it 'should have a description attribute' do
16
+ subject.description.must_equal 'A very brief description...'
17
17
  end
18
18
 
19
- it "should have a default attribute" do
19
+ it 'should have a default attribute' do
20
20
  subject.default.must_equal false
21
21
  end
22
22
 
23
- it "should have a closed attribute" do
23
+ it 'should have a closed attribute' do
24
24
  subject.closed.must_equal false
25
25
  end
26
26
 
27
- it "should have an external_board_id attribute" do
28
- subject.external_board_id.must_equal "526d8e130a14a9d846001d96"
27
+ it 'should have an external_board_id attribute' do
28
+ subject.external_board_id.must_equal '526d8e130a14a9d846001d96'
29
29
  end
30
30
  end
31
31
 
32
- context "associations" do
32
+ context 'associations' do
33
33
  before do
34
34
  @list = Fabricate(:list)
35
35
  @card = Fabricate(:card)
@@ -37,14 +37,13 @@ module Troo
37
37
 
38
38
  after { database_cleanup }
39
39
 
40
- it "can have many lists" do
40
+ it 'can have many lists' do
41
41
  subject.lists.size.must_equal 1
42
42
  end
43
43
 
44
- it "can have many cards" do
44
+ it 'can have many cards' do
45
45
  subject.cards.size.must_equal 1
46
46
  end
47
47
  end
48
48
  end
49
49
  end
50
-