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,4 +1,4 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  module Troo
4
4
  describe Card do
@@ -7,57 +7,89 @@ module Troo
7
7
 
8
8
  subject { described_instance }
9
9
 
10
- context "attributes" do
11
- it "should have a short_id attribute" do
12
- subject.short_id.must_equal "67"
10
+ context 'attributes' do
11
+ it 'should have a short_id attribute' do
12
+ subject.short_id.must_equal '67'
13
13
  end
14
14
 
15
- it "should have a name attribute" do
16
- subject.name.must_equal "My Test Card"
15
+ it 'should have a name attribute' do
16
+ subject.name.must_equal 'My Test Card'
17
17
  end
18
18
 
19
- it "should have a desc attribute" do
20
- subject.desc.must_equal "some description"
19
+ it 'should have a desc attribute' do
20
+ subject.desc.must_equal 'some description'
21
21
  end
22
22
 
23
- it "should have a url attribute" do
24
- subject.url.must_equal "some trello url"
23
+ it 'should have a url attribute' do
24
+ subject.url.must_equal 'some trello url'
25
25
  end
26
26
 
27
- it "should have an external_member_ids attribute" do
28
- subject.external_member_ids.must_equal(["5195fdb5a8c01a2318004f5d"])
27
+ describe '#external_member_ids' do
28
+ context 'when the attribute is set' do
29
+ context 'and the attribute is an array' do
30
+ it 'returns the attribute' do
31
+ subject.external_member_ids
32
+ .must_equal(['5195fdb5a8c01a2318004f5d'])
33
+ end
34
+ end
35
+
36
+ context 'and the attribute is a string' do
37
+ let(:member_ids) { "[\"5195fdb5a8c01a2318004f5d\"]" }
38
+ let(:described_instance) do
39
+ Fabricate.build(:card,
40
+ external_member_ids: member_ids)
41
+ end
42
+
43
+ it 'converts to an array and returns the attribute' do
44
+ subject.external_member_ids
45
+ .must_equal(['5195fdb5a8c01a2318004f5d'])
46
+ end
47
+ end
48
+ end
49
+
50
+ context 'when the attribute is not set' do
51
+ let(:described_instance) do
52
+ Fabricate.build(:card, external_member_ids: nil)
53
+ end
54
+
55
+ it 'returns an empty collection' do
56
+ subject.external_member_ids.must_equal([])
57
+ end
58
+ end
29
59
  end
30
60
 
31
- it "should have a position attribute" do
61
+ it 'should have a position attribute' do
32
62
  subject.position.must_equal 16
33
63
  end
34
64
 
35
- it "should have a last_activity_date attribute" do
36
- subject.last_activity_date.must_equal "2013-12-17 21:48:09 UTC"
65
+ it 'should have a last_activity_date attribute' do
66
+ subject.last_activity_date
67
+ .must_equal '2013-12-17 21:48:09 UTC'
37
68
  end
38
69
 
39
- it "should have a default attribute" do
70
+ it 'should have a default attribute' do
40
71
  subject.default.must_equal false
41
72
  end
42
73
 
43
- it "should have a closed attribute" do
74
+ it 'should have a closed attribute' do
44
75
  subject.closed.must_equal false
45
76
  end
46
77
 
47
- it "should have an external_board_id attribute" do
48
- subject.external_board_id.must_equal "526d8e130a14a9d846001d96"
78
+ it 'should have an external_board_id attribute' do
79
+ subject.external_board_id
80
+ .must_equal '526d8e130a14a9d846001d96'
49
81
  end
50
82
 
51
- it "should have an external_list_id attribute" do
52
- subject.external_list_id.must_equal "526d8e130a14a9d846001d97"
83
+ it 'should have an external_list_id attribute' do
84
+ subject.external_list_id.must_equal '526d8e130a14a9d846001d97'
53
85
  end
54
86
 
55
- it "should have an external_card_id attribute" do
56
- subject.external_card_id.must_equal "526d8f19ddb279532e005259"
87
+ it 'should have an external_card_id attribute' do
88
+ subject.external_card_id.must_equal '526d8f19ddb279532e005259'
57
89
  end
58
90
  end
59
91
 
60
- context "associations" do
92
+ context 'associations' do
61
93
  before do
62
94
  @board = Fabricate(:board)
63
95
  @list = Fabricate(:list)
@@ -67,36 +99,35 @@ module Troo
67
99
 
68
100
  after { database_cleanup }
69
101
 
70
- it "belongs to a board" do
102
+ it 'belongs to a board' do
71
103
  subject.board.must_equal @board
72
104
  end
73
105
 
74
- it "belongs to a list" do
106
+ it 'belongs to a list' do
75
107
  subject.list.must_equal @list
76
108
  end
77
109
 
78
- it "can have many comments" do
110
+ it 'can have many comments' do
79
111
  subject.comments.size.must_equal 1
80
112
  end
81
113
 
82
- it "can have many comments" do
114
+ it 'can have many comments' do
83
115
  subject.recent_comments.size.must_equal 1
84
116
  end
85
117
 
86
- context "when the card has members" do
87
- it "returns the collection of members" do
118
+ context 'when the card has members' do
119
+ it 'returns the collection of members' do
88
120
  subject.members.size.must_equal 1
89
121
  end
90
122
  end
91
123
 
92
- context "when the card has no members" do
124
+ context 'when the card has no members' do
93
125
  before { subject.stubs(:external_member_ids).returns([]) }
94
126
 
95
- it "returns an empty collection" do
127
+ it 'returns an empty collection' do
96
128
  subject.members.size.must_equal 0
97
129
  end
98
130
  end
99
131
  end
100
132
  end
101
133
  end
102
-
@@ -1,4 +1,4 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  module Troo
4
4
  describe Comment do
@@ -7,33 +7,33 @@ module Troo
7
7
 
8
8
  subject { described_instance }
9
9
 
10
- context "attributes" do
11
- it "should have a text attribute" do
12
- subject.text.must_equal "My Test Comment"
10
+ context 'attributes' do
11
+ it 'should have a text attribute' do
12
+ subject.text.must_equal 'My Test Comment'
13
13
  end
14
14
 
15
- it "should have a date attribute" do
16
- subject.date.must_equal "2013-12-17 22:01:13 UTC"
15
+ it 'should have a date attribute' do
16
+ subject.date.must_equal '2013-12-17 22:01:13 UTC'
17
17
  end
18
18
 
19
- it "should have an external_board_id attribute" do
20
- subject.external_board_id.must_equal "526d8e130a14a9d846001d96"
19
+ it 'should have an external_board_id attribute' do
20
+ subject.external_board_id.must_equal '526d8e130a14a9d846001d96'
21
21
  end
22
22
 
23
- it "should have an external_card_id attribute" do
24
- subject.external_card_id.must_equal "526d8f19ddb279532e005259"
23
+ it 'should have an external_card_id attribute' do
24
+ subject.external_card_id.must_equal '526d8f19ddb279532e005259'
25
25
  end
26
26
 
27
- it "should have an external_comment_id attribute" do
28
- subject.external_comment_id.must_equal "51f9277b2822b8654f0023af"
27
+ it 'should have an external_comment_id attribute' do
28
+ subject.external_comment_id.must_equal '51f9277b2822b8654f0023af'
29
29
  end
30
30
 
31
- it "should have a external_member_id attribute" do
32
- subject.external_member_id.must_equal "5195fdb5a8c01a2318004f5d"
31
+ it 'should have a external_member_id attribute' do
32
+ subject.external_member_id.must_equal '5195fdb5a8c01a2318004f5d'
33
33
  end
34
34
  end
35
35
 
36
- context "associations" do
36
+ context 'associations' do
37
37
  before do
38
38
  @board = Fabricate(:board)
39
39
  @card = Fabricate(:card)
@@ -42,18 +42,17 @@ module Troo
42
42
 
43
43
  after { database_cleanup }
44
44
 
45
- it "belongs to a board" do
45
+ it 'belongs to a board' do
46
46
  subject.board.must_equal @board
47
47
  end
48
48
 
49
- it "belongs to a card" do
49
+ it 'belongs to a card' do
50
50
  subject.card.must_equal @card
51
51
  end
52
52
 
53
- it "belongs to a member" do
53
+ it 'belongs to a member' do
54
54
  subject.member.must_equal @member
55
55
  end
56
56
  end
57
57
  end
58
58
  end
59
-
@@ -1,4 +1,4 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  module Troo
4
4
  describe List do
@@ -7,33 +7,33 @@ 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 List"
10
+ context 'attributes' do
11
+ it 'should have a name attribute' do
12
+ subject.name.must_equal 'My Test List'
13
13
  end
14
14
 
15
- it "should have a position attribute" do
16
- subject.position.must_equal 32768
15
+ it 'should have a position attribute' do
16
+ subject.position.must_equal 32_768
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 a external_board_id attribute" do
28
- subject.external_board_id.must_equal "526d8e130a14a9d846001d96"
27
+ it 'should have a external_board_id attribute' do
28
+ subject.external_board_id.must_equal '526d8e130a14a9d846001d96'
29
29
  end
30
30
 
31
- it "should have an external_list_id attribute" do
32
- subject.external_list_id.must_equal "526d8e130a14a9d846001d97"
31
+ it 'should have an external_list_id attribute' do
32
+ subject.external_list_id.must_equal '526d8e130a14a9d846001d97'
33
33
  end
34
34
  end
35
35
 
36
- context "associations" do
36
+ context 'associations' do
37
37
  before do
38
38
  @board = Fabricate(:board)
39
39
  @card = Fabricate(:card)
@@ -41,11 +41,11 @@ module Troo
41
41
 
42
42
  after { database_cleanup }
43
43
 
44
- it "belongs to a board" do
44
+ it 'belongs to a board' do
45
45
  subject.board.must_equal @board
46
46
  end
47
47
 
48
- it "can have many cards" do
48
+ it 'can have many cards' do
49
49
  subject.cards.size.must_equal 1
50
50
  end
51
51
  end
@@ -1,4 +1,4 @@
1
- require_relative "../../../test_helper"
1
+ require_relative '../../../test_helper'
2
2
 
3
3
  module Troo
4
4
  describe Member do
@@ -7,37 +7,37 @@ module Troo
7
7
 
8
8
  subject { described_instance }
9
9
 
10
- context "attributes" do
11
- it "should have a username attribute" do
12
- subject.username.must_equal "gavinlaking1"
10
+ context 'attributes' do
11
+ it 'should have a username attribute' do
12
+ subject.username.must_equal 'gavinlaking1'
13
13
  end
14
14
 
15
- it "should have an email attribute" do
16
- subject.email.must_equal "gavinlaking@gmail.com"
15
+ it 'should have an email attribute' do
16
+ subject.email.must_equal 'gavinlaking@gmail.com'
17
17
  end
18
18
 
19
- it "should have a full_name attribute" do
20
- subject.full_name.must_equal "Gavin Laking"
19
+ it 'should have a full_name attribute' do
20
+ subject.full_name.must_equal 'Gavin Laking'
21
21
  end
22
22
 
23
- it "should have an initials attribute" do
24
- subject.initials.must_equal "GL"
23
+ it 'should have an initials attribute' do
24
+ subject.initials.must_equal 'GL'
25
25
  end
26
26
 
27
- it "should have an avatar_id attribute" do
28
- subject.avatar_id.must_equal "some_avatar_id"
27
+ it 'should have an avatar_id attribute' do
28
+ subject.avatar_id.must_equal 'some_avatar_id'
29
29
  end
30
30
 
31
- it "should have a bio attribute" do
32
- subject.bio.must_equal "some bio"
31
+ it 'should have a bio attribute' do
32
+ subject.bio.must_equal 'some bio'
33
33
  end
34
34
 
35
- it "should have a url attribute" do
36
- subject.url.must_equal "http://www.gavinlaking.name/"
35
+ it 'should have a url attribute' do
36
+ subject.url.must_equal 'http://www.gavinlaking.name/'
37
37
  end
38
38
 
39
- it "should have an external_member_id attribute" do
40
- subject.external_member_id.must_equal "5195fdb5a8c01a2318004f5d"
39
+ it 'should have an external_member_id attribute' do
40
+ subject.external_member_id.must_equal '5195fdb5a8c01a2318004f5d'
41
41
  end
42
42
  end
43
43
  end
@@ -0,0 +1,62 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ describe Persistence::Board do
5
+ let(:described_class) { Persistence::Board }
6
+ let(:resource) do
7
+ OpenStruct.new(
8
+ id: '526d8e130a14a9d846001d96',
9
+ name: resource_name,
10
+ description: 'A very brief description...',
11
+ closed: false)
12
+ end
13
+ let(:resource_name) { 'My Test Board' }
14
+ let(:options) { {} }
15
+
16
+ before { @board = Fabricate(:board) }
17
+ after { database_cleanup }
18
+
19
+ describe '.initialize' do
20
+ subject { described_class.new(resource, options) }
21
+
22
+ it 'assigns the resource to an instance variable' do
23
+ subject.instance_variable_get('@resource')
24
+ .must_equal(resource)
25
+ end
26
+
27
+ it 'assigns the options to an instance variable' do
28
+ subject.instance_variable_get('@options').must_equal(options)
29
+ end
30
+ end
31
+
32
+ describe '#persist' do
33
+ subject { described_class.for(resource, options) }
34
+
35
+ context 'when there is already a local copy' do
36
+ context 'and the local copy is identical' do
37
+ it 'returns the local copy' do
38
+ subject.must_equal(@board)
39
+ end
40
+ end
41
+
42
+ context 'and the local copy is out of date' do
43
+ let(:resource_name) { 'My Renamed Board' }
44
+
45
+ it 'updates and returns the new local copy' do
46
+ subject.name.must_equal(resource_name)
47
+ end
48
+ end
49
+ end
50
+
51
+ context 'when there is not already a local copy' do
52
+ let(:resource_name) { 'My New Test Board' }
53
+
54
+ before { database_cleanup }
55
+
56
+ it 'creates and returns the new local copy' do
57
+ subject.name.must_equal(resource_name)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,61 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ describe Persistence::Card do
5
+ let(:described_class) { Persistence::Card }
6
+ let(:resource) do
7
+ OpenStruct.new(
8
+ id: '526d8f19ddb279532e005259',
9
+ name: resource_name,
10
+ closed: false)
11
+ end
12
+ let(:resource_name) { 'My Test Card' }
13
+ let(:options) { {} }
14
+
15
+ before { @card = Fabricate(:card) }
16
+ after { database_cleanup }
17
+
18
+ describe '.initialize' do
19
+ subject { described_class.new(resource, options) }
20
+
21
+ it 'assigns the resource to an instance variable' do
22
+ subject.instance_variable_get('@resource')
23
+ .must_equal(resource)
24
+ end
25
+
26
+ it 'assigns the options to an instance variable' do
27
+ subject.instance_variable_get('@options').must_equal(options)
28
+ end
29
+ end
30
+
31
+ describe '#persist' do
32
+ subject { described_class.for(resource, options) }
33
+
34
+ context 'when there is already a local copy' do
35
+ context 'and the local copy is identical' do
36
+ it 'returns the local copy' do
37
+ subject.must_equal(@card)
38
+ end
39
+ end
40
+
41
+ context 'and the local copy is out of date' do
42
+ let(:resource_name) { 'My Renamed Card' }
43
+
44
+ it 'updates and returns the new local copy' do
45
+ subject.name.must_equal(resource_name)
46
+ end
47
+ end
48
+ end
49
+
50
+ context 'when there is not already a local copy' do
51
+ let(:resource_name) { 'My New Test Card' }
52
+
53
+ before { database_cleanup }
54
+
55
+ it 'creates and returns the new local copy' do
56
+ subject.name.must_equal(resource_name)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,69 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ describe Persistence::Comment do
5
+ let(:described_class) { Persistence::Comment }
6
+ let(:resource) do
7
+ OpenStruct.new(
8
+ id: '51f9277b2822b8654f0023af',
9
+ date: '2013-12-17 22:01:13 UTC',
10
+ data: {
11
+ 'text' => resource_text,
12
+ 'board' => {
13
+ 'id' => '526d8e130a14a9d846001d96'
14
+ },
15
+ 'card' => {
16
+ 'id' => '526d8f19ddb279532e005259'
17
+ }
18
+ })
19
+ end
20
+ let(:resource_text) { 'My Test Comment' }
21
+ let(:options) { {} }
22
+
23
+ before { @comment = Fabricate(:comment) }
24
+ after { database_cleanup }
25
+
26
+ describe '.initialize' do
27
+ subject { described_class.new(resource, options) }
28
+
29
+ it 'assigns the resource to an instance variable' do
30
+ subject.instance_variable_get('@resource')
31
+ .must_equal(resource)
32
+ end
33
+
34
+ it 'assigns the options to an instance variable' do
35
+ subject.instance_variable_get('@options').must_equal(options)
36
+ end
37
+ end
38
+
39
+ describe '#persist' do
40
+ subject { described_class.for(resource, options) }
41
+
42
+ context 'when there is already a local copy' do
43
+ context 'and the local copy is identical' do
44
+ it 'returns the local copy' do
45
+ subject.must_equal(@comment)
46
+ end
47
+ end
48
+
49
+ context 'and the local copy is out of date' do
50
+ let(:resource_text) { 'My Renamed Comment' }
51
+
52
+ it 'updates and returns the new local copy' do
53
+ subject.text.must_equal(resource_text)
54
+ end
55
+ end
56
+ end
57
+
58
+ context 'when there is not already a local copy' do
59
+ let(:resource_text) { 'My New Test Comment' }
60
+
61
+ before { database_cleanup }
62
+
63
+ it 'creates and returns the new local copy' do
64
+ subject.text.must_equal(resource_text)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,60 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ describe Persistence::List do
5
+ let(:described_class) { Persistence::List }
6
+ let(:resource) do
7
+ OpenStruct.new(
8
+ id: '526d8e130a14a9d846001d97',
9
+ name: resource_name,
10
+ closed: false)
11
+ end
12
+ let(:resource_name) { 'My Test List' }
13
+ let(:options) { {} }
14
+
15
+ before { @list = Fabricate(:list) }
16
+ after { database_cleanup }
17
+
18
+ describe '.initialize' do
19
+ subject { described_class.new(resource, options) }
20
+
21
+ it 'assigns the resource to an instance variable' do
22
+ subject.instance_variable_get('@resource').must_equal(resource)
23
+ end
24
+
25
+ it 'assigns the options to an instance variable' do
26
+ subject.instance_variable_get('@options').must_equal(options)
27
+ end
28
+ end
29
+
30
+ describe '#persist' do
31
+ subject { described_class.for(resource, options) }
32
+
33
+ context 'when there is already a local copy' do
34
+ context 'and the local copy is identical' do
35
+ it 'returns the local copy' do
36
+ subject.must_equal(@list)
37
+ end
38
+ end
39
+
40
+ context 'and the local copy is out of date' do
41
+ let(:resource_name) { 'My Renamed List' }
42
+
43
+ it 'updates and returns the new local copy' do
44
+ subject.name.must_equal(resource_name)
45
+ end
46
+ end
47
+ end
48
+
49
+ context 'when there is not already a local copy' do
50
+ let(:resource_name) { 'My New Test List' }
51
+
52
+ before { database_cleanup }
53
+
54
+ it 'creates and returns the new local copy' do
55
+ subject.name.must_equal(resource_name)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,60 @@
1
+ require_relative '../../../../test_helper'
2
+
3
+ module Troo
4
+ describe Persistence::Member do
5
+ let(:described_class) { Persistence::Member }
6
+ let(:resource) do
7
+ OpenStruct.new(
8
+ id: '5195fdb5a8c01a2318004f5d',
9
+ full_name: resource_full_name)
10
+ end
11
+ let(:resource_full_name) { 'My Test Member' }
12
+ let(:options) { {} }
13
+
14
+ before { @member = Fabricate(:member) }
15
+ after { database_cleanup }
16
+
17
+ describe '.initialize' do
18
+ subject { described_class.new(resource, options) }
19
+
20
+ it 'assigns the resource to an instance variable' do
21
+ subject.instance_variable_get('@resource')
22
+ .must_equal(resource)
23
+ end
24
+
25
+ it 'assigns the options to an instance variable' do
26
+ subject.instance_variable_get('@options').must_equal(options)
27
+ end
28
+ end
29
+
30
+ describe '#persist' do
31
+ subject { described_class.for(resource, options) }
32
+
33
+ context 'when there is already a local copy' do
34
+ context 'and the local copy is identical' do
35
+ it 'returns the local copy' do
36
+ subject.must_equal(@member)
37
+ end
38
+ end
39
+
40
+ context 'and the local copy is out of date' do
41
+ let(:resource_full_name) { 'My Renamed Member' }
42
+
43
+ it 'updates and returns the new local copy' do
44
+ subject.full_name.must_equal(resource_full_name)
45
+ end
46
+ end
47
+ end
48
+
49
+ context 'when there is not already a local copy' do
50
+ let(:resource_full_name) { 'My New Test Member' }
51
+
52
+ before { database_cleanup }
53
+
54
+ it 'creates and returns the new local copy' do
55
+ subject.full_name.must_equal(resource_full_name)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end