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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +2 -0
- data/Guardfile +3 -1
- data/Rakefile +7 -0
- data/bin/troo +3 -8
- data/config/.gitkeep +0 -0
- data/config/cucumber.yml +8 -0
- data/features/add/board.feature +26 -0
- data/features/add/card.feature +34 -0
- data/features/add/comment.feature +21 -0
- data/features/add/list.feature +24 -0
- data/features/cleanup.feature +13 -0
- data/features/default/board.feature +21 -0
- data/features/default/card.feature +21 -0
- data/features/default/list.feature +21 -0
- data/features/refresh/all.feature +7 -0
- data/features/refresh/board.feature +26 -0
- data/features/refresh/card.feature +27 -0
- data/features/refresh/list.feature +27 -0
- data/features/show/board.feature +32 -0
- data/features/show/card.feature +62 -0
- data/features/show/comment.feature +39 -0
- data/features/show/list.feature +37 -0
- data/features/status.feature +46 -1
- data/features/step_definitions/fabrication_steps.rb +34 -0
- data/features/step_definitions/troo_steps.rb +16 -0
- data/features/support/env.rb +22 -24
- data/features/troo.feature +31 -1
- data/lib/troo/actions/create_board.rb +10 -7
- data/lib/troo/actions/create_card.rb +5 -4
- data/lib/troo/actions/create_comment.rb +15 -13
- data/lib/troo/actions/create_list.rb +5 -4
- data/lib/troo/actions/move_card.rb +4 -3
- data/lib/troo/{external/board_adaptor.rb → adaptors/board.rb} +3 -14
- data/lib/troo/{external/card_adaptor.rb → adaptors/card.rb} +4 -15
- data/lib/troo/{external/comment_adaptor.rb → adaptors/comment.rb} +6 -17
- data/lib/troo/{external/list_adaptor.rb → adaptors/list.rb} +3 -14
- data/lib/troo/{external/member_adaptor.rb → adaptors/member.rb} +3 -14
- data/lib/troo/adaptors/resource.rb +17 -0
- data/lib/troo/cli/add.rb +53 -0
- data/lib/troo/cli/default.rb +25 -0
- data/lib/troo/cli/main.rb +46 -0
- data/lib/troo/cli/refresh.rb +31 -0
- data/lib/troo/cli/show.rb +41 -0
- data/lib/troo/cli/thor_fixes.rb +13 -0
- data/lib/troo/commands/add/board.rb +26 -0
- data/lib/troo/commands/add/card.rb +33 -0
- data/lib/troo/commands/add/comment.rb +33 -0
- data/lib/troo/commands/add/list.rb +33 -0
- data/lib/troo/commands/add/resource.rb +21 -0
- data/lib/troo/commands/commands.rb +28 -0
- data/lib/troo/commands/default/board.rb +25 -0
- data/lib/troo/commands/default/card.rb +25 -0
- data/lib/troo/commands/default/list.rb +25 -0
- data/lib/troo/commands/default/resource.rb +26 -0
- data/lib/troo/commands/refresh/all.rb +41 -0
- data/lib/troo/commands/refresh/board.rb +28 -0
- data/lib/troo/commands/refresh/card.rb +29 -0
- data/lib/troo/commands/refresh/list.rb +29 -0
- data/lib/troo/commands/refresh/resource.rb +42 -0
- data/lib/troo/commands/show/board.rb +13 -0
- data/lib/troo/commands/show/boards.rb +35 -0
- data/lib/troo/commands/show/card.rb +13 -0
- data/lib/troo/commands/show/comments.rb +21 -0
- data/lib/troo/commands/show/list.rb +13 -0
- data/lib/troo/commands/show/resource.rb +41 -0
- data/lib/troo/commands/status/board.rb +30 -0
- data/lib/troo/commands/status/card.rb +30 -0
- data/lib/troo/commands/status/list.rb +30 -0
- data/lib/troo/commands/status/resource.rb +34 -0
- data/lib/troo/decorators/board.rb +66 -0
- data/lib/troo/decorators/card.rb +105 -0
- data/lib/troo/decorators/comment.rb +36 -0
- data/lib/troo/decorators/list.rb +60 -0
- data/lib/troo/decorators/member.rb +28 -0
- data/lib/troo/external/board.rb +14 -26
- data/lib/troo/external/card.rb +2 -19
- data/lib/troo/external/comment.rb +5 -23
- data/lib/troo/external/list.rb +2 -20
- data/lib/troo/external/member.rb +2 -20
- data/lib/troo/external/resource.rb +21 -6
- data/lib/troo/helpers/command_helpers.rb +37 -0
- data/lib/troo/{display → helpers}/decorator_helpers.rb +23 -17
- data/lib/troo/{models → helpers}/model_helpers.rb +1 -1
- data/lib/troo/models/behaviours/set_default.rb +49 -0
- data/lib/troo/models/board.rb +10 -7
- data/lib/troo/models/card.rb +33 -15
- data/lib/troo/models/comment.rb +8 -5
- data/lib/troo/models/list.rb +10 -6
- data/lib/troo/models/member.rb +7 -4
- data/lib/troo/models/persistence/board.rb +19 -0
- data/lib/troo/models/persistence/card.rb +19 -0
- data/lib/troo/models/persistence/comment.rb +19 -0
- data/lib/troo/models/persistence/list.rb +19 -0
- data/lib/troo/models/persistence/member.rb +19 -0
- data/lib/troo/models/persistence/resource.rb +50 -0
- data/lib/troo/models/refresh.rb +1 -1
- data/lib/troo/models/remote/comment.rb +21 -0
- data/lib/troo/models/remote/resource.rb +25 -0
- data/lib/troo/models/retrieval/board.rb +29 -0
- data/lib/troo/models/retrieval/card.rb +33 -0
- data/lib/troo/models/retrieval/comment.rb +25 -0
- data/lib/troo/models/retrieval/list.rb +29 -0
- data/lib/troo/models/retrieval/member.rb +25 -0
- data/lib/troo/models/retrieval/resource.rb +36 -0
- data/lib/troo/presentation/sentence.rb +57 -0
- data/lib/troo/presentation/template.rb +4 -3
- data/lib/troo/presenters/board.rb +81 -0
- data/lib/troo/presenters/card.rb +30 -0
- data/lib/troo/presenters/comment.rb +38 -0
- data/lib/troo/presenters/list.rb +44 -0
- data/lib/troo/presenters/member.rb +32 -0
- data/lib/troo/troo.rb +79 -65
- data/lib/troo/version.rb +1 -2
- data/lib/troo.rb +36 -8
- data/test/lib/troo/actions/create_board_test.rb +34 -15
- data/test/lib/troo/actions/create_card_test.rb +35 -18
- data/test/lib/troo/actions/create_comment_test.rb +38 -16
- data/test/lib/troo/actions/create_list_test.rb +31 -15
- data/test/lib/troo/actions/move_card_test.rb +23 -15
- data/test/lib/troo/adaptors/board_test.rb +38 -0
- data/test/lib/troo/adaptors/card_test.rb +49 -0
- data/test/lib/troo/adaptors/comment_test.rb +41 -0
- data/test/lib/troo/adaptors/list_test.rb +38 -0
- data/test/lib/troo/adaptors/member_test.rb +44 -0
- data/test/lib/troo/commands/add/board_test.rb +43 -0
- data/test/lib/troo/commands/add/card_test.rb +44 -0
- data/test/lib/troo/commands/add/comment_test.rb +44 -0
- data/test/lib/troo/commands/add/list_test.rb +44 -0
- data/test/lib/troo/commands/add/resource_test.rb +25 -0
- data/test/lib/troo/commands/default/board_test.rb +37 -0
- data/test/lib/troo/commands/default/card_test.rb +37 -0
- data/test/lib/troo/commands/default/list_test.rb +37 -0
- data/test/lib/troo/commands/default/resource_test.rb +20 -0
- data/test/lib/troo/commands/refresh/all_test.rb +39 -0
- data/test/lib/troo/commands/refresh/board_test.rb +62 -0
- data/test/lib/troo/commands/refresh/card_test.rb +62 -0
- data/test/lib/troo/commands/refresh/list_test.rb +62 -0
- data/test/lib/troo/commands/refresh/resource_test.rb +20 -0
- data/test/lib/troo/commands/show/board_test.rb +65 -0
- data/test/lib/troo/commands/show/boards_test.rb +36 -0
- data/test/lib/troo/commands/show/card_test.rb +64 -0
- data/test/lib/troo/commands/show/comments_test.rb +64 -0
- data/test/lib/troo/commands/show/list_test.rb +64 -0
- data/test/lib/troo/commands/show/resource_test.rb +25 -0
- data/test/lib/troo/commands/status/board_test.rb +43 -0
- data/test/lib/troo/commands/status/card_test.rb +43 -0
- data/test/lib/troo/commands/status/list_test.rb +43 -0
- data/test/lib/troo/commands/status/resource_test.rb +19 -0
- data/test/lib/troo/decorators/board_test.rb +129 -0
- data/test/lib/troo/decorators/card_test.rb +237 -0
- data/test/lib/troo/decorators/comment_test.rb +74 -0
- data/test/lib/troo/decorators/list_test.rb +102 -0
- data/test/lib/troo/decorators/member_test.rb +50 -0
- data/test/lib/troo/external/board_test.rb +74 -41
- data/test/lib/troo/external/card_test.rb +49 -37
- data/test/lib/troo/external/comment_test.rb +43 -33
- data/test/lib/troo/external/list_test.rb +37 -30
- data/test/lib/troo/external/member_test.rb +37 -30
- data/test/lib/troo/external/resource_test.rb +18 -1
- data/test/lib/troo/helpers/command_helpers_test.rb +82 -0
- data/test/lib/troo/{display → helpers}/decorator_helpers_test.rb +6 -6
- data/test/lib/troo/helpers/model_helpers_test.rb +103 -0
- data/test/lib/troo/models/behaviours/set_default_test.rb +54 -0
- data/test/lib/troo/models/board_test.rb +13 -14
- data/test/lib/troo/models/card_test.rb +64 -33
- data/test/lib/troo/models/comment_test.rb +18 -19
- data/test/lib/troo/models/list_test.rb +15 -15
- data/test/lib/troo/models/member_test.rb +18 -18
- data/test/lib/troo/models/persistence/board_test.rb +62 -0
- data/test/lib/troo/models/persistence/card_test.rb +61 -0
- data/test/lib/troo/models/persistence/comment_test.rb +69 -0
- data/test/lib/troo/models/persistence/list_test.rb +60 -0
- data/test/lib/troo/models/persistence/member_test.rb +60 -0
- data/test/lib/troo/models/refresh_test.rb +12 -11
- data/test/lib/troo/models/remote/comment_test.rb +56 -0
- data/test/lib/troo/models/remote/resource_test.rb +26 -0
- data/test/lib/troo/models/retrieval/board_test.rb +93 -0
- data/test/lib/troo/models/retrieval/card_test.rb +101 -0
- data/test/lib/troo/models/retrieval/comment_test.rb +46 -0
- data/test/lib/troo/models/retrieval/list_test.rb +93 -0
- data/test/lib/troo/models/retrieval/member_test.rb +58 -0
- data/test/lib/troo/presentation/sentence_test.rb +57 -0
- data/test/lib/troo/presentation/template_test.rb +17 -16
- data/test/lib/troo/presenters/board_test.rb +79 -0
- data/test/lib/troo/presenters/card_test.rb +41 -0
- data/test/lib/troo/presenters/comment_test.rb +49 -0
- data/test/lib/troo/presenters/list_test.rb +50 -0
- data/test/lib/troo/presenters/member_test.rb +40 -0
- data/test/support/fabrication.rb +31 -32
- data/test/support/vcr_setup.rb +7 -9
- data/test/system_test.sh +55 -0
- data/test/test_helper.rb +10 -10
- data/troo.gemspec +1 -0
- metadata +232 -134
- data/features/add_board.feature +0 -1
- data/features/add_card.feature +0 -1
- data/features/add_comment.feature +0 -1
- data/features/add_list.feature +0 -1
- data/features/move_card_to_list.feature +0 -1
- data/features/refresh.feature +0 -1
- data/features/set_default.feature +0 -7
- data/features/show_board.feature +0 -1
- data/features/show_boards.feature +0 -1
- data/features/show_card.feature +0 -1
- data/features/show_comments.feature +0 -1
- data/features/show_list.feature +0 -1
- data/features/version.feature +0 -8
- data/lib/troo/actions/refresh_all.rb +0 -79
- data/lib/troo/actions/set_default.rb +0 -46
- data/lib/troo/cli/add_cli.rb +0 -83
- data/lib/troo/cli/cli_helpers.rb +0 -34
- data/lib/troo/cli/default_cli.rb +0 -32
- data/lib/troo/cli/main_cli.rb +0 -132
- data/lib/troo/cli/show_cli.rb +0 -64
- data/lib/troo/display/board_decorator.rb +0 -62
- data/lib/troo/display/board_presenter.rb +0 -71
- data/lib/troo/display/card_decorator.rb +0 -100
- data/lib/troo/display/card_presenter.rb +0 -27
- data/lib/troo/display/comment_decorator.rb +0 -33
- data/lib/troo/display/comment_presenter.rb +0 -31
- data/lib/troo/display/list_decorator.rb +0 -57
- data/lib/troo/display/list_presenter.rb +0 -41
- data/lib/troo/display/member_decorator.rb +0 -25
- data/lib/troo/display/member_presenter.rb +0 -59
- data/lib/troo/models/board_persistence.rb +0 -25
- data/lib/troo/models/board_retrieval.rb +0 -45
- data/lib/troo/models/card_persistence.rb +0 -25
- data/lib/troo/models/card_retrieval.rb +0 -49
- data/lib/troo/models/comment_persistence.rb +0 -25
- data/lib/troo/models/comment_retrieval.rb +0 -32
- data/lib/troo/models/list_persistence.rb +0 -25
- data/lib/troo/models/list_retrieval.rb +0 -45
- data/lib/troo/models/member_persistence.rb +0 -25
- data/lib/troo/models/member_retrieval.rb +0 -36
- data/lib/troo/models/persistence.rb +0 -39
- data/test/lib/troo/actions/refresh_all_test.rb +0 -68
- data/test/lib/troo/actions/set_default_test.rb +0 -44
- data/test/lib/troo/cli/add_cli_test.rb +0 -216
- data/test/lib/troo/cli/cli_helpers_test.rb +0 -24
- data/test/lib/troo/cli/default_cli_test.rb +0 -85
- data/test/lib/troo/cli/main_cli_test.rb +0 -234
- data/test/lib/troo/cli/show_cli_test.rb +0 -251
- data/test/lib/troo/display/board_decorator_test.rb +0 -126
- data/test/lib/troo/display/board_presenter_test.rb +0 -77
- data/test/lib/troo/display/card_decorator_test.rb +0 -213
- data/test/lib/troo/display/card_presenter_test.rb +0 -38
- data/test/lib/troo/display/comment_decorator_test.rb +0 -70
- data/test/lib/troo/display/comment_presenter_test.rb +0 -47
- data/test/lib/troo/display/list_decorator_test.rb +0 -98
- data/test/lib/troo/display/list_presenter_test.rb +0 -48
- data/test/lib/troo/display/member_decorator_test.rb +0 -47
- data/test/lib/troo/display/member_presenter_test.rb +0 -70
- data/test/lib/troo/external/board_adaptor_test.rb +0 -36
- data/test/lib/troo/external/card_adaptor_test.rb +0 -50
- data/test/lib/troo/external/comment_adaptor_test.rb +0 -41
- data/test/lib/troo/external/list_adaptor_test.rb +0 -38
- data/test/lib/troo/external/member_adaptor_test.rb +0 -44
- data/test/lib/troo/models/board_persistence_test.rb +0 -61
- data/test/lib/troo/models/board_retrieval_test.rb +0 -93
- data/test/lib/troo/models/card_persistence_test.rb +0 -60
- data/test/lib/troo/models/card_retrieval_test.rb +0 -101
- data/test/lib/troo/models/comment_persistence_test.rb +0 -65
- data/test/lib/troo/models/comment_retrieval_test.rb +0 -46
- data/test/lib/troo/models/list_persistence_test.rb +0 -60
- data/test/lib/troo/models/list_retrieval_test.rb +0 -93
- data/test/lib/troo/models/member_persistence_test.rb +0 -59
- data/test/lib/troo/models/member_retrieval_test.rb +0 -58
- data/test/lib/troo/models/model_helpers_test.rb +0 -103
- data/test/lib/troo/models/persistence_test.rb +0 -6
@@ -1,54 +1,71 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative '../../../test_helper'
|
2
2
|
|
3
3
|
module Troo
|
4
4
|
describe CreateCard do
|
5
5
|
let(:described_class) { CreateCard }
|
6
|
-
let(:list_id) {
|
7
|
-
let(:card_name) {
|
8
|
-
let(:description) {
|
6
|
+
let(:list_id) { '526d8e130a14a9d846001d97' }
|
7
|
+
let(:card_name) { 'My New Card' }
|
8
|
+
let(:description) { 'A description to get us started.' }
|
9
9
|
|
10
10
|
before do
|
11
11
|
@list = Fabricate(:list)
|
12
12
|
@card = Fabricate(:card, name: card_name, desc: description)
|
13
|
-
|
14
|
-
CardPersistence.stubs(:for).returns(@card)
|
13
|
+
Persistence::Card.stubs(:for).returns(@card)
|
15
14
|
end
|
16
15
|
|
17
16
|
after { database_cleanup }
|
18
17
|
|
19
|
-
describe
|
18
|
+
describe '.initialize' do
|
20
19
|
subject { described_class.new(@list, card_name, description) }
|
21
20
|
|
22
|
-
it
|
23
|
-
subject.instance_variable_get(
|
21
|
+
it 'assigns the list to an instance variable' do
|
22
|
+
subject.instance_variable_get('@list').must_equal(@list)
|
24
23
|
end
|
25
24
|
|
26
|
-
it
|
27
|
-
subject.instance_variable_get(
|
25
|
+
it 'assigns the name to an instance variable' do
|
26
|
+
subject.instance_variable_get('@name').must_equal(card_name)
|
28
27
|
end
|
29
28
|
|
30
|
-
it
|
31
|
-
subject.instance_variable_get(
|
29
|
+
it 'assigns the description to an instance variable' do
|
30
|
+
subject.instance_variable_get('@description')
|
31
|
+
.must_equal(description)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe
|
36
|
-
before
|
35
|
+
describe '.for' do
|
36
|
+
before do
|
37
|
+
VCR.insert_cassette(:create_card,
|
38
|
+
decode_compressed_response: true)
|
39
|
+
end
|
40
|
+
|
37
41
|
after { VCR.eject_cassette }
|
38
42
|
|
39
43
|
subject { described_class.for(@list, card_name, description) }
|
40
44
|
|
41
|
-
context
|
42
|
-
it
|
45
|
+
context 'when the card was created' do
|
46
|
+
it 'returns the new card' do
|
43
47
|
subject.must_equal(@card)
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
47
|
-
context
|
51
|
+
context 'when the card was not created' do
|
48
52
|
before { Trello::Card.stubs(:create).raises(Trello::Error) }
|
49
53
|
|
50
54
|
it { subject.must_equal false }
|
51
55
|
end
|
56
|
+
|
57
|
+
context 'when the access token is invalid' do
|
58
|
+
before do
|
59
|
+
Trello::Card.stubs(:create)
|
60
|
+
.raises(Trello::InvalidAccessToken)
|
61
|
+
end
|
62
|
+
|
63
|
+
subject { described_class.for(@list, card_name, description) }
|
64
|
+
|
65
|
+
it 'catches the exception and re-raises' do
|
66
|
+
proc { subject }.must_raise(Troo::InvalidAccessToken)
|
67
|
+
end
|
68
|
+
end
|
52
69
|
end
|
53
70
|
end
|
54
71
|
end
|
@@ -1,49 +1,71 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative '../../../test_helper'
|
2
2
|
|
3
3
|
module Troo
|
4
4
|
describe CreateComment do
|
5
5
|
let(:described_class) { CreateComment }
|
6
|
-
let(:card_id) {
|
7
|
-
let(:comment) {
|
6
|
+
let(:card_id) { '526d8f19ddb279532e005259' }
|
7
|
+
let(:comment) { 'Some much needed feedback...' }
|
8
8
|
|
9
9
|
before do
|
10
10
|
@card = Fabricate(:card)
|
11
11
|
@comment = Fabricate(:comment, text: comment)
|
12
|
-
|
13
|
-
CommentPersistence.stubs(:for).returns(@comment)
|
12
|
+
Persistence::Comment.stubs(:for).returns(@comment)
|
14
13
|
end
|
15
14
|
|
16
15
|
after { database_cleanup }
|
17
16
|
|
18
|
-
describe
|
17
|
+
describe '.initialize' do
|
19
18
|
subject { described_class.new(@card, comment) }
|
20
19
|
|
21
|
-
it
|
22
|
-
subject.instance_variable_get(
|
20
|
+
it 'assigns the card to an instance variable' do
|
21
|
+
subject.instance_variable_get('@card').must_equal(@card)
|
23
22
|
end
|
24
23
|
|
25
|
-
it
|
26
|
-
subject.instance_variable_get(
|
24
|
+
it 'assigns the comment to an instance variable' do
|
25
|
+
subject.instance_variable_get('@comment').must_equal(comment)
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
|
-
describe
|
31
|
-
before
|
29
|
+
describe '.for' do
|
30
|
+
before do
|
31
|
+
VCR.insert_cassette(:create_comment,
|
32
|
+
decode_compressed_response: true)
|
33
|
+
end
|
34
|
+
|
32
35
|
after { VCR.eject_cassette }
|
33
36
|
|
34
37
|
subject { described_class.for(@card, comment) }
|
35
38
|
|
36
|
-
context
|
37
|
-
it
|
39
|
+
context 'when the comment was created' do
|
40
|
+
it 'returns the new comment' do
|
38
41
|
subject.must_equal(@comment)
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
42
|
-
context
|
43
|
-
before
|
45
|
+
context 'when the comment was not created' do
|
46
|
+
before do
|
47
|
+
Trello::Card.any_instance.stubs(:add_comment)
|
48
|
+
.raises(Trello::Error)
|
49
|
+
end
|
44
50
|
|
45
51
|
it { subject.must_equal false }
|
46
52
|
end
|
53
|
+
|
54
|
+
context 'when the access token is invalid' do
|
55
|
+
let(:card) { stub }
|
56
|
+
|
57
|
+
before do
|
58
|
+
Trello::Card.stubs(:new).returns(card)
|
59
|
+
card.stubs(:update_fields).returns(card)
|
60
|
+
card.stubs(:add_comment).raises(Trello::InvalidAccessToken)
|
61
|
+
end
|
62
|
+
|
63
|
+
subject { described_class.for(@card, comment) }
|
64
|
+
|
65
|
+
it 'catches the exception and re-raises' do
|
66
|
+
proc { subject }.must_raise(Troo::InvalidAccessToken)
|
67
|
+
end
|
68
|
+
end
|
47
69
|
end
|
48
70
|
end
|
49
71
|
end
|
@@ -1,49 +1,65 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative '../../../test_helper'
|
2
2
|
|
3
3
|
module Troo
|
4
4
|
describe CreateList do
|
5
5
|
let(:described_class) { CreateList }
|
6
|
-
let(:board_id) {
|
7
|
-
let(:list_name) {
|
6
|
+
let(:board_id) { '526d8e130a14a9d846001d96' }
|
7
|
+
let(:list_name) { 'My New List' }
|
8
8
|
|
9
9
|
before do
|
10
10
|
@board = Fabricate(:board)
|
11
11
|
@list = Fabricate(:list, name: list_name)
|
12
|
-
|
13
|
-
ListPersistence.stubs(:for).returns(@list)
|
12
|
+
Persistence::List.stubs(:for).returns(@list)
|
14
13
|
end
|
15
14
|
|
16
15
|
after { database_cleanup }
|
17
16
|
|
18
|
-
describe
|
17
|
+
describe '.initialize' do
|
19
18
|
subject { described_class.new(@board, list_name) }
|
20
19
|
|
21
|
-
it
|
22
|
-
subject.instance_variable_get(
|
20
|
+
it 'assigns the board to an instance variable' do
|
21
|
+
subject.instance_variable_get('@board').must_equal(@board)
|
23
22
|
end
|
24
23
|
|
25
|
-
it
|
26
|
-
subject.instance_variable_get(
|
24
|
+
it 'assigns the name to an instance variable' do
|
25
|
+
subject.instance_variable_get('@name').must_equal(list_name)
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
|
-
describe
|
31
|
-
before
|
29
|
+
describe '.for' do
|
30
|
+
before do
|
31
|
+
VCR.insert_cassette(:create_list,
|
32
|
+
decode_compressed_response: true)
|
33
|
+
end
|
34
|
+
|
32
35
|
after { VCR.eject_cassette }
|
33
36
|
|
34
37
|
subject { described_class.for(@board, list_name) }
|
35
38
|
|
36
|
-
context
|
37
|
-
it
|
39
|
+
context 'when the list was created' do
|
40
|
+
it 'returns the new list' do
|
38
41
|
subject.must_equal(@list)
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
42
|
-
context
|
45
|
+
context 'when the list was not created' do
|
43
46
|
before { Trello::List.stubs(:create).raises(Trello::Error) }
|
44
47
|
|
45
48
|
it { subject.must_equal false }
|
46
49
|
end
|
50
|
+
|
51
|
+
context 'when the access token is invalid' do
|
52
|
+
before do
|
53
|
+
Trello::List.stubs(:create)
|
54
|
+
.raises(Trello::InvalidAccessToken)
|
55
|
+
end
|
56
|
+
|
57
|
+
subject { described_class.for(@board, list_name) }
|
58
|
+
|
59
|
+
it 'catches the exception and re-raises' do
|
60
|
+
proc { subject }.must_raise(Troo::InvalidAccessToken)
|
61
|
+
end
|
62
|
+
end
|
47
63
|
end
|
48
64
|
end
|
49
65
|
end
|
@@ -1,43 +1,51 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative '../../../test_helper'
|
2
2
|
|
3
3
|
module Troo
|
4
4
|
describe MoveCard do
|
5
5
|
let(:described_class) { MoveCard }
|
6
|
+
let(:id) { '526d8e130a14a9d846001d98' }
|
6
7
|
|
7
8
|
before do
|
8
|
-
@list = Fabricate(:list, external_list_id:
|
9
|
+
@list = Fabricate(:list, external_list_id: id)
|
9
10
|
@card = Fabricate(:card)
|
10
11
|
Troo::External::Card.stubs(:fetch).returns(true)
|
11
|
-
|
12
|
+
end
|
12
13
|
|
13
14
|
after { database_cleanup }
|
14
15
|
|
15
|
-
describe
|
16
|
+
describe '.initialize' do
|
16
17
|
subject { described_class.new(@card, @list) }
|
17
18
|
|
18
|
-
it
|
19
|
-
subject.instance_variable_get(
|
19
|
+
it 'assigns the card to an instance variable' do
|
20
|
+
subject.instance_variable_get('@card').must_equal(@card)
|
20
21
|
end
|
21
22
|
|
22
|
-
it
|
23
|
-
subject.instance_variable_get(
|
23
|
+
it 'assigns the list to an instance variable' do
|
24
|
+
subject.instance_variable_get('@list').must_equal(@list)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
describe
|
28
|
-
before
|
29
|
-
|
28
|
+
describe '#perform' do
|
29
|
+
before do
|
30
|
+
VCR.insert_cassette(:move_card,
|
31
|
+
decode_compressed_response: true)
|
32
|
+
end
|
33
|
+
|
34
|
+
after { VCR.eject_cassette }
|
30
35
|
|
31
36
|
subject { described_class.with(@card, @list) }
|
32
37
|
|
33
|
-
context
|
34
|
-
it
|
38
|
+
context 'when the card was moved' do
|
39
|
+
it 'returns a refresh of all cards for the board' do
|
35
40
|
subject.wont_equal false
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
39
|
-
context
|
40
|
-
before
|
44
|
+
context 'when the card was not moved' do
|
45
|
+
before do
|
46
|
+
Trello::Card.any_instance.stubs(:move_to_list)
|
47
|
+
.raises(Trello::Error)
|
48
|
+
end
|
41
49
|
|
42
50
|
it { subject.must_equal false }
|
43
51
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Adaptors::Board do
|
5
|
+
let(:described_class) { Adaptors::Board }
|
6
|
+
let(:resource) do
|
7
|
+
OpenStruct.new(
|
8
|
+
id: '526d8e130a14a9d846001d96',
|
9
|
+
name: 'My Test Board',
|
10
|
+
description: 'A very brief description...',
|
11
|
+
closed: false)
|
12
|
+
end
|
13
|
+
|
14
|
+
after { database_cleanup }
|
15
|
+
|
16
|
+
describe '#initialize' do
|
17
|
+
subject { described_class.new(resource) }
|
18
|
+
|
19
|
+
it 'assigns the resource to an instance variable' do
|
20
|
+
subject.instance_variable_get('@resource')
|
21
|
+
.must_equal(resource)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#adapted' do
|
26
|
+
subject { described_class.adapt(resource) }
|
27
|
+
|
28
|
+
it 'returns an adapted resource for local persistence' do
|
29
|
+
subject.must_equal(
|
30
|
+
external_board_id: '526d8e130a14a9d846001d96',
|
31
|
+
name: 'My Test Board',
|
32
|
+
description: 'A very brief description...',
|
33
|
+
closed: 'false'
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Adaptors::Card do
|
5
|
+
let(:described_class) { Adaptors::Card }
|
6
|
+
let(:resource) do
|
7
|
+
OpenStruct.new(
|
8
|
+
board_id: '526d8e130a14a9d846001d96',
|
9
|
+
list_id: '526d8e130a14a9d846001d97',
|
10
|
+
id: '526d8f19ddb279532e005259',
|
11
|
+
member_ids: ['5195fdb5a8c01a2318004f5d'],
|
12
|
+
short_id: 67,
|
13
|
+
name: 'My Test Card',
|
14
|
+
desc: 'some description',
|
15
|
+
url: 'some trello url',
|
16
|
+
pos: 16,
|
17
|
+
last_activity_date: '2013-12-17 21:48:09 UTC',
|
18
|
+
closed: false)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#initialize' do
|
22
|
+
subject { described_class.new(resource) }
|
23
|
+
|
24
|
+
it 'assigns the resource to an instance variable' do
|
25
|
+
subject.instance_variable_get('@resource')
|
26
|
+
.must_equal(resource)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#adapted' do
|
31
|
+
subject { described_class.adapt(resource) }
|
32
|
+
|
33
|
+
it 'returns an adapted resource for local persistence' do
|
34
|
+
subject.must_equal(
|
35
|
+
external_board_id: '526d8e130a14a9d846001d96',
|
36
|
+
external_list_id: '526d8e130a14a9d846001d97',
|
37
|
+
external_card_id: '526d8f19ddb279532e005259',
|
38
|
+
external_member_ids: "[\"5195fdb5a8c01a2318004f5d\"]",
|
39
|
+
short_id: '67',
|
40
|
+
name: 'My Test Card',
|
41
|
+
desc: 'some description',
|
42
|
+
url: 'some trello url',
|
43
|
+
position: '16',
|
44
|
+
last_activity_date: '2013-12-17 21:48:09 UTC',
|
45
|
+
closed: 'false')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Adaptors::Comment do
|
5
|
+
let(:described_class) { Adaptors::Comment }
|
6
|
+
let(:resource) do
|
7
|
+
OpenStruct.new(
|
8
|
+
id: '51f9277b2822b8654f0023af',
|
9
|
+
member_creator_id: '5195fdb5a8c01a2318004f5d',
|
10
|
+
date: '2013-12-17 22:01:13 UTC',
|
11
|
+
data: {
|
12
|
+
'text' => 'My Test Comment',
|
13
|
+
'board' => { 'id' => '526d8e130a14a9d846001d96' },
|
14
|
+
'card' => { 'id' => '526d8f19ddb279532e005259' } })
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#initialize' do
|
18
|
+
subject { described_class.new(resource) }
|
19
|
+
|
20
|
+
it 'assigns the resource to an instance variable' do
|
21
|
+
subject.instance_variable_get('@resource')
|
22
|
+
.must_equal(resource)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#adapted' do
|
27
|
+
subject { described_class.adapt(resource) }
|
28
|
+
|
29
|
+
it 'returns an adapted resource for local persistence' do
|
30
|
+
subject.must_equal(
|
31
|
+
external_comment_id: '51f9277b2822b8654f0023af',
|
32
|
+
external_board_id: '526d8e130a14a9d846001d96',
|
33
|
+
external_card_id: '526d8f19ddb279532e005259',
|
34
|
+
external_member_id: '5195fdb5a8c01a2318004f5d',
|
35
|
+
date: '2013-12-17 22:01:13 UTC',
|
36
|
+
text: 'My Test Comment'
|
37
|
+
)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Adaptors::List do
|
5
|
+
let(:described_class) { Adaptors::List }
|
6
|
+
let(:resource) do
|
7
|
+
OpenStruct.new(
|
8
|
+
board_id: '526d8e130a14a9d846001d96',
|
9
|
+
id: '526d8e130a14a9d846001d97',
|
10
|
+
name: 'My Test List',
|
11
|
+
pos: 32_768,
|
12
|
+
closed: false)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#initialize' do
|
16
|
+
subject { described_class.new(resource) }
|
17
|
+
|
18
|
+
it 'assigns the resource to an instance variable' do
|
19
|
+
subject.instance_variable_get('@resource')
|
20
|
+
.must_equal(resource)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#adapted' do
|
25
|
+
subject { described_class.adapt(resource) }
|
26
|
+
|
27
|
+
it 'returns an adapted resource for local persistence' do
|
28
|
+
subject.must_equal(
|
29
|
+
external_board_id: '526d8e130a14a9d846001d96',
|
30
|
+
external_list_id: '526d8e130a14a9d846001d97',
|
31
|
+
name: 'My Test List',
|
32
|
+
position: '32768',
|
33
|
+
closed: 'false'
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Adaptors::Member do
|
5
|
+
let(:described_class) { Adaptors::Member }
|
6
|
+
let(:resource) do
|
7
|
+
OpenStruct.new(
|
8
|
+
id: '5195fdb5a8c01a2318004f5d',
|
9
|
+
username: 'gavinlaking1',
|
10
|
+
email: 'gavinlaking@gmail.com',
|
11
|
+
full_name: 'Gavin Laking',
|
12
|
+
initials: 'GL',
|
13
|
+
avatar_id: 'some_avatar_id',
|
14
|
+
bio: 'some bio',
|
15
|
+
url: 'http://www.gavinlaking.name/')
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#initialize' do
|
19
|
+
subject { described_class.new(resource) }
|
20
|
+
|
21
|
+
it 'assigns the resource to an instance variable' do
|
22
|
+
subject.instance_variable_get('@resource')
|
23
|
+
.must_equal(resource)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#adapted' do
|
28
|
+
subject { described_class.adapt(resource) }
|
29
|
+
|
30
|
+
it 'returns an adapted resource for local persistence' do
|
31
|
+
subject.must_equal(
|
32
|
+
external_member_id: '5195fdb5a8c01a2318004f5d',
|
33
|
+
username: 'gavinlaking1',
|
34
|
+
email: 'gavinlaking@gmail.com',
|
35
|
+
full_name: 'Gavin Laking',
|
36
|
+
initials: 'GL',
|
37
|
+
avatar_id: 'some_avatar_id',
|
38
|
+
bio: 'some bio',
|
39
|
+
url: 'http://www.gavinlaking.name/'
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative '../../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
module Commands
|
5
|
+
module Add
|
6
|
+
describe Board do
|
7
|
+
let(:described_class) { Board }
|
8
|
+
let(:value) { 'Add Board Test' }
|
9
|
+
let(:id) {}
|
10
|
+
|
11
|
+
before do
|
12
|
+
CreateBoard.stubs(:with).returns(false)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#add' do
|
16
|
+
subject { described_class.new(value, id).add }
|
17
|
+
|
18
|
+
context 'when the parent resource exists' do
|
19
|
+
context 'and the board was created' do
|
20
|
+
before { CreateBoard.stubs(:with).returns(true) }
|
21
|
+
|
22
|
+
it 'returns a polite message' do
|
23
|
+
subject.must_match(/\'Add Board Test\' created/)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'and the board was not created' do
|
28
|
+
it 'returns a polite message' do
|
29
|
+
subject.must_match(/could not/)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when the parent resource does not exist' do
|
35
|
+
it 'returns a polite message' do
|
36
|
+
subject.must_match(/could not/)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
module Commands
|
5
|
+
module Add
|
6
|
+
describe Card do
|
7
|
+
let(:described_class) { Card }
|
8
|
+
let(:value) { 'Add Card Test' }
|
9
|
+
let(:id) {}
|
10
|
+
|
11
|
+
before do
|
12
|
+
Retrieval::List.stubs(:retrieve)
|
13
|
+
CreateCard.stubs(:for).returns(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#add' do
|
17
|
+
subject { described_class.new(value, id).add }
|
18
|
+
|
19
|
+
context 'when the parent resource exists' do
|
20
|
+
context 'and the card was created' do
|
21
|
+
before { CreateCard.stubs(:for).returns(true) }
|
22
|
+
|
23
|
+
it 'returns a polite message' do
|
24
|
+
subject.must_match(/\'Add Card Test\' created/)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'and the card was not created' do
|
29
|
+
it 'returns a polite message' do
|
30
|
+
subject.must_match(/could not/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when the parent resource does not exist' do
|
36
|
+
it 'returns a polite message' do
|
37
|
+
subject.must_match(/could not/)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
module Commands
|
5
|
+
module Add
|
6
|
+
describe Comment do
|
7
|
+
let(:described_class) { Comment }
|
8
|
+
let(:value) { 'Add Comment Test' }
|
9
|
+
let(:id) {}
|
10
|
+
|
11
|
+
before do
|
12
|
+
Retrieval::Card.stubs(:retrieve)
|
13
|
+
CreateComment.stubs(:for).returns(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#add' do
|
17
|
+
subject { described_class.new(value, id).add }
|
18
|
+
|
19
|
+
context 'when the parent resource exists' do
|
20
|
+
context 'and the comment was created' do
|
21
|
+
before { CreateComment.stubs(:for).returns(true) }
|
22
|
+
|
23
|
+
it 'returns a polite message' do
|
24
|
+
subject.must_match(/New comment created/)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'and the comment was not created' do
|
29
|
+
it 'returns a polite message' do
|
30
|
+
subject.must_match(/could not/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when the parent resource does not exist' do
|
36
|
+
it 'returns a polite message' do
|
37
|
+
subject.must_match(/could not/)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|