troo 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +0 -1
  5. data/Guardfile +6 -0
  6. data/LICENSE.txt +1 -0
  7. data/README.md +46 -3
  8. data/Rakefile +11 -0
  9. data/bin/troo +12 -0
  10. data/configuration.yml.example +7 -0
  11. data/features/add_board.feature +1 -0
  12. data/features/add_card.feature +1 -0
  13. data/features/add_comment.feature +1 -0
  14. data/features/add_list.feature +1 -0
  15. data/features/cleanup.feature +0 -0
  16. data/features/move_card_to_list.feature +1 -0
  17. data/features/refresh.feature +1 -0
  18. data/features/set_default.feature +7 -0
  19. data/features/show_board.feature +1 -0
  20. data/features/show_boards.feature +1 -0
  21. data/features/show_card.feature +1 -0
  22. data/features/show_comments.feature +1 -0
  23. data/features/show_list.feature +1 -0
  24. data/features/status.feature +1 -0
  25. data/features/step_definitions/troo_steps.rb +0 -0
  26. data/features/support/env.rb +31 -0
  27. data/features/troo.feature +1 -0
  28. data/features/version.feature +8 -0
  29. data/lib/troo.rb +24 -2
  30. data/lib/troo/actions/create_board.rb +43 -0
  31. data/lib/troo/actions/create_card.rb +43 -0
  32. data/lib/troo/actions/create_comment.rb +44 -0
  33. data/lib/troo/actions/create_list.rb +41 -0
  34. data/lib/troo/actions/move_card.rb +36 -0
  35. data/lib/troo/actions/refresh_all.rb +79 -0
  36. data/lib/troo/actions/set_default.rb +35 -0
  37. data/lib/troo/cli/add_cli.rb +83 -0
  38. data/lib/troo/cli/default_cli.rb +37 -0
  39. data/lib/troo/cli/main_cli.rb +130 -0
  40. data/lib/troo/cli/show_cli.rb +83 -0
  41. data/lib/troo/cli/thor_fixes.rb +9 -0
  42. data/lib/troo/display/board_decorator.rb +58 -0
  43. data/lib/troo/display/board_presenter.rb +65 -0
  44. data/lib/troo/display/card_decorator.rb +105 -0
  45. data/lib/troo/display/card_presenter.rb +27 -0
  46. data/lib/troo/display/comment_decorator.rb +32 -0
  47. data/lib/troo/display/comment_presenter.rb +35 -0
  48. data/lib/troo/display/decorator_helpers.rb +76 -0
  49. data/lib/troo/display/list_decorator.rb +53 -0
  50. data/lib/troo/display/list_presenter.rb +43 -0
  51. data/lib/troo/display/member_decorator.rb +24 -0
  52. data/lib/troo/display/member_presenter.rb +59 -0
  53. data/lib/troo/external/board.rb +49 -0
  54. data/lib/troo/external/board_adaptor.rb +43 -0
  55. data/lib/troo/external/card.rb +70 -0
  56. data/lib/troo/external/card_adaptor.rb +78 -0
  57. data/lib/troo/external/comment.rb +64 -0
  58. data/lib/troo/external/comment_adaptor.rb +53 -0
  59. data/lib/troo/external/list.rb +58 -0
  60. data/lib/troo/external/list_adaptor.rb +48 -0
  61. data/lib/troo/external/member.rb +52 -0
  62. data/lib/troo/external/member_adaptor.rb +63 -0
  63. data/lib/troo/models/board.rb +26 -0
  64. data/lib/troo/models/board_persistence.rb +53 -0
  65. data/lib/troo/models/board_retrieval.rb +45 -0
  66. data/lib/troo/models/card.rb +54 -0
  67. data/lib/troo/models/card_persistence.rb +53 -0
  68. data/lib/troo/models/card_retrieval.rb +49 -0
  69. data/lib/troo/models/comment.rb +32 -0
  70. data/lib/troo/models/comment_persistence.rb +53 -0
  71. data/lib/troo/models/comment_retrieval.rb +32 -0
  72. data/lib/troo/models/list.rb +27 -0
  73. data/lib/troo/models/list_persistence.rb +53 -0
  74. data/lib/troo/models/list_retrieval.rb +45 -0
  75. data/lib/troo/models/member.rb +18 -0
  76. data/lib/troo/models/member_persistence.rb +53 -0
  77. data/lib/troo/models/member_retrieval.rb +36 -0
  78. data/lib/troo/models/model_helpers.rb +32 -0
  79. data/lib/troo/models/refresh.rb +23 -0
  80. data/lib/troo/presentation/template.rb +31 -0
  81. data/lib/troo/troo.rb +69 -0
  82. data/lib/troo/version.rb +2 -1
  83. data/lib/troo/views/card.erb +17 -0
  84. data/lib/troo/views/comment.erb +3 -0
  85. data/logs/.gitkeep +0 -0
  86. data/test/cassettes/board_by_id.yml +59 -0
  87. data/test/cassettes/boards_all.yml +118 -0
  88. data/test/cassettes/card_by_card_id.yml +58 -0
  89. data/test/cassettes/cards_by_board_id.yml +117 -0
  90. data/test/cassettes/cards_by_list_id.yml +114 -0
  91. data/test/cassettes/comments_by_board_id.yml +122 -0
  92. data/test/cassettes/comments_by_card_id.yml +114 -0
  93. data/test/cassettes/comments_by_list_id.yml +109 -0
  94. data/test/cassettes/create_board.yml +62 -0
  95. data/test/cassettes/create_card.yml +63 -0
  96. data/test/cassettes/create_comment.yml +67 -0
  97. data/test/cassettes/create_list.yml +60 -0
  98. data/test/cassettes/list_by_list_id.yml +56 -0
  99. data/test/cassettes/lists_by_board_id.yml +118 -0
  100. data/test/cassettes/member_by_member_id.yml +60 -0
  101. data/test/cassettes/members_by_board_id.yml +109 -0
  102. data/test/cassettes/move_card.yml +61 -0
  103. data/test/lib/troo/actions/create_board_test.rb +47 -0
  104. data/test/lib/troo/actions/create_card_test.rb +54 -0
  105. data/test/lib/troo/actions/create_comment_test.rb +49 -0
  106. data/test/lib/troo/actions/create_list_test.rb +49 -0
  107. data/test/lib/troo/actions/move_card_test.rb +46 -0
  108. data/test/lib/troo/actions/refresh_all_test.rb +68 -0
  109. data/test/lib/troo/actions/set_default_test.rb +44 -0
  110. data/test/lib/troo/cli/add_cli_test.rb +216 -0
  111. data/test/lib/troo/cli/default_cli_test.rb +79 -0
  112. data/test/lib/troo/cli/main_cli_test.rb +232 -0
  113. data/test/lib/troo/cli/show_cli_test.rb +221 -0
  114. data/test/lib/troo/cli/thor_fixes_test.rb +21 -0
  115. data/test/lib/troo/display/board_decorator_test.rb +126 -0
  116. data/test/lib/troo/display/board_presenter_test.rb +77 -0
  117. data/test/lib/troo/display/card_decorator_test.rb +221 -0
  118. data/test/lib/troo/display/card_presenter_test.rb +38 -0
  119. data/test/lib/troo/display/comment_decorator_test.rb +65 -0
  120. data/test/lib/troo/display/comment_presenter_test.rb +47 -0
  121. data/test/lib/troo/display/decorator_helpers_test.rb +7 -0
  122. data/test/lib/troo/display/list_decorator_test.rb +98 -0
  123. data/test/lib/troo/display/list_presenter_test.rb +48 -0
  124. data/test/lib/troo/display/member_decorator_test.rb +42 -0
  125. data/test/lib/troo/display/member_presenter_test.rb +70 -0
  126. data/test/lib/troo/external/board_adaptor_test.rb +36 -0
  127. data/test/lib/troo/external/board_test.rb +69 -0
  128. data/test/lib/troo/external/card_adaptor_test.rb +50 -0
  129. data/test/lib/troo/external/card_test.rb +108 -0
  130. data/test/lib/troo/external/comment_adaptor_test.rb +41 -0
  131. data/test/lib/troo/external/comment_test.rb +88 -0
  132. data/test/lib/troo/external/list_adaptor_test.rb +38 -0
  133. data/test/lib/troo/external/list_test.rb +65 -0
  134. data/test/lib/troo/external/member_adaptor_test.rb +44 -0
  135. data/test/lib/troo/external/member_test.rb +65 -0
  136. data/test/lib/troo/models/board_persistence_test.rb +61 -0
  137. data/test/lib/troo/models/board_retrieval_test.rb +93 -0
  138. data/test/lib/troo/models/board_test.rb +50 -0
  139. data/test/lib/troo/models/card_persistence_test.rb +60 -0
  140. data/test/lib/troo/models/card_retrieval_test.rb +101 -0
  141. data/test/lib/troo/models/card_test.rb +102 -0
  142. data/test/lib/troo/models/comment_persistence_test.rb +65 -0
  143. data/test/lib/troo/models/comment_retrieval_test.rb +46 -0
  144. data/test/lib/troo/models/comment_test.rb +59 -0
  145. data/test/lib/troo/models/list_persistence_test.rb +60 -0
  146. data/test/lib/troo/models/list_retrieval_test.rb +93 -0
  147. data/test/lib/troo/models/list_test.rb +53 -0
  148. data/test/lib/troo/models/member_persistence_test.rb +59 -0
  149. data/test/lib/troo/models/member_retrieval_test.rb +58 -0
  150. data/test/lib/troo/models/member_test.rb +44 -0
  151. data/test/lib/troo/models/model_helpers_test.rb +103 -0
  152. data/test/lib/troo/models/refresh_test.rb +45 -0
  153. data/test/lib/troo/presentation/template_test.rb +40 -0
  154. data/test/support/fabrication.rb +56 -0
  155. data/test/support/template.erb +3 -0
  156. data/test/support/vcr_setup.rb +36 -0
  157. data/test/test_helper.rb +30 -0
  158. data/troo.gemspec +24 -5
  159. metadata +501 -23
@@ -0,0 +1,221 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe CardDecorator do
5
+ let(:described_class) { CardDecorator }
6
+ let(:described_instance) { described_class.new(@card, options) }
7
+ let(:default) { true }
8
+ let(:description) { "Finish Troo for fame and fortune." }
9
+ let(:options) { {} }
10
+
11
+ before do
12
+ @board = Fabricate(:board)
13
+ @list = Fabricate(:list)
14
+ @card = Fabricate(:card, desc: description, default: default, external_member_ids: ["5195fdb5a8c01a2318004f5d", "some_member_id"])
15
+ @comment = Fabricate(:comment)
16
+ @comment_2 = Fabricate(:comment, text: "My Other Test Comment")
17
+ @comment_3 = Fabricate(:comment, text: "My Lithium Comment")
18
+ @comment_4 = Fabricate(:comment, text: "My Beryllium Comment")
19
+ @member = Fabricate(:member)
20
+ @member_2 = Fabricate(:member, username: "mysterywoman", external_member_id: "some_member_id")
21
+ end
22
+
23
+ after { database_cleanup }
24
+
25
+ describe "#initialize" do
26
+ subject { described_instance }
27
+
28
+ it "assigns the card to an instance variable" do
29
+ subject.instance_variable_get("@card").must_equal(@card)
30
+ end
31
+
32
+ it "assigns the options to an instance variable" do
33
+ subject.instance_variable_get("@options").must_equal(options)
34
+ end
35
+ end
36
+
37
+ describe "#short" do
38
+ subject { described_instance.short }
39
+
40
+ it "returns a one line overview of the card" do
41
+ subject.must_equal(" * (67) My Test Card\n")
42
+ end
43
+
44
+ context "when the ansicolor option is false" do
45
+ let(:options) { { ansicolor: false } }
46
+
47
+ it "returns a one line overview of the board" do
48
+ subject.must_equal(" * (67) My Test Card\n")
49
+ end
50
+ end
51
+ end
52
+
53
+ describe "#title" do
54
+ subject { described_instance.title }
55
+
56
+ it "returns a formatted string representing the card title" do
57
+ subject.must_match /\* \(67\) My Test Card/
58
+ end
59
+ end
60
+
61
+ describe "#name_str" do
62
+ subject { described_instance.name_str }
63
+
64
+ it "returns the formatted card name" do
65
+ subject.must_equal("My Test Card")
66
+ end
67
+ end
68
+
69
+ describe "#default_str" do
70
+ subject { described_instance.default_str }
71
+
72
+ it "returns the formatted card default indicator" do
73
+ subject.must_equal(" * ")
74
+ end
75
+ end
76
+
77
+ describe "#id_str" do
78
+ subject { described_instance.id_str }
79
+
80
+ it "returns the formatted card id" do
81
+ subject.must_equal(" (67) ")
82
+ end
83
+ end
84
+
85
+ describe "#name" do
86
+ subject { described_instance.name }
87
+
88
+ it "returns the card name" do
89
+ subject.must_equal(@card.name)
90
+ end
91
+ end
92
+
93
+ describe "#default" do
94
+ subject { described_instance.default }
95
+
96
+ context "when default" do
97
+ it "return an indicator" do
98
+ subject.must_equal("*")
99
+ end
100
+ end
101
+
102
+ context "when not default" do
103
+ let(:default) { false }
104
+
105
+ it "returns nothing" do
106
+ subject.must_equal("")
107
+ end
108
+ end
109
+ end
110
+
111
+ describe "#id" do
112
+ subject { described_instance.id }
113
+
114
+ it "returns the card id" do
115
+ subject.must_equal(@card.short_id)
116
+ end
117
+ end
118
+
119
+ describe "#description" do
120
+ subject { described_instance.description }
121
+
122
+ context "when there are further details" do
123
+ it "returns the description" do
124
+ subject.must_equal(@card.desc)
125
+ end
126
+ end
127
+
128
+ context "when there are no further details" do
129
+ let(:description) { nil }
130
+
131
+ it "returns a polite message" do
132
+ subject.must_equal("There are no further details at this time.")
133
+ end
134
+ end
135
+ end
136
+
137
+ describe "#comments" do
138
+ subject { described_instance.comments }
139
+
140
+ context "when there are more than 3 comments" do
141
+ it "returns the comments" do
142
+ subject.must_match /There are more comments/
143
+ subject.must_match /My Test Comment/
144
+ subject.must_match /My Other Test Comment/
145
+ subject.must_match /My Lithium Comment/
146
+ subject.wont_match /My Beryllium Comment/
147
+ end
148
+ end
149
+
150
+ context "when there are 3 or less comments" do
151
+ before do
152
+ @comment_3.delete
153
+ @comment_4.delete
154
+ end
155
+
156
+ it "returns the comments" do
157
+ subject.must_match /My Test Comment/
158
+ subject.must_match /My Other Test Comment/
159
+ end
160
+ end
161
+
162
+ context "when there are no comments" do
163
+ before do
164
+ @comment.delete
165
+ @comment_2.delete
166
+ @comment_3.delete
167
+ @comment_4.delete
168
+ end
169
+
170
+ it "returns a polite message" do
171
+ subject.must_equal("No comments have been left.")
172
+ end
173
+ end
174
+ end
175
+
176
+ describe "#members" do
177
+ subject { described_instance.members }
178
+
179
+ context "when there are members" do
180
+ it "returns the members" do
181
+ subject.must_equal("@gavinlaking1 and @mysterywoman")
182
+ end
183
+ end
184
+
185
+ context "when there are no members" do
186
+ before do
187
+ @member.delete
188
+ @member_2.delete
189
+ end
190
+
191
+ it "returns a polite message" do
192
+ subject.must_equal("No members have been assigned.")
193
+ end
194
+ end
195
+ end
196
+
197
+ describe "#last_activity_date" do
198
+ subject { described_instance.last_activity_date }
199
+
200
+ it "returns the last activity date" do
201
+ subject.must_equal("Tue, Dec 17 at 21:48")
202
+ end
203
+ end
204
+
205
+ describe "#board" do
206
+ subject { described_instance.board }
207
+
208
+ it "returns the board details" do
209
+ subject.must_match "(1) My Test Board"
210
+ end
211
+ end
212
+
213
+ describe "#list" do
214
+ subject { described_class.new(@card).list }
215
+
216
+ it "returns the list details" do
217
+ subject.must_match "(1) My Test List"
218
+ end
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,38 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe CardPresenter do
5
+ let(:described_class) { CardPresenter }
6
+ let(:options) { { } }
7
+
8
+ before do
9
+ @card = Fabricate(:card)
10
+ @board = Fabricate(:board)
11
+ @list = Fabricate(:list)
12
+ end
13
+
14
+ after { database_cleanup }
15
+
16
+ describe "#initialize" do
17
+ subject { described_class.new(@card, options) }
18
+
19
+ it "assigns the card to an instance variable" do
20
+ subject.instance_variable_get("@card").must_equal(@card)
21
+ end
22
+
23
+ it "assigns the options to an instance variable" do
24
+ subject.instance_variable_get("@options").must_equal(options)
25
+ end
26
+ end
27
+
28
+ describe "#render_show" do
29
+ subject { capture_io { described_class.render_show(@card, options) }.join }
30
+
31
+ it "renders the view" do
32
+ subject.must_match /My Test Card/
33
+ subject.must_match /No comments have been left/
34
+ subject.must_match /Metadata/
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,65 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe CommentDecorator do
5
+ let(:described_class) { CommentDecorator }
6
+ let(:default) { true }
7
+
8
+ before do
9
+ @comment = Fabricate(:comment)
10
+ @member = Fabricate(:member)
11
+ end
12
+
13
+ after { database_cleanup }
14
+
15
+ describe "#initialize" do
16
+ subject { described_class.new(@comment) }
17
+
18
+ it "assigns the comment to an instance variable" do
19
+ subject.instance_variable_get("@comment").must_equal(@comment)
20
+ end
21
+ end
22
+
23
+ describe "#as_view" do
24
+ subject { described_class.new(@comment).as_view }
25
+
26
+ it "returns the rendered comment" do
27
+ subject.must_match /gavinlaking1/
28
+ subject.must_match /My Test Comment/
29
+ subject.must_match /Tue, Dec 17 at 22:01/
30
+ end
31
+ end
32
+
33
+ describe "#member_username" do
34
+ subject { described_class.new(@comment).member_username }
35
+
36
+ it "returns the comment member username" do
37
+ subject.must_equal(@comment.member.username + ":")
38
+ end
39
+ end
40
+
41
+ describe "#text" do
42
+ subject { described_class.new(@comment).text }
43
+
44
+ it "returns the comment text" do
45
+ subject.must_equal(@comment.text)
46
+ end
47
+ end
48
+
49
+ describe "#date" do
50
+ subject { described_class.new(@comment).date }
51
+
52
+ it "returns the comment date" do
53
+ subject.must_equal("Tue, Dec 17 at 22:01")
54
+ end
55
+ end
56
+
57
+ describe "#id" do
58
+ subject { described_class.new(@comment).id }
59
+
60
+ it "returns the comment id" do
61
+ subject.must_equal("(#{@comment.id})")
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,47 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe CommentPresenter do
5
+ let(:described_class) { CommentPresenter }
6
+ let(:options) { { } }
7
+
8
+ before do
9
+ @card = Fabricate(:card)
10
+ @comment = Fabricate(:comment)
11
+ @member = Fabricate(:member)
12
+ end
13
+
14
+ after { database_cleanup }
15
+
16
+ describe "#initialize" do
17
+ subject { described_class.new(@card, options) }
18
+
19
+ it "assigns the card to an instance variable" do
20
+ subject.instance_variable_get("@card").must_equal(@card)
21
+ end
22
+
23
+ it "assigns the options to an instance variable" do
24
+ subject.instance_variable_get("@options").must_equal(options)
25
+ end
26
+ end
27
+
28
+ describe "#render_show" do
29
+ subject { capture_io { described_class.render_show(@card, options) }.join }
30
+
31
+ context "when the card has comments" do
32
+ it "renders the view" do
33
+ subject.must_match /My Test Card/
34
+ subject.must_match /My Test Comment/
35
+ end
36
+ end
37
+
38
+ context "when the card has no comments" do
39
+ before { @comment.delete }
40
+
41
+ it "returns a polite message" do
42
+ subject.must_match /No comments were found/
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,7 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe DecoratorHelpers do
5
+ let(:described_class) { DecoratorHelpers }
6
+ end
7
+ end
@@ -0,0 +1,98 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe ListDecorator do
5
+ let(:described_class) { ListDecorator }
6
+ let(:default) { true }
7
+ let(:options) { {} }
8
+
9
+ before { @list = Fabricate(:list, default: default) }
10
+ after { database_cleanup }
11
+
12
+ describe "#initialize" do
13
+ subject { described_class.new(@list, options) }
14
+
15
+ it "assigns the list to an instance variable" do
16
+ subject.instance_variable_get("@list").must_equal(@list)
17
+ end
18
+
19
+ it "assigns the options to an instance variable" do
20
+ subject.instance_variable_get("@options").must_equal(options)
21
+ end
22
+ end
23
+
24
+ describe "#short" do
25
+ subject { described_class.new(@list, options).short }
26
+
27
+ it "returns a one line overview of the list" do
28
+ subject.must_equal(" * \e[32m\e[4m(1) \e[0m\e[32m\e[4mMy Test List\e[0m\n")
29
+ end
30
+
31
+ context "when the ansicolor option is false" do
32
+ let(:options) { { ansicolor: false } }
33
+
34
+ it "returns a one line overview of the board" do
35
+ subject.must_equal(" * (1) My Test List\n")
36
+ end
37
+ end
38
+ end
39
+
40
+ describe "#name_str" do
41
+ subject { described_class.new(@list).name_str }
42
+
43
+ it "returns the formatted list name" do
44
+ subject.must_equal("\e[32m\e[4mMy Test List\e[0m")
45
+ end
46
+ end
47
+
48
+ describe "#default_str" do
49
+ subject { described_class.new(@list).default_str }
50
+
51
+ it "returns the formatted card default indicator" do
52
+ subject.must_equal(" * ")
53
+ end
54
+ end
55
+
56
+ describe "#id_str" do
57
+ subject { described_class.new(@list).id_str }
58
+
59
+ it "returns the formatted list id" do
60
+ subject.must_equal("\e[32m\e[4m(1) \e[0m")
61
+ end
62
+ end
63
+
64
+ describe "#name" do
65
+ subject { described_class.new(@list).name }
66
+
67
+ it "returns the list name" do
68
+ subject.must_equal(@list.name)
69
+ end
70
+ end
71
+
72
+ describe "#default" do
73
+ subject { described_class.new(@list).default }
74
+
75
+ context "when default" do
76
+ it "return an indicator" do
77
+ subject.must_equal("*")
78
+ end
79
+ end
80
+
81
+ context "when not default" do
82
+ let(:default) { false }
83
+
84
+ it "returns nothing" do
85
+ subject.must_equal("")
86
+ end
87
+ end
88
+ end
89
+
90
+ describe "#id" do
91
+ subject { described_class.new(@list).id }
92
+
93
+ it "returns the list id" do
94
+ subject.must_equal(@list.id.to_s)
95
+ end
96
+ end
97
+ end
98
+ end