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,50 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe Board do
5
+ let(:described_class) { Board }
6
+ let(:described_instance) { Fabricate.build(:board) }
7
+
8
+ subject { described_instance }
9
+
10
+ context "attributes" do
11
+ it "should have a name attribute" do
12
+ subject.name.must_equal "My Test Board"
13
+ end
14
+
15
+ it "should have a description attribute" do
16
+ subject.description.must_equal "A very brief description..."
17
+ end
18
+
19
+ it "should have a default attribute" do
20
+ subject.default.must_equal false
21
+ end
22
+
23
+ it "should have a closed attribute" do
24
+ subject.closed.must_equal false
25
+ end
26
+
27
+ it "should have an external_board_id attribute" do
28
+ subject.external_board_id.must_equal "526d8e130a14a9d846001d96"
29
+ end
30
+ end
31
+
32
+ context "associations" do
33
+ before do
34
+ @list = Fabricate(:list)
35
+ @card = Fabricate(:card)
36
+ end
37
+
38
+ after { database_cleanup }
39
+
40
+ it "can have many lists" do
41
+ subject.lists.size.must_equal 1
42
+ end
43
+
44
+ it "can have many cards" do
45
+ subject.cards.size.must_equal 1
46
+ end
47
+ end
48
+ end
49
+ end
50
+
@@ -0,0 +1,60 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe CardPersistence do
5
+ let(:described_class) { CardPersistence }
6
+ let(:resource) { OpenStruct.new({
7
+ id: "526d8f19ddb279532e005259",
8
+ name: resource_name,
9
+ closed: false
10
+ }) }
11
+ let(:resource_name) { "My Test Card" }
12
+ let(:options) { {} }
13
+
14
+ before { @card = Fabricate(:card) }
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").must_equal(resource)
22
+ end
23
+
24
+ it "assigns the options to an instance variable" do
25
+ subject.instance_variable_get("@options").must_equal(options)
26
+ end
27
+ end
28
+
29
+ describe "#persist" do
30
+ subject { described_class.for(resource, options) }
31
+
32
+ context "when there is already a local copy" do
33
+ context "and the local copy is identical" do
34
+ it "returns the local copy" do
35
+ subject.must_equal(@card)
36
+ end
37
+ end
38
+
39
+ context "and the local copy is out of date" do
40
+ let(:resource_name) { "My Renamed Card" }
41
+
42
+ it "updates and returns the new local copy" do
43
+ subject.name.must_equal(resource_name)
44
+ end
45
+ end
46
+ end
47
+
48
+ context "when there is not already a local copy" do
49
+ let(:resource_name) { "My New Test Card" }
50
+
51
+ before { database_cleanup }
52
+
53
+ it "creates and returns the new local copy" do
54
+ subject.name.must_equal(resource_name)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+
@@ -0,0 +1,101 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe CardRetrieval do
5
+ let(:described_class) { CardRetrieval }
6
+ let(:default) { true }
7
+ let(:card_name) { "My Test Card" }
8
+
9
+ before { @card = Fabricate(:card, default: default, name: card_name) }
10
+ after { database_cleanup }
11
+
12
+ describe ".all" do
13
+ subject { described_class.all }
14
+
15
+ it "retrieves all locally stored cards" do
16
+ subject.size.must_equal 1
17
+ end
18
+ end
19
+
20
+ describe ".default" do
21
+ subject { described_class.default }
22
+
23
+ context "when default is set" do
24
+ it "returns the default" do
25
+ subject.must_equal @card
26
+ end
27
+ end
28
+
29
+ context "when default is not set" do
30
+ let(:default) { false }
31
+
32
+ it { subject.must_equal(nil) }
33
+ end
34
+ end
35
+
36
+ describe ".retrieve" do
37
+ context "without an ID" do
38
+ subject { described_class.retrieve }
39
+
40
+ context "when default is set" do
41
+ it "returns the default" do
42
+ subject.must_equal @card
43
+ end
44
+ end
45
+
46
+ context "when default is not set" do
47
+ let(:default) { false }
48
+
49
+ it { subject.must_equal(nil) }
50
+ end
51
+ end
52
+
53
+ context "with an ID" do
54
+ subject { described_class.retrieve(id) }
55
+
56
+ context "local retrieval by short_id" do
57
+ let(:id) { 67 }
58
+
59
+ it "returns the correct card" do
60
+ subject.name.must_equal("My Test Card")
61
+ end
62
+ end
63
+
64
+ context "local retrieval by database ID" do
65
+ let(:id) { @card.id }
66
+
67
+ it "returns the correct card" do
68
+ subject.name.must_equal("My Test Card")
69
+ end
70
+ end
71
+
72
+ context "local retrieval by external ID" do
73
+ let(:id) { "526d8f19ddb279532e005259" }
74
+
75
+ it "returns the correct card" do
76
+ subject.name.must_equal("My Test Card")
77
+ end
78
+ end
79
+
80
+ context "remote retrieval by either ID" do
81
+ let(:id) { "526d_remote_card_005259" }
82
+ let(:card_name) { "My Remote Test Card" }
83
+
84
+ before { External::Card.stubs(:fetch).returns([@card]) }
85
+
86
+ it "returns the correct card" do
87
+ subject.name.must_equal("My Remote Test Card")
88
+ end
89
+ end
90
+
91
+ context "when the ID cannot be found" do
92
+ let(:id) { "not_found_id" }
93
+
94
+ before { External::Card.stubs(:fetch).returns([]) }
95
+
96
+ it { subject.must_equal(nil) }
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,102 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe Card do
5
+ let(:described_class) { Card }
6
+ let(:described_instance) { Fabricate.build(:card) }
7
+
8
+ subject { described_instance }
9
+
10
+ context "attributes" do
11
+ it "should have a short_id attribute" do
12
+ subject.short_id.must_equal "67"
13
+ end
14
+
15
+ it "should have a name attribute" do
16
+ subject.name.must_equal "My Test Card"
17
+ end
18
+
19
+ it "should have a desc attribute" do
20
+ subject.desc.must_equal "some description"
21
+ end
22
+
23
+ it "should have a url attribute" do
24
+ subject.url.must_equal "some trello url"
25
+ end
26
+
27
+ it "should have an external_member_ids attribute" do
28
+ subject.external_member_ids.must_equal(["5195fdb5a8c01a2318004f5d"])
29
+ end
30
+
31
+ it "should have a position attribute" do
32
+ subject.position.must_equal 16
33
+ end
34
+
35
+ it "should have a last_activity_date attribute" do
36
+ subject.last_activity_date.must_equal "2013-12-17 21:48:09 UTC"
37
+ end
38
+
39
+ it "should have a default attribute" do
40
+ subject.default.must_equal false
41
+ end
42
+
43
+ it "should have a closed attribute" do
44
+ subject.closed.must_equal false
45
+ end
46
+
47
+ it "should have an external_board_id attribute" do
48
+ subject.external_board_id.must_equal "526d8e130a14a9d846001d96"
49
+ end
50
+
51
+ it "should have an external_list_id attribute" do
52
+ subject.external_list_id.must_equal "526d8e130a14a9d846001d97"
53
+ end
54
+
55
+ it "should have an external_card_id attribute" do
56
+ subject.external_card_id.must_equal "526d8f19ddb279532e005259"
57
+ end
58
+ end
59
+
60
+ context "associations" do
61
+ before do
62
+ @board = Fabricate(:board)
63
+ @list = Fabricate(:list)
64
+ @comment = Fabricate(:comment)
65
+ @member = Fabricate(:member)
66
+ end
67
+
68
+ after { database_cleanup }
69
+
70
+ it "belongs to a board" do
71
+ subject.board.must_equal @board
72
+ end
73
+
74
+ it "belongs to a list" do
75
+ subject.list.must_equal @list
76
+ end
77
+
78
+ it "can have many comments" do
79
+ subject.comments.size.must_equal 1
80
+ end
81
+
82
+ it "can have many comments" do
83
+ subject.recent_comments.size.must_equal 1
84
+ end
85
+
86
+ context "when the card has members" do
87
+ it "returns the collection of members" do
88
+ subject.members.size.must_equal 1
89
+ end
90
+ end
91
+
92
+ context "when the card has no members" do
93
+ before { subject.stubs(:external_member_ids).returns([]) }
94
+
95
+ it "returns an empty collection" do
96
+ subject.members.size.must_equal 0
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+
@@ -0,0 +1,65 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe CommentPersistence do
5
+ let(:described_class) { CommentPersistence }
6
+ let(:resource) { OpenStruct.new({
7
+ id: "51f9277b2822b8654f0023af",
8
+ date: "2013-12-17 22:01:13 UTC",
9
+ data: {
10
+ "text" => resource_text, "board" => {
11
+ "id" => "526d8e130a14a9d846001d96"
12
+ }, "card" => {
13
+ "id" => "526d8f19ddb279532e005259"
14
+ } }
15
+ }) }
16
+ let(:resource_text) { "My Test Comment" }
17
+ let(:options) { {} }
18
+
19
+ before { @comment = Fabricate(:comment) }
20
+ after { database_cleanup }
21
+
22
+ describe ".initialize" do
23
+ subject { described_class.new(resource, options) }
24
+
25
+ it "assigns the resource to an instance variable" do
26
+ subject.instance_variable_get("@resource").must_equal(resource)
27
+ end
28
+
29
+ it "assigns the options to an instance variable" do
30
+ subject.instance_variable_get("@options").must_equal(options)
31
+ end
32
+ end
33
+
34
+ describe "#persist" do
35
+ subject { described_class.for(resource, options) }
36
+
37
+ context "when there is already a local copy" do
38
+ context "and the local copy is identical" do
39
+ it "returns the local copy" do
40
+ subject.must_equal(@comment)
41
+ end
42
+ end
43
+
44
+ context "and the local copy is out of date" do
45
+ let(:resource_text) { "My Renamed Comment" }
46
+
47
+ it "updates and returns the new local copy" do
48
+ subject.text.must_equal(resource_text)
49
+ end
50
+ end
51
+ end
52
+
53
+ context "when there is not already a local copy" do
54
+ let(:resource_text) { "My New Test Comment" }
55
+
56
+ before { database_cleanup }
57
+
58
+ it "creates and returns the new local copy" do
59
+ subject.text.must_equal(resource_text)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+
@@ -0,0 +1,46 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe CommentRetrieval do
5
+ let(:described_class) { CommentRetrieval }
6
+
7
+ before { @comment = Fabricate(:comment) }
8
+ after { database_cleanup }
9
+
10
+ describe ".all" do
11
+ subject { described_class.all }
12
+
13
+ it "retrieves all locally stored comments" do
14
+ subject.size.must_equal 1
15
+ end
16
+ end
17
+
18
+ describe ".retrieve" do
19
+ subject { described_class.retrieve(id) }
20
+
21
+ context "local retrieval by database ID" do
22
+ let(:id) { @comment.id }
23
+
24
+ it "returns the correct comment" do
25
+ subject.text.must_equal("My Test Comment")
26
+ end
27
+ end
28
+
29
+ context "local retrieval by external ID" do
30
+ let(:id) { "51f9277b2822b8654f0023af" }
31
+
32
+ it "returns the correct comment" do
33
+ subject.text.must_equal("My Test Comment")
34
+ end
35
+ end
36
+
37
+ context "when the ID cannot be found" do
38
+ let(:id) { "not_found_id" }
39
+
40
+ before { External::Comment.stubs(:fetch).returns([]) }
41
+
42
+ it { subject.must_equal(nil) }
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,59 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ module Troo
4
+ describe Comment do
5
+ let(:described_class) { Comment }
6
+ let(:described_instance) { Fabricate.build(:comment) }
7
+
8
+ subject { described_instance }
9
+
10
+ context "attributes" do
11
+ it "should have a text attribute" do
12
+ subject.text.must_equal "My Test Comment"
13
+ end
14
+
15
+ it "should have a date attribute" do
16
+ subject.date.must_equal "2013-12-17 22:01:13 UTC"
17
+ end
18
+
19
+ it "should have an external_board_id attribute" do
20
+ subject.external_board_id.must_equal "526d8e130a14a9d846001d96"
21
+ end
22
+
23
+ it "should have an external_card_id attribute" do
24
+ subject.external_card_id.must_equal "526d8f19ddb279532e005259"
25
+ end
26
+
27
+ it "should have an external_comment_id attribute" do
28
+ subject.external_comment_id.must_equal "51f9277b2822b8654f0023af"
29
+ end
30
+
31
+ it "should have a external_member_id attribute" do
32
+ subject.external_member_id.must_equal "5195fdb5a8c01a2318004f5d"
33
+ end
34
+ end
35
+
36
+ context "associations" do
37
+ before do
38
+ @board = Fabricate(:board)
39
+ @card = Fabricate(:card)
40
+ @member = Fabricate(:member)
41
+ end
42
+
43
+ after { database_cleanup }
44
+
45
+ it "belongs to a board" do
46
+ subject.board.must_equal @board
47
+ end
48
+
49
+ it "belongs to a card" do
50
+ subject.card.must_equal @card
51
+ end
52
+
53
+ it "belongs to a member" do
54
+ subject.member.must_equal @member
55
+ end
56
+ end
57
+ end
58
+ end
59
+