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,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative '../../../test_helper'
|
2
2
|
|
3
3
|
module Troo
|
4
4
|
describe Refresh do
|
@@ -7,35 +7,36 @@ module Troo
|
|
7
7
|
|
8
8
|
subject { described_instance }
|
9
9
|
|
10
|
-
context
|
11
|
-
it
|
12
|
-
subject.last_performed_at
|
10
|
+
context 'attributes' do
|
11
|
+
it 'should have a last_performed_at attribute' do
|
12
|
+
subject.last_performed_at
|
13
|
+
.must_equal(Time.parse('2014-01-16 21:00:00 UTC'))
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
context
|
17
|
+
context 'actions' do
|
17
18
|
before { @refresh = Fabricate(:refresh) }
|
18
19
|
after { database_cleanup }
|
19
20
|
|
20
|
-
describe
|
21
|
+
describe '.completed!' do
|
21
22
|
subject { described_class.completed! }
|
22
23
|
|
23
|
-
it
|
24
|
+
it 'updates the last performed at timestamp' do
|
24
25
|
subject.wont_equal @refresh.last_performed_at
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
describe
|
29
|
+
describe '.last_performed_at?' do
|
29
30
|
subject { described_class.last_performed_at? }
|
30
31
|
|
31
|
-
context
|
32
|
+
context 'when one has not been performed' do
|
32
33
|
before { @refresh.delete }
|
33
34
|
|
34
35
|
it { subject.must_equal(nil) }
|
35
36
|
end
|
36
37
|
|
37
|
-
context
|
38
|
-
it
|
38
|
+
context 'when one has been performed' do
|
39
|
+
it 'returns the last performed timestamp' do
|
39
40
|
subject.must_equal @refresh.last_performed_at
|
40
41
|
end
|
41
42
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative '../../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
module Remote
|
5
|
+
describe Comment do
|
6
|
+
let(:described_class) { Comment }
|
7
|
+
let(:json) do
|
8
|
+
"{\"id\":\"52f51fb0b6e6b1fb2de2949e\"," \
|
9
|
+
"\"idMemberCreator\":\"5195fdb5a8c01a2318004f5d\"," \
|
10
|
+
"\"data\":{\"text\":\"This is a comment.\"," \
|
11
|
+
"\"card\":{\"id\":\"526d8f19ddb279532e005259\"}," \
|
12
|
+
"\"board\":{\"id\":\"526d8e130a14a9d846001d96\"}}," \
|
13
|
+
"\"date\":\"2014-02-07T18:02:24.297Z\"}"
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#id' do
|
17
|
+
subject { described_class.create(json).id }
|
18
|
+
|
19
|
+
it 'returns the comment ID' do
|
20
|
+
subject.must_equal('52f51fb0b6e6b1fb2de2949e')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#member_creator_id' do
|
25
|
+
subject { described_class.create(json).member_creator_id }
|
26
|
+
|
27
|
+
it 'returns the member creator ID' do
|
28
|
+
subject.must_equal('5195fdb5a8c01a2318004f5d')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#date' do
|
33
|
+
subject { described_class.create(json).date }
|
34
|
+
|
35
|
+
it 'returns the date the comment was created' do
|
36
|
+
subject.must_equal('2014-02-07T18:02:24.297Z')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#data' do
|
41
|
+
subject { described_class.create(json).data }
|
42
|
+
|
43
|
+
it 'returns a hash of useful data' do
|
44
|
+
subject.must_equal(
|
45
|
+
'text' => 'This is a comment.',
|
46
|
+
'card' => {
|
47
|
+
'id' => '526d8f19ddb279532e005259'
|
48
|
+
},
|
49
|
+
'board' => {
|
50
|
+
'id' => '526d8e130a14a9d846001d96'
|
51
|
+
})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
module Remote
|
5
|
+
describe Resource do
|
6
|
+
let(:described_class) { Resource }
|
7
|
+
let(:json) { "{\"some_key\":\"some_value\"}" }
|
8
|
+
|
9
|
+
describe '#initialize' do
|
10
|
+
subject { described_class.new(json) }
|
11
|
+
|
12
|
+
it 'assigns the JSON to an instance variable' do
|
13
|
+
subject.instance_variable_get('@json').must_equal(json)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.create' do
|
18
|
+
subject { described_class.create(json) }
|
19
|
+
|
20
|
+
it 'returns the resource' do
|
21
|
+
subject.must_be_instance_of described_class
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require_relative '../../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Retrieval::Board do
|
5
|
+
let(:described_class) { Retrieval::Board }
|
6
|
+
let(:default) { true }
|
7
|
+
let(:board_name) { 'My Test Board' }
|
8
|
+
|
9
|
+
before { @board = Fabricate(:board, default: default, name: board_name) }
|
10
|
+
after { database_cleanup }
|
11
|
+
|
12
|
+
describe '.all' do
|
13
|
+
subject { described_class.all }
|
14
|
+
|
15
|
+
it 'retrieves all locally stored lists' 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 @board
|
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 @board
|
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 database ID' do
|
57
|
+
let(:id) { @board.id }
|
58
|
+
|
59
|
+
it 'returns the correct board' do
|
60
|
+
subject.name.must_equal('My Test Board')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'local retrieval by external ID' do
|
65
|
+
let(:id) { '526d8e130a14a9d846001d96' }
|
66
|
+
|
67
|
+
it 'returns the correct board' do
|
68
|
+
subject.name.must_equal('My Test Board')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'remote retrieval by either ID' do
|
73
|
+
let(:id) { '526d_remote_board_005259' }
|
74
|
+
let(:board_name) { 'My Remote Test Board' }
|
75
|
+
|
76
|
+
before { External::Board.stubs(:fetch).returns([@board]) }
|
77
|
+
|
78
|
+
it 'returns the correct board' do
|
79
|
+
subject.name.must_equal('My Remote Test Board')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when the ID cannot be found' do
|
84
|
+
let(:id) { 'not_found_id' }
|
85
|
+
|
86
|
+
before { External::Board.stubs(:fetch).returns([]) }
|
87
|
+
|
88
|
+
it { subject.must_equal(nil) }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require_relative '../../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Retrieval::Card do
|
5
|
+
let(:described_class) { Retrieval::Card }
|
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,46 @@
|
|
1
|
+
require_relative '../../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Retrieval::Comment do
|
5
|
+
let(:described_class) { Retrieval::Comment }
|
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,93 @@
|
|
1
|
+
require_relative '../../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Retrieval::List do
|
5
|
+
let(:described_class) { Retrieval::List }
|
6
|
+
let(:default) { true }
|
7
|
+
let(:list_name) { 'My Test List' }
|
8
|
+
|
9
|
+
before { @list = Fabricate(:list, default: default, name: list_name) }
|
10
|
+
after { database_cleanup }
|
11
|
+
|
12
|
+
describe '.all' do
|
13
|
+
subject { described_class.all }
|
14
|
+
|
15
|
+
it 'retrieves all locally stored lists' 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 @list
|
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 @list
|
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 database ID' do
|
57
|
+
let(:id) { @list.id }
|
58
|
+
|
59
|
+
it 'returns the correct list' do
|
60
|
+
subject.name.must_equal('My Test List')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'local retrieval by external ID' do
|
65
|
+
let(:id) { '526d8e130a14a9d846001d97' }
|
66
|
+
|
67
|
+
it 'returns the correct list' do
|
68
|
+
subject.name.must_equal('My Test List')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'remote retrieval by either ID' do
|
73
|
+
let(:id) { '526d_remote_list_005259' }
|
74
|
+
let(:list_name) { 'My Remote Test List' }
|
75
|
+
|
76
|
+
before { External::List.stubs(:fetch).returns([@list]) }
|
77
|
+
|
78
|
+
it 'returns the correct list' do
|
79
|
+
subject.name.must_equal('My Remote Test List')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when the ID cannot be found' do
|
84
|
+
let(:id) { 'not_found_id' }
|
85
|
+
|
86
|
+
before { External::List.stubs(:fetch).returns([]) }
|
87
|
+
|
88
|
+
it { subject.must_equal(nil) }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative '../../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Retrieval::Member do
|
5
|
+
let(:described_class) { Retrieval::Member }
|
6
|
+
let(:full_name) { 'My Test Member' }
|
7
|
+
|
8
|
+
before { @member = Fabricate(:member, full_name: full_name) }
|
9
|
+
after { database_cleanup }
|
10
|
+
|
11
|
+
describe '.all' do
|
12
|
+
subject { described_class.all }
|
13
|
+
|
14
|
+
it 'retrieves all locally stored members' do
|
15
|
+
subject.size.must_equal 1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.retrieve' do
|
20
|
+
subject { described_class.retrieve(id) }
|
21
|
+
|
22
|
+
context 'local retrieval by database ID' do
|
23
|
+
let(:id) { @member.id }
|
24
|
+
|
25
|
+
it 'returns the correct member' do
|
26
|
+
subject.full_name.must_equal('My Test Member')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'local retrieval by external ID' do
|
31
|
+
let(:id) { '5195fdb5a8c01a2318004f5d' }
|
32
|
+
|
33
|
+
it 'returns the correct member' do
|
34
|
+
subject.full_name.must_equal('My Test Member')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'remote retrieval by either ID' do
|
39
|
+
let(:id) { '526d_remote_member_005259' }
|
40
|
+
let(:full_name) { 'My Remote Test Member' }
|
41
|
+
|
42
|
+
before { External::Member.stubs(:fetch).returns([@member]) }
|
43
|
+
|
44
|
+
it 'returns the correct member' do
|
45
|
+
subject.full_name.must_equal('My Remote Test Member')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when the ID cannot be found' do
|
50
|
+
let(:id) { 'not_found_id' }
|
51
|
+
|
52
|
+
before { External::Member.stubs(:fetch).returns([]) }
|
53
|
+
|
54
|
+
it { subject.must_equal(nil) }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Sentence do
|
5
|
+
let(:described_class) { Sentence }
|
6
|
+
let(:elements) { ['Hydrogen'] }
|
7
|
+
let(:label) { 'elements' }
|
8
|
+
|
9
|
+
describe '#initialize' do
|
10
|
+
subject { described_class.new(elements, label) }
|
11
|
+
|
12
|
+
it 'assigns the elements to an instance variable' do
|
13
|
+
subject.instance_variable_get('@elements').must_equal(elements)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'assigns the label to an instance variable' do
|
17
|
+
subject.instance_variable_get('@label').must_equal(label)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.construct' do
|
22
|
+
subject { described_class.construct(elements, label) }
|
23
|
+
|
24
|
+
context 'when there is one element' do
|
25
|
+
let(:elements) { ['Hydrogen'] }
|
26
|
+
|
27
|
+
it 'returns the element as a string' do
|
28
|
+
subject.must_equal('Hydrogen')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when there are two elements' do
|
33
|
+
let(:elements) { %w(Hydrogen Helium) }
|
34
|
+
|
35
|
+
it "returns the elements joined with 'and'" do
|
36
|
+
subject.must_equal('Hydrogen and Helium')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when there are more than two elements' do
|
41
|
+
let(:elements) { %w(Hydrogen Helium Lithium) }
|
42
|
+
|
43
|
+
it 'returns the elements as a sentence list' do
|
44
|
+
subject.must_equal('Hydrogen, Helium and Lithium')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when there are no elements' do
|
49
|
+
let(:elements) { [] }
|
50
|
+
|
51
|
+
it 'returns a polite message' do
|
52
|
+
subject.must_equal('No elements have been assigned.')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,37 +1,38 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative '../../../test_helper'
|
2
2
|
|
3
3
|
module Troo
|
4
4
|
describe Template do
|
5
5
|
let(:described_class) { Template }
|
6
|
-
let(:object) { OpenStruct.new(value:
|
7
|
-
let(:template_path) {
|
6
|
+
let(:object) { OpenStruct.new(value: 'Hello from variable!') }
|
7
|
+
let(:template_path) { '/../../../test/support/template.erb' }
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe '#initialize' do
|
10
10
|
subject { described_class.new(object, template_path) }
|
11
11
|
|
12
|
-
it
|
13
|
-
subject.instance_variable_get(
|
12
|
+
it 'assigns the object to an instance variable' do
|
13
|
+
subject.instance_variable_get('@object').must_equal(object)
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
subject.instance_variable_get(
|
16
|
+
it 'assigns the template_path to an instance variable' do
|
17
|
+
subject.instance_variable_get('@template_path')
|
18
|
+
.must_equal(template_path)
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
describe
|
22
|
+
describe '#parse' do
|
22
23
|
subject { described_class.new(object, template_path).parse }
|
23
24
|
|
24
|
-
context
|
25
|
-
it
|
26
|
-
subject.must_match
|
27
|
-
subject.must_match
|
25
|
+
context 'when the template file can be found' do
|
26
|
+
it 'parses the template' do
|
27
|
+
subject.must_match(/This is the test template/)
|
28
|
+
subject.must_match(/Hello from variable!/)
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
context
|
32
|
-
let(:template_path) {
|
32
|
+
context 'when the template file cannot be found' do
|
33
|
+
let(:template_path) { '/some/wrong/path/template.erb' }
|
33
34
|
|
34
|
-
it
|
35
|
+
it 'raises an exception' do
|
35
36
|
proc { subject }.must_raise(Errno::ENOENT)
|
36
37
|
end
|
37
38
|
end
|