tacokit 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +86 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +16 -25
  5. data/Guardfile +1 -1
  6. data/README.md +61 -17
  7. data/Rakefile +10 -5
  8. data/lib/tacokit/authorization.rb +14 -13
  9. data/lib/tacokit/client/actions.rb +68 -28
  10. data/lib/tacokit/client/boards.rb +92 -85
  11. data/lib/tacokit/client/cards.rb +285 -92
  12. data/lib/tacokit/client/checklists.rb +48 -28
  13. data/lib/tacokit/client/labels.rb +14 -16
  14. data/lib/tacokit/client/lists.rb +52 -28
  15. data/lib/tacokit/client/members.rb +56 -46
  16. data/lib/tacokit/client/notifications.rb +13 -27
  17. data/lib/tacokit/client/organizations.rb +0 -6
  18. data/lib/tacokit/client/searches.rb +0 -1
  19. data/lib/tacokit/client/tokens.rb +0 -6
  20. data/lib/tacokit/client/types.rb +0 -1
  21. data/lib/tacokit/client/webhooks.rb +3 -8
  22. data/lib/tacokit/client.rb +48 -75
  23. data/lib/tacokit/collection.rb +49 -0
  24. data/lib/tacokit/configuration.rb +4 -6
  25. data/lib/tacokit/error.rb +0 -2
  26. data/lib/tacokit/middleware/boom.rb +6 -7
  27. data/lib/tacokit/middleware.rb +2 -10
  28. data/lib/tacokit/resource.rb +84 -57
  29. data/lib/tacokit/response.rb +3 -3
  30. data/lib/tacokit/transform.rb +35 -13
  31. data/lib/tacokit/utils.rb +40 -8
  32. data/lib/tacokit/version.rb +1 -1
  33. data/lib/tacokit.rb +0 -2
  34. data/spec/cassettes/Tacokit_Client_Actions/_action_board/returns_action_board.json +1 -0
  35. data/spec/cassettes/Tacokit_Client_Actions/_action_card/returns_action_card.json +1 -0
  36. data/spec/cassettes/Tacokit_Client_Actions/_action_entities/returns_action_entities.json +1 -0
  37. data/spec/cassettes/Tacokit_Client_Actions/_action_list/returns_action_list.json +1 -0
  38. data/spec/cassettes/Tacokit_Client_Boards/_add_board_member/adds_invites_member_to_board.json +1 -1
  39. data/spec/cassettes/Tacokit_Client_Boards/_board_actions/returns_board_actions.json +1 -0
  40. data/spec/cassettes/Tacokit_Client_Boards/_board_cards/returns_board_cards.json +1 -0
  41. data/spec/cassettes/Tacokit_Client_Boards/_board_checklists/returns_board_checklists.json +1 -0
  42. data/spec/cassettes/Tacokit_Client_Boards/_board_labels/returns_board_labels.json +1 -0
  43. data/spec/cassettes/Tacokit_Client_Boards/_board_lists/returns_board_lists.json +1 -0
  44. data/spec/cassettes/Tacokit_Client_Boards/_board_members/returns_board_members.json +1 -0
  45. data/spec/cassettes/Tacokit_Client_Boards/_board_organization/returns_board_organization.json +1 -0
  46. data/spec/cassettes/Tacokit_Client_Boards/_board_preferences/returns_preferences_for_a_board.json +1 -0
  47. data/spec/cassettes/Tacokit_Client_Boards/_board_stars/returns_board_stars.json +1 -0
  48. data/spec/cassettes/Tacokit_Client_Boards/_member_board_stars/returns_board_stars.json +1 -0
  49. data/spec/cassettes/Tacokit_Client_Boards/_update_board_member/updates_member.json +1 -0
  50. data/spec/cassettes/Tacokit_Client_Cards/_add_comment/creates_a_comment.json +1 -0
  51. data/spec/cassettes/Tacokit_Client_Cards/_add_label/adds_label_to_card.json +1 -0
  52. data/spec/cassettes/Tacokit_Client_Cards/_add_member_to_card/adds_member_to_card.json +1 -0
  53. data/spec/cassettes/Tacokit_Client_Cards/_archive_card/archives_card.json +1 -0
  54. data/spec/cassettes/Tacokit_Client_Cards/_archive_card/restore_card.json +1 -0
  55. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_an_attachment.json +1 -0
  56. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_attachment.json +1 -0
  57. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_attachments.json +1 -0
  58. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_card_resource.json +1 -0
  59. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_id.json +1 -1
  60. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_short_link.json +1 -1
  61. data/spec/cassettes/Tacokit_Client_Cards/_card_actions/returns_card_actions.json +1 -0
  62. data/spec/cassettes/Tacokit_Client_Cards/_card_board/returns_card_board.json +1 -0
  63. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_hash.json +1 -1
  64. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_value.json +1 -1
  65. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_an_array.json +1 -1
  66. data/spec/cassettes/Tacokit_Client_Cards/_card_list/returns_a_list.json +1 -0
  67. data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members.json +1 -0
  68. data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members_voted.json +1 -0
  69. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_actions.json +1 -1
  70. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_board.json +1 -1
  71. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_check_item_states.json +1 -1
  72. data/spec/cassettes/Tacokit_Client_Cards/_card_stickers/returns_.json +1 -0
  73. data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_check_item_states.json +1 -0
  74. data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_checklists.json +1 -0
  75. data/spec/cassettes/Tacokit_Client_Cards/_create_card/creates_a_card.json +1 -1
  76. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/attaches_external_url.json +1 -1
  77. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/uploads_local_file.json +1 -1
  78. data/spec/cassettes/Tacokit_Client_Cards/_delete_card/deletes_a_card.json +1 -1
  79. data/spec/cassettes/Tacokit_Client_Cards/_delete_card_resource/deletes_resource.json +1 -1
  80. data/spec/cassettes/Tacokit_Client_Cards/_delete_comment/deletes_comment.json +1 -0
  81. data/spec/cassettes/Tacokit_Client_Cards/_list/returns_list.json +1 -0
  82. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_a_new_position.json +1 -0
  83. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_another_board_list.json +1 -0
  84. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_board.json +1 -0
  85. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_list.json +1 -0
  86. data/spec/cassettes/Tacokit_Client_Cards/_move_card/raises_error_if_missing_options.json +1 -0
  87. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/adds_a_checklist_item.json +1 -0
  88. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/adds_new_checklist_by_name.json +1 -0
  89. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/copies_a_checklist_by_id.json +1 -0
  90. data/spec/cassettes/Tacokit_Client_Cards/_stickers/returns_stickers.json +1 -0
  91. data/spec/cassettes/Tacokit_Client_Cards/_update_card/updates_a_card.json +1 -1
  92. data/spec/cassettes/Tacokit_Client_Cards/_update_checklist_item/updates_checklist_item.json +1 -0
  93. data/spec/cassettes/Tacokit_Client_Cards/_update_comment/updates_a_comment.json +1 -0
  94. data/spec/cassettes/Tacokit_Client_Cards/_vote/adds_a_member_s_vote_to_card.json +1 -0
  95. data/spec/cassettes/Tacokit_Client_Checklists/_check_items/adds_a_checklist_check_item.json +1 -0
  96. data/spec/cassettes/Tacokit_Client_Checklists/_check_items/retrieves_checklist_check_items.json +1 -0
  97. data/spec/cassettes/Tacokit_Client_Lists/_archive_list_cards/should_archive_cards_in_list.json +1 -0
  98. data/spec/cassettes/Tacokit_Client_Lists/_list_actions/returns_list_actions.json +1 -0
  99. data/spec/cassettes/Tacokit_Client_Lists/_list_board/returns_list_board.json +1 -0
  100. data/spec/cassettes/Tacokit_Client_Lists/_list_cards/returns_list_cards.json +1 -0
  101. data/spec/cassettes/Tacokit_Client_Lists/_move_list_cards/should_move_cards_in_list.json +1 -0
  102. data/spec/cassettes/Tacokit_Client_Members/_actions/returns_member_actions.json +1 -0
  103. data/spec/cassettes/Tacokit_Client_Members/_board_stars/returns_member_board_stars.json +1 -0
  104. data/spec/cassettes/Tacokit_Client_Members/_boards/returns_member_boards.json +1 -0
  105. data/spec/cassettes/Tacokit_Client_Members/_cards/returns_member_cards.json +1 -0
  106. data/spec/cassettes/Tacokit_Client_Members/_notifications/returns_member_notifications.json +1 -0
  107. data/spec/cassettes/Tacokit_Client_Members/_organizations/returns_member_organizations.json +1 -0
  108. data/spec/cassettes/Tacokit_Client_Members/_tokens/returns_member_organizations.json +1 -0
  109. data/spec/cassettes/Tacokit_Client_Members/_tokens/returns_member_tokens.json +1 -0
  110. data/spec/spec_helper.rb +39 -29
  111. data/spec/tacokit/authorization_spec.rb +11 -11
  112. data/spec/tacokit/client/actions_spec.rb +56 -19
  113. data/spec/tacokit/client/boards_spec.rb +81 -78
  114. data/spec/tacokit/client/cards_spec.rb +322 -68
  115. data/spec/tacokit/client/checklists_spec.rb +29 -27
  116. data/spec/tacokit/client/labels_spec.rb +8 -16
  117. data/spec/tacokit/client/lists_spec.rb +74 -27
  118. data/spec/tacokit/client/members_spec.rb +55 -41
  119. data/spec/tacokit/client/notifications_spec.rb +3 -31
  120. data/spec/tacokit/client/organizations_spec.rb +6 -27
  121. data/spec/tacokit/client/searches_spec.rb +1 -3
  122. data/spec/tacokit/client/tokens_spec.rb +2 -18
  123. data/spec/tacokit/client/types_spec.rb +2 -3
  124. data/spec/tacokit/client/webhooks_spec.rb +6 -14
  125. data/spec/tacokit/client_spec.rb +3 -3
  126. data/spec/tacokit/configuration_spec.rb +30 -31
  127. data/spec/tacokit/middleware/boom_spec.rb +6 -7
  128. data/spec/tacokit/resource_spec.rb +142 -17
  129. data/spec/tacokit/transform_spec.rb +37 -35
  130. data/spec/tacokit_spec.rb +3 -5
  131. data/tacokit.gemspec +6 -6
  132. metadata +132 -15
  133. data/config.ru +0 -7
  134. data/lib/tacokit/middleware/debug.rb +0 -22
  135. data/spec/cassettes/Tacokit_Client_Boards/_update_board_resource/updates_member.json +0 -1
  136. data/spec/cassettes/Tacokit_Client_Members/_member/raises_error_for_missing_token.json +0 -1
@@ -1,45 +1,41 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Tacokit::Client::Lists do
4
4
  def test_list_id
5
- '548dd948ffd374221926b4c8'
5
+ "548dd948ffd374221926b4c8"
6
6
  end
7
7
 
8
8
  def test_board_id
9
- '548a675581d1d669c9e8184e'
9
+ "548a675581d1d669c9e8184e"
10
10
  end
11
11
 
12
- describe "#list", :vcr do
13
- it "returns a list by id" do
14
- list = app_client.list(test_list_id)
12
+ def test_alternate_list_id
13
+ "54f3724e8a0bbe01a80f8712"
14
+ end
15
15
 
16
- expect(list.name).to eq 'List 1'
17
- end
16
+ def test_alternate_board_id
17
+ "54f371b4086781e1a71b6111"
18
18
  end
19
19
 
20
- describe "#list_field", :vcr do
21
- it "returns a value" do
22
- field = app_client.list_field(test_list_id, :pos)
20
+ describe "#list", :vcr do
21
+ it "returns a list by id" do
22
+ list = app_client.list(test_list_id)
23
23
 
24
- expect(field['_value']).to be_present
24
+ expect(list.name).to eq "List 1"
25
25
  end
26
26
  end
27
27
 
28
- describe "#list_resource", :vcr do
28
+ describe "#list_actions", :vcr do
29
29
  it "returns list actions" do
30
- actions = app_client.list_resource(test_list_id, :actions)
30
+ actions = app_client.list_actions(test_list_id)
31
31
 
32
32
  expect(actions).to be_any
33
33
  end
34
+ end
34
35
 
35
- it "returns list board" do
36
- board = app_client.list_resource(test_list_id, :board)
37
-
38
- expect(board.name).to be_present
39
- end
40
-
36
+ describe "#list_cards", :vcr do
41
37
  it "returns list cards" do
42
- cards = app_client.list_resource(test_list_id, :cards)
38
+ cards = app_client.list_cards(test_list_id)
43
39
 
44
40
  expect(cards).to be_any
45
41
 
@@ -48,19 +44,27 @@ describe Tacokit::Client::Lists do
48
44
  end
49
45
  end
50
46
 
47
+ describe "#list_board", :vcr do
48
+ it "returns list board" do
49
+ board = app_client.list_board(test_list_id)
50
+
51
+ expect(board.name).to be_present
52
+ end
53
+ end
54
+
51
55
  describe "#update_list", :vcr do
52
56
  it "updates a list" do
53
57
  list = app_client.update_list test_list_id,
54
- name: 'Test List 1'
58
+ name: "Test List 1"
55
59
 
56
- expect(list.name).to eq 'Test List 1'
60
+ expect(list.name).to eq "Test List 1"
57
61
  assert_requested :put, trello_url_template("lists/#{test_list_id}{?key,token}")
58
62
  end
59
63
  end
60
64
 
61
65
  describe "#create_list", :vcr do
62
66
  before do
63
- @list = app_client.create_list test_board_id, "Autolist", pos: 'bottom'
67
+ @list = app_client.create_list test_board_id, "Autolist", pos: "bottom"
64
68
  end
65
69
 
66
70
  it "creates a list" do
@@ -68,9 +72,9 @@ describe Tacokit::Client::Lists do
68
72
  expect(@list.pos).to be >= 1
69
73
  assert_requested :post, trello_url_template("lists{?key,token}"),
70
74
  body: {
71
- 'name' => 'Autolist',
72
- 'pos' => 'bottom',
73
- 'idBoard' => test_board_id
75
+ "name" => "Autolist",
76
+ "pos" => "bottom",
77
+ "idBoard" => test_board_id
74
78
  }
75
79
  end
76
80
 
@@ -78,4 +82,47 @@ describe Tacokit::Client::Lists do
78
82
  app_client.update_list @list.id, closed: true
79
83
  end
80
84
  end
85
+
86
+ describe "#archive_list_cards", :vcr do
87
+ before do
88
+ @list = app_client.create_list test_board_id, "Autolist", pos: "bottom"
89
+ @card = app_client.create_card @list.id, "Test card"
90
+ end
91
+
92
+ it "should archive cards in list" do
93
+ app_client.archive_list_cards(@list.id)
94
+
95
+ card = app_client.card(@card.id)
96
+ expect(card.closed?).to be_truthy
97
+ end
98
+
99
+ after do
100
+ app_client.update_list @list.id, closed: true
101
+ end
102
+ end
103
+
104
+ describe "#move_list_cards", :vcr do
105
+ before do
106
+ @list = app_client.create_list test_board_id, "Autolist", pos: "bottom"
107
+ @card = app_client.create_card @list.id, "Test card"
108
+ end
109
+
110
+ it "should move cards in list" do
111
+ app_client.move_list_cards @list.id, test_alternate_list_id, test_alternate_board_id
112
+
113
+ source = app_client.list_cards(@list.id)
114
+ expect(source).to be_empty
115
+
116
+ destination = app_client.list_cards(test_alternate_list_id)
117
+ expect(destination.size).to eq(1)
118
+
119
+ card = destination.first
120
+ expect(card.list_id).to eq test_alternate_list_id
121
+ end
122
+
123
+ after do
124
+ app_client.delete_card @card.id
125
+ app_client.update_list @list.id, closed: true
126
+ end
127
+ end
81
128
  end
@@ -1,7 +1,6 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Tacokit::Client::Members do
4
-
5
4
  describe "#member", :vcr do
6
5
  it "returns a member" do
7
6
  member = app_client.member("rossta")
@@ -16,17 +15,11 @@ describe Tacokit::Client::Members do
16
15
  expect(member.full_name).to eq("Taco Kit")
17
16
  end
18
17
 
19
- it "raises error for missing token" do
20
- app_client.configuration.app_token = nil
21
-
22
- expect { app_client.member }.to raise_error
23
- end
24
-
25
18
  it "supports query fields as string or array" do
26
19
  member = app_client.member "tacokit",
27
- boards: 'all',
28
- board_fields: 'name,short_url',
29
- fields: ['username', 'full_name']
20
+ boards: "all",
21
+ board_fields: "name,short_url",
22
+ fields: %w[ username full_name ]
30
23
 
31
24
  expect(member.username).to eq("tacokit")
32
25
  expect(member.full_name).to eq("Taco Kit")
@@ -45,68 +38,89 @@ describe Tacokit::Client::Members do
45
38
  assert_requested :get, trello_url("members/me")
46
39
  end
47
40
  end
48
-
49
41
  end
50
42
 
51
- describe "#member_field", :vcr do
52
- it "returns a value" do
53
- field = app_client.member_field('tacokit', 'full_name')
43
+ describe "#actions", :vcr do
44
+ it "returns member actions" do
45
+ actions = app_client.actions("tacokit")
46
+
47
+ expect(actions).not_to be_empty
54
48
 
55
- expect(field['_value']).to eq('Taco Kit')
49
+ action = actions.first
50
+ expect(action.member_creator.full_name).to be_present
51
+
52
+ assert_requested :get, trello_url_template("members/tacokit/actions{?key,token,page}")
56
53
  end
54
+ end
55
+
56
+ describe "#boards", :vcr do
57
+ it "returns member boards" do
58
+ boards = app_client.boards("tacokit")
59
+
60
+ expect(boards).not_to be_empty
57
61
 
58
- it "returns an array" do
59
- field = app_client.member_field('tacokit', :id_organizations)
62
+ board = boards.first
63
+ expect(board).to be_a(Tacokit::Resource)
64
+ expect(board.name).to be_present
60
65
 
61
- expect(field).to include(test_org_id)
66
+ assert_requested :get, trello_url_template("members/tacokit/boards{?key,token}")
62
67
  end
68
+ end
63
69
 
64
- it "returns a resource" do
65
- field = app_client.member_field('tacokit', :prefs)
70
+ describe "#cards", :vcr do
71
+ it "returns member cards" do
72
+ cards = app_client.cards("tacokit")
66
73
 
67
- expect(field.to_attrs).to include(color_blind: true)
74
+ expect(cards).to be_empty
75
+
76
+ assert_requested :get, trello_url_template("members/tacokit/cards{?key,token}")
68
77
  end
69
78
  end
70
79
 
71
- describe "#member_resource", :vcr do
72
- it "returns member actions" do
73
- actions = app_client.member_resource('tacokit', :actions)
80
+ describe "#notifications", :vcr do
81
+ it "returns member notifications" do
82
+ notifications = app_client.notifications("tacokit")
74
83
 
75
- expect(actions).not_to be_empty
84
+ expect(notifications).to be_empty
76
85
 
77
- action = actions.first
78
- expect(action.member_creator.full_name).to be_present
86
+ assert_requested :get, trello_url_template("members/tacokit/notifications{?key,token,page}")
79
87
  end
88
+ end
80
89
 
81
- it "returns member boards" do
82
- boards = app_client.member_resource('tacokit', :boards)
90
+ describe "#organizations", :vcr do
91
+ it "returns member organizations" do
92
+ organizations = app_client.organizations("tacokit")
83
93
 
84
- expect(boards).not_to be_empty
94
+ expect(organizations).not_to be_empty
95
+ org = organizations.first
96
+ expect(org.name).to eq "teamtacokit"
85
97
 
86
- board = boards.first
87
- expect(board.name).to be_present
98
+ assert_requested :get, trello_url_template("members/tacokit/organizations{?key,token}")
88
99
  end
100
+ end
89
101
 
90
- it "returns member board stars" do
91
- stars = app_client.member_resource('tacokit', :board_stars)
102
+ describe "#tokens", :vcr do
103
+ it "returns member tokens" do
104
+ tokens = app_client.tokens("tacokit")
92
105
 
93
- expect(stars).not_to be_empty
106
+ expect(tokens).not_to be_empty
107
+ token = tokens.first
108
+ expect(token.identifier).to be_present
94
109
 
95
- star = stars.first
96
- expect(star.pos).to be_present
110
+ assert_requested :get, trello_url_template("members/tacokit/tokens{?key,token}")
97
111
  end
98
112
  end
99
113
 
100
114
  describe "#update_member", :vcr do
101
115
  it "updates a member" do
102
- member = oauth_client.update_member('tacokit', bio: 'Tacokit puts the Trello API on Ruby')
116
+ member = oauth_client.update_member("tacokit", bio: "Tacokit puts the Trello API on Ruby")
103
117
 
104
- expect(member.bio).to eq 'Tacokit puts the Trello API on Ruby'
118
+ expect(member.bio).to eq "Tacokit puts the Trello API on Ruby"
105
119
  assert_requested :put, trello_url_template("members/tacokit{?key,token}")
106
120
  end
107
121
 
108
122
  it "updates nested resource" do
109
- member = oauth_client.update_member('tacokit', prefs: { color_blind: true })
123
+ member = oauth_client.update_member("tacokit", prefs: { color_blind: true })
110
124
 
111
125
  expect(member.prefs.color_blind).to eq true
112
126
  end
@@ -1,43 +1,15 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Tacokit::Client::Notifications do
4
4
  def test_notification_id
5
- '549102431b607566bafc93ab'
5
+ "549102431b607566bafc93ab"
6
6
  end
7
7
 
8
8
  describe "#notification", :vcr do
9
9
  it "returns a notification by id" do
10
10
  notification = app_client.notification(test_notification_id)
11
11
 
12
- expect(notification.data).to include("text")
13
- end
14
- end
15
-
16
- describe "#notification_field", :vcr do
17
- it "returns a value" do
18
- field = app_client.notification_field(test_notification_id, :type)
19
-
20
- expect(field['_value']).to be_present
21
- end
22
-
23
- it "returns a resource" do
24
- field = app_client.notification_field(test_notification_id, :data)
25
-
26
- expect(field).to be_a(Tacokit::Resource)
27
- end
28
- end
29
-
30
- describe "#notification_resource", :vcr do
31
- it "returns action entities" do
32
- entities = app_client.notification_resource(test_notification_id, :entities)
33
-
34
- expect(entities).to be_any
35
- end
36
-
37
- it "returns notification board" do
38
- board = app_client.notification_resource(test_notification_id, :board)
39
-
40
- expect(board.name).to be_present
12
+ expect(notification.data).to include(:text)
41
13
  end
42
14
  end
43
15
 
@@ -1,32 +1,11 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Tacokit::Client::Organizations do
4
-
5
4
  describe "#organization", :vcr do
6
5
  it "returns an organization by id" do
7
6
  org = app_client.organization(test_org_name)
8
7
 
9
- expect(org.name).to eq 'teamtacokit'
10
- end
11
- end
12
-
13
- describe "#organization_field", :vcr do
14
- it "returns a value" do
15
- field = app_client.organization_field(test_org_name, :desc)
16
-
17
- expect(field['_value']).to eq('Tacokit the organization')
18
- end
19
-
20
- it "returns an array" do
21
- field = app_client.organization_field(test_org_name, :premium_features)
22
-
23
- expect(field).to be_empty
24
- end
25
-
26
- it "returns a resource" do
27
- field = app_client.organization_field(test_org_name, :prefs)
28
-
29
- expect(field.to_attrs).to include(permission_level: "public")
8
+ expect(org.name).to eq "teamtacokit"
30
9
  end
31
10
  end
32
11
 
@@ -58,9 +37,9 @@ describe Tacokit::Client::Organizations do
58
37
 
59
38
  describe "#update_organization", :vcr do
60
39
  it "updates a organization" do
61
- organization = oauth_client.update_organization(test_org_name, desc: 'This organization is for Tacokit collaboration')
40
+ organization = oauth_client.update_organization(test_org_name, desc: "This organization is for Tacokit collaboration")
62
41
 
63
- expect(organization.desc).to eq 'This organization is for Tacokit collaboration'
42
+ expect(organization.desc).to eq "This organization is for Tacokit collaboration"
64
43
  assert_requested :put, trello_url_template("organizations/#{test_org_name}")
65
44
  end
66
45
  end
@@ -75,8 +54,8 @@ describe Tacokit::Client::Organizations do
75
54
  expect(@organization.desc).to eq "This is an autogenerated organization"
76
55
  assert_requested :post, trello_url_template("organizations{?key,token}"),
77
56
  body: {
78
- 'displayName' => 'Autoorganization',
79
- 'desc' => 'This is an autogenerated organization'
57
+ "displayName" => "Autoorganization",
58
+ "desc" => "This is an autogenerated organization"
80
59
  }
81
60
  end
82
61
 
@@ -1,13 +1,11 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Tacokit::Client::Searches do
4
-
5
4
  describe "#search", :vcr do
6
5
  it "returns search result" do
7
6
  search = app_client.search("taco")
8
7
 
9
8
  expect(search.members).to_not be_empty
10
9
  end
11
-
12
10
  end
13
11
  end
@@ -1,7 +1,6 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Tacokit::Client::Tokens do
4
-
5
4
  describe "#token", :vcr do
6
5
  it "returns a token for token string" do
7
6
  token = app_client.token(test_trello_app_token)
@@ -10,21 +9,6 @@ describe Tacokit::Client::Tokens do
10
9
  end
11
10
  end
12
11
 
13
- describe "#token_field", :vcr do
14
- it "returns a value" do
15
- field = app_client.token_field(test_trello_app_token, :date_created)
16
-
17
- expect(field['_value']).to be_present
18
- end
19
-
20
- it "returns an array" do
21
- field = app_client.token_field(test_trello_app_token, :permissions)
22
-
23
- expect(field).to be_any
24
- expect(field.first.read).to be_present
25
- end
26
- end
27
-
28
12
  describe "#token_resource", :vcr do
29
13
  it "returns token member" do
30
14
  member = app_client.token_resource(test_trello_app_token, :member)
@@ -41,7 +25,7 @@ describe Tacokit::Client::Tokens do
41
25
 
42
26
  describe "#delete_token", :vcr do
43
27
  it "deletes a token" do
44
- expect { app_client.delete_token('faketokenid') }.to raise_error(Tacokit::Error) # 400, invalid token
28
+ expect { app_client.delete_token("faketokenid") }.to raise_error(Tacokit::Error) # 400, invalid token
45
29
 
46
30
  assert_requested :delete, trello_url_template("tokens/faketokenid{?key,token}")
47
31
  end
@@ -1,12 +1,11 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Tacokit::Client::Types do
4
-
5
4
  describe "#type", :vcr do
6
5
  it "returns a type by id" do
7
6
  type = app_client.type(test_org_name)
8
7
 
9
- expect(type.type).to eq 'organization'
8
+ expect(type.type).to eq "organization"
10
9
  end
11
10
  end
12
11
  end
@@ -1,8 +1,8 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Tacokit::Client::Webhooks do
4
4
  def test_webhook_id
5
- '5491ff14d60e03635c260393'
5
+ "5491ff14d60e03635c260393"
6
6
  end
7
7
 
8
8
  describe "#webhook", :vcr do
@@ -13,19 +13,11 @@ describe Tacokit::Client::Webhooks do
13
13
  end
14
14
  end
15
15
 
16
- describe "#webhook_field", :vcr do
17
- it "returns a value" do
18
- field = app_client.webhook_field(test_webhook_id, :callback_url)
19
-
20
- expect(field['_value']).to be_present
21
- end
22
- end
23
-
24
16
  describe "#update_webhook", :vcr do
25
17
  it "updates a webhook" do
26
- webhook = app_client.update_webhook(test_webhook_id, description: 'This webhook is for Tacokit testing')
18
+ webhook = app_client.update_webhook(test_webhook_id, description: "This webhook is for Tacokit testing")
27
19
 
28
- expect(webhook.description).to eq 'This webhook is for Tacokit testing'
20
+ expect(webhook.description).to eq "This webhook is for Tacokit testing"
29
21
  assert_requested :put, trello_url_template("webhooks/#{test_webhook_id}{?key,token}")
30
22
  end
31
23
  end
@@ -42,8 +34,8 @@ describe Tacokit::Client::Webhooks do
42
34
  expect(@webhook.callback_url).to match(%r{https://[^/]*/webhook})
43
35
  assert_requested :post, trello_url_template("webhooks{?key,token}"),
44
36
  body: {
45
- 'callbackURL' => tacokit_web_endpoint("webhook?create_webhook"),
46
- 'idModel' => test_org_id
37
+ "callbackURL" => tacokit_web_endpoint("webhook?create_webhook"),
38
+ "idModel" => test_org_id
47
39
  }
48
40
  end
49
41
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Tacokit::Client do
4
4
  describe "#configuration" do
@@ -17,8 +17,8 @@ describe Tacokit::Client do
17
17
 
18
18
  board = boards.first
19
19
 
20
- expect(board.name).to eq 'Test Board'
21
- assert_requested :get, trello_url_template('members/me/boards{?key,token}')
20
+ expect(board.name).to eq "Test Board"
21
+ assert_requested :get, trello_url_template("members/me/boards{?key,token}")
22
22
  end
23
23
  end
24
24
 
@@ -1,51 +1,50 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Tacokit::Configuration do
4
4
  let(:configuration) { Tacokit::Configuration.new }
5
5
 
6
- it 'has an app_key attribute' do
7
- configuration.app_key = 'app_key'
8
- expect(configuration.app_key).to eq('app_key')
6
+ it "has an app_key attribute" do
7
+ configuration.app_key = "app_key"
8
+ expect(configuration.app_key).to eq("app_key")
9
9
  end
10
10
 
11
- it 'has an app_secret attribute' do
12
- configuration.app_secret = 'app_secret'
13
- expect(configuration.app_secret).to eq('app_secret')
11
+ it "has an app_secret attribute" do
12
+ configuration.app_secret = "app_secret"
13
+ expect(configuration.app_secret).to eq("app_secret")
14
14
  end
15
15
 
16
- it 'has an oauth_token attribute' do
17
- configuration.oauth_token = 'oauth_token'
18
- expect(configuration.oauth_token).to eq('oauth_token')
16
+ it "has an oauth_token attribute" do
17
+ configuration.oauth_token = "oauth_token"
18
+ expect(configuration.oauth_token).to eq("oauth_token")
19
19
  end
20
20
 
21
- it 'has an oauth_token_secret attribute' do
22
- configuration.oauth_secret = 'oauth_secret'
23
- expect(configuration.oauth_secret).to eq('oauth_secret')
21
+ it "has an oauth_token_secret attribute" do
22
+ configuration.oauth_secret = "oauth_secret"
23
+ expect(configuration.oauth_secret).to eq("oauth_secret")
24
24
  end
25
25
 
26
- it 'has a developer public key attribute' do
27
- configuration.app_key = 'app_key'
28
- expect(configuration.app_key).to eq('app_key')
26
+ it "has a developer public key attribute" do
27
+ configuration.app_key = "app_key"
28
+ expect(configuration.app_key).to eq("app_key")
29
29
  end
30
30
 
31
- it 'has a member token attribute' do
32
- configuration.app_secret = 'app_secret'
33
- expect(configuration.app_secret).to eq('app_secret')
31
+ it "has a member token attribute" do
32
+ configuration.app_secret = "app_secret"
33
+ expect(configuration.app_secret).to eq("app_secret")
34
34
  end
35
35
 
36
- describe '#initialize' do
37
- it 'sets key attributes provided as a hash' do
36
+ describe "#initialize" do
37
+ it "sets key attributes provided as a hash" do
38
38
  configuration = Tacokit::Configuration.new \
39
- app_key: 'app_key',
40
- app_secret: 'app_secret',
41
- oauth_token: 'oauth_token',
42
- oauth_secret: 'oauth_secret'
43
-
44
- expect(configuration.app_key).to eq('app_key')
45
- expect(configuration.app_secret).to eq('app_secret')
46
- expect(configuration.oauth_token).to eq('oauth_token')
47
- expect(configuration.oauth_secret).to eq('oauth_secret')
39
+ app_key: "app_key",
40
+ app_secret: "app_secret",
41
+ oauth_token: "oauth_token",
42
+ oauth_secret: "oauth_secret"
43
+
44
+ expect(configuration.app_key).to eq("app_key")
45
+ expect(configuration.app_secret).to eq("app_secret")
46
+ expect(configuration.oauth_token).to eq("oauth_token")
47
+ expect(configuration.oauth_secret).to eq("oauth_secret")
48
48
  end
49
49
  end
50
-
51
50
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Tacokit::Middleware::Boom do
4
4
  let(:app) { Object.new }
@@ -6,30 +6,29 @@ describe Tacokit::Middleware::Boom do
6
6
  let(:middleware) { described_class.new(app) }
7
7
 
8
8
  describe "#on_complete" do
9
-
10
9
  it "raises 404" do
11
10
  env[:status] = 404
12
- expect{middleware.on_complete(env)}.to raise_error(Tacokit::Error::ResourceNotFound)
11
+ expect { middleware.on_complete(env) }.to raise_error(Tacokit::Error::ResourceNotFound)
13
12
  end
14
13
 
15
14
  it "raises 407" do
16
15
  env[:status] = 407
17
- expect{middleware.on_complete(env)}.to raise_error(Tacokit::Error::ConnectionFailed)
16
+ expect { middleware.on_complete(env) }.to raise_error(Tacokit::Error::ConnectionFailed)
18
17
  end
19
18
 
20
19
  it "raises 400" do
21
20
  env[:status] = 400
22
- expect{middleware.on_complete(env)}.to raise_error(Tacokit::Error::ClientError)
21
+ expect { middleware.on_complete(env) }.to raise_error(Tacokit::Error::ClientError)
23
22
  end
24
23
 
25
24
  it "raises 401" do
26
25
  env[:status] = 401
27
- expect{middleware.on_complete(env)}.to raise_error(Tacokit::Error::Unauthorized)
26
+ expect { middleware.on_complete(env) }.to raise_error(Tacokit::Error::Unauthorized)
28
27
  end
29
28
 
30
29
  it "does nothing" do
31
30
  env[:status] = 200
32
- expect{middleware.on_complete(env)}.not_to raise_error
31
+ expect { middleware.on_complete(env) }.not_to raise_error
33
32
  end
34
33
  end
35
34
  end