troo 0.0.1 → 0.0.2

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 (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
+ require "thor"
3
+
4
+ module Troo
5
+ module CLI
6
+ describe Show do
7
+ let(:described_class) { Show }
8
+ let(:board_id) { "526d8e130a14a9d846001d96" }
9
+ let(:list_id) { "526d8e130a14a9d846001d97" }
10
+ let(:card_id) { "526d8f19ddb279532e005259" }
11
+
12
+ before do
13
+ @board = Fabricate(:board)
14
+ @board_2 = Fabricate(:board, name: "My Other Board")
15
+ @list = Fabricate(:list)
16
+ @card = Fabricate(:card)
17
+ @comment = Fabricate(:comment)
18
+ @member = Fabricate(:member)
19
+ end
20
+
21
+ after { database_cleanup }
22
+
23
+ describe "#boards" do
24
+ subject { capture_io { described_class.new.boards }.join }
25
+
26
+ context "when boards exist" do
27
+ it "returns a list of boards" do
28
+ subject.must_match /Test Board/
29
+ subject.must_match /Other Board/
30
+ end
31
+ end
32
+
33
+ context "when no boards exist" do
34
+ before { Troo::BoardRetrieval.stubs(:all).returns([]) }
35
+
36
+ it "returns a polite message" do
37
+ subject.must_match /Boards not found./
38
+ end
39
+ end
40
+ end
41
+
42
+ describe "#board" do
43
+ subject { capture_io { described_class.new.board(board_id) }.join }
44
+
45
+ context "when a board_id was provided" do
46
+ context "and the board exists" do
47
+ it "returns the board with all lists and all cards" do
48
+ subject.must_match /Test Board/
49
+ subject.must_match /Test List/
50
+ subject.must_match /Test Card/
51
+ end
52
+ end
53
+
54
+ context "and the board does not exist" do
55
+ before { Troo::BoardRetrieval.stubs(:retrieve).returns() }
56
+
57
+ it "returns a polite message" do
58
+ subject.must_match /Board not found./
59
+ end
60
+ end
61
+ end
62
+
63
+ context "when a board_id was not provided" do
64
+ let(:board_id) { }
65
+
66
+ context "and the default board is set" do
67
+ before { Troo::BoardRetrieval.stubs(:retrieve).returns(@board) }
68
+
69
+ it "returns the board with all lists and all cards" do
70
+ subject.must_match /Test Board/
71
+ subject.must_match /Test List/
72
+ subject.must_match /Test Card/
73
+ end
74
+ end
75
+
76
+ context "and the default board is not set" do
77
+ before { Troo::BoardRetrieval.stubs(:retrieve).returns() }
78
+
79
+ it "returns a polite message" do
80
+ subject.must_match /set a default board first/
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ describe "#list" do
87
+ subject { capture_io { described_class.new.list(list_id) }.join }
88
+
89
+ context "when a list_id was provided" do
90
+ context "when the list exists" do
91
+ it "returns the list's board, the list and all cards" do
92
+ subject.must_match /Test Board/
93
+ subject.must_match /Test List/
94
+ subject.must_match /Test Card/
95
+ end
96
+ end
97
+
98
+ context "when the list does not exist" do
99
+ before { Troo::ListRetrieval.stubs(:retrieve).returns() }
100
+
101
+ it "returns a polite message" do
102
+ subject.must_match /List not found./
103
+ end
104
+ end
105
+ end
106
+
107
+ context "when a list_id was not provided" do
108
+ let(:list_id) { }
109
+
110
+ context "and the default list is set" do
111
+ before { Troo::ListRetrieval.stubs(:retrieve).returns(@list) }
112
+
113
+ it "returns the list's board, the list and all cards" do
114
+ subject.must_match /Test Board/
115
+ subject.must_match /Test List/
116
+ subject.must_match /Test Card/
117
+ end
118
+ end
119
+
120
+ context "and the default list is not set" do
121
+ before { Troo::ListRetrieval.stubs(:retrieve).returns() }
122
+
123
+ it "returns a polite message" do
124
+ subject.must_match /set a default list first/
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ describe "#card" do
131
+ subject { capture_io { described_class.new.card(card_id) }.join }
132
+
133
+ context "when a card_id was provided" do
134
+ context "when the card exists" do
135
+ before { @comment.delete }
136
+
137
+ it "returns the card details" do
138
+ subject.must_match /\(67\) My Test Card/
139
+ subject.must_match /some description/
140
+ subject.must_match /Metadata/
141
+ subject.must_match /Tue, Dec 17 at 21:48/
142
+ end
143
+ end
144
+
145
+ context "when the card does not exist" do
146
+ before { Troo::CardRetrieval.stubs(:retrieve).returns() }
147
+
148
+ it "returns a polite message" do
149
+ subject.must_match /Card not found./
150
+ end
151
+ end
152
+ end
153
+
154
+ context "when a card_id was not provided" do
155
+ let(:card_id) { }
156
+
157
+ context "and the default card is set" do
158
+ before { Troo::CardRetrieval.stubs(:retrieve).returns(@card) }
159
+
160
+ it "returns the card details" do
161
+ subject.must_match /\(67\) My Test Card/
162
+ subject.must_match /some description/
163
+ subject.must_match /Metadata/
164
+ subject.must_match /Tue, Dec 17 at 21:48/
165
+ end
166
+ end
167
+
168
+ context "and the default card is not set" do
169
+ before { Troo::CardRetrieval.stubs(:retrieve).returns() }
170
+
171
+ it "returns a polite message" do
172
+ subject.must_match /set a default card first/
173
+ end
174
+ end
175
+ end
176
+ end
177
+
178
+ describe "#comments" do
179
+ subject { capture_io { described_class.new.comments(card_id) }.join }
180
+
181
+ context "when a card_id was provided" do
182
+ context "when the card exists" do
183
+ it "returns the card and all comments" do
184
+ subject.must_match /\(67\) My Test Card/
185
+ subject.must_match /My Test Comment/
186
+ end
187
+ end
188
+
189
+ context "when the card does not exist" do
190
+ before { Troo::CardRetrieval.stubs(:retrieve).returns() }
191
+
192
+ it "returns a polite message" do
193
+ subject.must_match /Card not found./
194
+ end
195
+ end
196
+ end
197
+
198
+ context "when a card_id was not provided" do
199
+ let(:card_id) { }
200
+
201
+ context "and the default card is set" do
202
+ before { Troo::CardRetrieval.stubs(:retrieve).returns(@card) }
203
+
204
+ it "returns the card and all comments" do
205
+ subject.must_match /\(67\) My Test Card/
206
+ subject.must_match /My Test Comment/
207
+ end
208
+ end
209
+
210
+ context "and the default card is not set" do
211
+ before { Troo::CardRetrieval.stubs(:retrieve).returns() }
212
+
213
+ it "returns a polite message" do
214
+ subject.must_match /set a default card first/
215
+ end
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,21 @@
1
+ require_relative "../../../test_helper"
2
+ require "thor"
3
+
4
+ module Troo
5
+ module CLI
6
+ describe ThorFixes do
7
+ let(:described_class) { ThorFixes }
8
+
9
+ describe ".banner" do
10
+ let(:command) { OpenStruct.new(usage: "some usage") }
11
+
12
+ before { File.stubs(:basename).returns("troo") }
13
+ subject { described_class.banner(command) }
14
+
15
+ it "should override Thor to provide proper subcommand help" do
16
+ subject.must_equal("troo some usage")
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,126 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe BoardDecorator do
5
+ let(:described_class) { BoardDecorator }
6
+ let(:default) { true }
7
+ let(:options) { {} }
8
+
9
+ before { @board = Fabricate(:board, default: default) }
10
+ after { database_cleanup }
11
+
12
+ describe "#initialize" do
13
+ subject { described_class.new(@board, options) }
14
+
15
+ it "assigns the board to an instance variable" do
16
+ subject.instance_variable_get("@board").must_equal(@board)
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(@board, options).short }
26
+
27
+ it "returns a one line overview of the board" do
28
+ subject.must_equal(" * \e[34m\e[4m(1) \e[0m\e[34m\e[4mMy Test Board\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 Board\n")
36
+ end
37
+ end
38
+ end
39
+
40
+ describe "#name_str" do
41
+ subject { described_class.new(@board).name_str }
42
+
43
+ it "returns the formatted board name" do
44
+ subject.must_equal("\e[34m\e[4mMy Test Board\e[0m")
45
+ end
46
+ end
47
+
48
+ describe "#default_str" do
49
+ subject { described_class.new(@board).default_str }
50
+
51
+ it "returns the formatted board default indicator" do
52
+ subject.must_equal(" * ")
53
+ end
54
+ end
55
+
56
+ describe "#id_str" do
57
+ subject { described_class.new(@board).id_str }
58
+
59
+ it "returns the formatted board id" do
60
+ subject.must_equal("\e[34m\e[4m(1) \e[0m")
61
+ end
62
+ end
63
+
64
+ describe "#description" do
65
+ subject { described_class.new(@board).description }
66
+
67
+ context "when the board has a description" do
68
+ it "returns the board description" do
69
+ subject.must_equal(@board.description)
70
+ end
71
+ end
72
+
73
+ context "when the board has no description" do
74
+ before { @board.stubs(:description).returns(nil) }
75
+
76
+ it "returns N/A" do
77
+ subject.must_equal("N/A")
78
+ end
79
+ end
80
+ end
81
+
82
+ describe "#name" do
83
+ subject { described_class.new(@board).name }
84
+
85
+ context "when the board has a name" do
86
+ it "returns the board name" do
87
+ subject.must_equal(@board.name)
88
+ end
89
+ end
90
+
91
+ context "when the board has no name" do
92
+ before { @board.stubs(:name).returns(nil) }
93
+
94
+ it "returns N/A" do
95
+ subject.must_equal("N/A")
96
+ end
97
+ end
98
+ end
99
+
100
+ describe "#default" do
101
+ subject { described_class.new(@board).default }
102
+
103
+ context "when default" do
104
+ it "return an indicator" do
105
+ subject.must_equal("*")
106
+ end
107
+ end
108
+
109
+ context "when not default" do
110
+ let(:default) { false }
111
+
112
+ it "returns nothing" do
113
+ subject.must_equal("")
114
+ end
115
+ end
116
+ end
117
+
118
+ describe "#id" do
119
+ subject { described_class.new(@board).id }
120
+
121
+ it "returns the board id" do
122
+ subject.must_equal(@board.id.to_s)
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,77 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe BoardPresenter do
5
+ let(:described_class) { BoardPresenter }
6
+ let(:options) { { } }
7
+
8
+ before do
9
+ @board = Fabricate(:board)
10
+ @list = Fabricate(:list)
11
+ @card = Fabricate(:card)
12
+ end
13
+
14
+ after { database_cleanup }
15
+
16
+ describe "#initialize" do
17
+ subject { described_class.new(@board, options) }
18
+
19
+ it "assigns the board to an instance variable" do
20
+ subject.instance_variable_get("@board").must_equal(@board)
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_all" do
29
+ subject { capture_io { described_class.new(@board, options).render_all }.join }
30
+
31
+ context "when the board has lists" do
32
+ it "renders the view" do
33
+ subject.must_match /My Test Board/
34
+ subject.must_match /My Test List/
35
+ end
36
+ end
37
+
38
+ context "when the board has no lists" do
39
+ before { @list.delete }
40
+
41
+ it "returns a polite message" do
42
+ subject.must_match /No lists were found./
43
+ end
44
+ end
45
+ end
46
+
47
+ describe "#render_show" do
48
+ subject { capture_io { described_class.new(@board, options).render_show }.join }
49
+
50
+ context "when the board has lists" do
51
+ context "and the list has cards" do
52
+ it "renders the view" do
53
+ subject.must_match /My Test Board/
54
+ subject.must_match /My Test List/
55
+ subject.must_match /My Test Card/
56
+ end
57
+ end
58
+
59
+ context "and the list has no cards" do
60
+ before { @card.delete }
61
+
62
+ it "returns a polite message" do
63
+ subject.must_match /No cards were found./
64
+ end
65
+ end
66
+ end
67
+
68
+ context "when the board has no lists" do
69
+ before { @board.stubs(:lists).returns([]) }
70
+
71
+ it "returns a polite message" do
72
+ subject.must_match /No lists were found./
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end