teamsnap_rb 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/teamsnap/version.rb +1 -1
- data/lib/teamsnap.rb +64 -46
- data/spec/cassettes/apiv3-init.yml +1358 -1229
- data/spec/cassettes/teamsnap_rb/adds_find_if_search_is_available.yml +19 -21
- data/spec/cassettes/teamsnap_rb/adds_href_to_items.yml +8 -8
- data/spec/cassettes/teamsnap_rb/can_follow_plural_links.yml +44 -55
- data/spec/cassettes/teamsnap_rb/can_follow_singular_links.yml +37 -41
- data/spec/cassettes/teamsnap_rb/can_handle_an_empty_bulk_load.yml +14 -22
- data/spec/cassettes/teamsnap_rb/can_handle_an_error_with_bulk_load.yml +12 -14
- data/spec/cassettes/teamsnap_rb/can_handle_errors_generated_by_command.yml +14 -16
- data/spec/cassettes/teamsnap_rb/can_handle_links_with_no_data.yml +29 -45
- data/spec/cassettes/teamsnap_rb/can_use_bulk_load.yml +28 -31
- data/spec/cassettes/teamsnap_rb/handles_executing_an_action_via_commands.yml +18 -26
- data/spec/cassettes/teamsnap_rb/handles_executing_an_action_via_commands_with_multiple_params.yml +2918 -0
- data/spec/cassettes/teamsnap_rb/handles_fetching_data_via_queries.yml +18 -26
- data/spec/cassettes/teamsnap_rb/handles_queries_with_no_data.yml +15 -23
- data/spec/cassettes/teamsnap_rb/raises_an_exception_if_find_returns_nothing.yml +15 -23
- data/spec/cassettes/teamsnap_rb/supports_relations_with_expected_behaviors/when_a_plural_relation_is_called/responds_with_an_array_of_objects_when_successful.yml +28 -40
- data/spec/cassettes/teamsnap_rb/supports_relations_with_expected_behaviors/when_a_plural_relation_is_called/responds_with_an_empty_array_when_no_objects_exist.yml +22 -34
- data/spec/cassettes/teamsnap_rb/supports_relations_with_expected_behaviors/when_a_singular_relation_is_called/responds_with_nil_if_it_does_NOT_exist.yml +22 -34
- data/spec/cassettes/teamsnap_rb/supports_relations_with_expected_behaviors/when_a_singular_relation_is_called/responds_with_the_object_if_it_exists.yml +25 -37
- data/spec/spec_helper.rb +10 -0
- data/spec/teamsnap_spec.rb +72 -9
- metadata +4 -2
data/spec/teamsnap_spec.rb
CHANGED
@@ -1,13 +1,59 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "teamsnap"
|
3
3
|
|
4
|
+
RSpec.describe "teamsnap_rb" do
|
5
|
+
let(:default_url) { TeamSnap::DEFAULT_URL }
|
6
|
+
let(:specified_url) { "https://url-fun-zone.com" }
|
7
|
+
let(:response) { Typhoeus::Response.new(
|
8
|
+
code: 200, body: { :collection => { :links => [] } }.to_json
|
9
|
+
) }
|
10
|
+
|
11
|
+
describe ".init" do
|
12
|
+
it "requires token or client id and client secret" do
|
13
|
+
expect {
|
14
|
+
TeamSnap.init
|
15
|
+
}.to raise_error(ArgumentError, "You must provide a :token or :client_id and :client_secret pair to '.init'")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "initializes with default url and token auth" do
|
19
|
+
Typhoeus.stub(%r(#{default_url})).and_return(response)
|
20
|
+
|
21
|
+
TeamSnap.init(:token => "mytoken", :backup_cache => false)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "requires client secret when given client id" do
|
25
|
+
expect {
|
26
|
+
TeamSnap.init(:client_id => "myclient")
|
27
|
+
}.to raise_error(ArgumentError, "You must provide a :token or :client_id and :client_secret pair to '.init'")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "initializes with default url and hmac auth" do
|
31
|
+
Typhoeus.stub(/#{default_url}/).and_return(response)
|
32
|
+
|
33
|
+
TeamSnap.init(
|
34
|
+
:client_id => "myclient", :client_secret => "mysecret", :backup_cache => false
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "allows url to be specified" do
|
39
|
+
Typhoeus.stub(/#{specified_url}/).and_return(response)
|
40
|
+
|
41
|
+
TeamSnap.init(
|
42
|
+
:client_id => "myclient", :client_secret => "mysecret", :backup_cache => false,
|
43
|
+
:url => specified_url
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
4
49
|
RSpec.describe "teamsnap_rb", :vcr => true do
|
5
50
|
before(:all) do
|
6
51
|
VCR.use_cassette("apiv3-init") do
|
7
52
|
TeamSnap.init(
|
8
|
-
:url =>
|
9
|
-
:
|
10
|
-
:
|
53
|
+
:url => ROOT_TEST_URL,
|
54
|
+
:backup_cache => false,
|
55
|
+
:client_id => "classic",
|
56
|
+
:client_secret => "dont_tell_the_cops"
|
11
57
|
)
|
12
58
|
end
|
13
59
|
end
|
@@ -45,6 +91,23 @@ RSpec.describe "teamsnap_rb", :vcr => true do
|
|
45
91
|
expect(ms[0].id).to eq(1)
|
46
92
|
end
|
47
93
|
|
94
|
+
it "handles executing an action via commands with multiple params" do
|
95
|
+
TeamSnap.init(
|
96
|
+
:url => ROOT_TEST_URL,
|
97
|
+
:backup_cache => false,
|
98
|
+
:token => "1-classic-dont_tell_the_cops"
|
99
|
+
)
|
100
|
+
|
101
|
+
ms = TeamSnap::Team.invite(
|
102
|
+
:team_id => 1, :member_id => [9, 11], :notify_as_member_id => 3,
|
103
|
+
:introduction => "Welcome! This is our team\n ...the superstars!"
|
104
|
+
)
|
105
|
+
|
106
|
+
expect(ms.size).to eq(2)
|
107
|
+
expect(ms.map(&:id)).to eq([9, 11])
|
108
|
+
expect(ms.map(&:is_invited)).to eq([true, true])
|
109
|
+
end
|
110
|
+
|
48
111
|
it "raises and exception when a command is invalid" do
|
49
112
|
expect {
|
50
113
|
TeamSnap::Member.disable_member(:foo => :bar)
|
@@ -79,7 +142,7 @@ RSpec.describe "teamsnap_rb", :vcr => true do
|
|
79
142
|
end
|
80
143
|
|
81
144
|
it "can follow singular links" do
|
82
|
-
m = TeamSnap::Member.find(
|
145
|
+
m = TeamSnap::Member.find(3)
|
83
146
|
t = m.team
|
84
147
|
|
85
148
|
expect(t.id).to eq(1)
|
@@ -96,19 +159,19 @@ RSpec.describe "teamsnap_rb", :vcr => true do
|
|
96
159
|
t = TeamSnap::Team.find(1)
|
97
160
|
ms = t.members
|
98
161
|
|
99
|
-
expect(ms.size).to eq(
|
162
|
+
expect(ms.size).to eq(16)
|
100
163
|
end
|
101
164
|
|
102
165
|
it "can use bulk load" do
|
103
166
|
cs = TeamSnap.bulk_load(:team_id => 1, :types => "team,member")
|
104
167
|
|
105
168
|
expect(cs).to_not be_empty
|
106
|
-
expect(cs.size).to eq(
|
169
|
+
expect(cs.size).to eq(17)
|
107
170
|
expect(cs[0]).to be_a(TeamSnap::Team)
|
108
171
|
expect(cs[0].id).to eq(1)
|
109
|
-
cs[
|
172
|
+
cs[3..17].each.with_index(5) do |c, idx|
|
110
173
|
expect(c).to be_a(TeamSnap::Member)
|
111
|
-
expect(c.id).to eq(idx
|
174
|
+
expect(c.id).to eq(idx)
|
112
175
|
end
|
113
176
|
end
|
114
177
|
|
@@ -130,7 +193,7 @@ RSpec.describe "teamsnap_rb", :vcr => true do
|
|
130
193
|
it "adds href to items" do
|
131
194
|
m = TeamSnap::Member.find(1)
|
132
195
|
|
133
|
-
expect(m.href).to eq("
|
196
|
+
expect(m.href).to eq("#{ROOT_TEST_URL}/members/1")
|
134
197
|
end
|
135
198
|
|
136
199
|
context "supports relations with expected behaviors" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamsnap_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Emmons
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- spec/cassettes/teamsnap_rb/can_handle_links_with_no_data.yml
|
165
165
|
- spec/cassettes/teamsnap_rb/can_use_bulk_load.yml
|
166
166
|
- spec/cassettes/teamsnap_rb/handles_executing_an_action_via_commands.yml
|
167
|
+
- spec/cassettes/teamsnap_rb/handles_executing_an_action_via_commands_with_multiple_params.yml
|
167
168
|
- spec/cassettes/teamsnap_rb/handles_fetching_data_via_queries.yml
|
168
169
|
- spec/cassettes/teamsnap_rb/handles_queries_with_no_data.yml
|
169
170
|
- spec/cassettes/teamsnap_rb/raises_an_exception_if_find_returns_nothing.yml
|
@@ -211,6 +212,7 @@ test_files:
|
|
211
212
|
- spec/cassettes/teamsnap_rb/can_handle_links_with_no_data.yml
|
212
213
|
- spec/cassettes/teamsnap_rb/can_use_bulk_load.yml
|
213
214
|
- spec/cassettes/teamsnap_rb/handles_executing_an_action_via_commands.yml
|
215
|
+
- spec/cassettes/teamsnap_rb/handles_executing_an_action_via_commands_with_multiple_params.yml
|
214
216
|
- spec/cassettes/teamsnap_rb/handles_fetching_data_via_queries.yml
|
215
217
|
- spec/cassettes/teamsnap_rb/handles_queries_with_no_data.yml
|
216
218
|
- spec/cassettes/teamsnap_rb/raises_an_exception_if_find_returns_nothing.yml
|