teamsnap_rb 0.0.8 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +13 -0
  3. data/Gemfile +2 -1
  4. data/LICENSE +1 -1
  5. data/README.md +31 -79
  6. data/Rakefile +19 -1
  7. data/lib/teamsnap/version.rb +3 -0
  8. data/lib/teamsnap.rb +270 -0
  9. data/spec/cassettes/apiv3-init.yml +1963 -0
  10. data/spec/cassettes/teamsnap_rb/adds_find_if_search_is_available.yml +56 -0
  11. data/spec/cassettes/teamsnap_rb/can_follow_plural_links.yml +111 -0
  12. data/spec/cassettes/teamsnap_rb/can_follow_singular_links.yml +105 -0
  13. data/spec/cassettes/teamsnap_rb/can_handle_an_empty_bulk_load.yml +52 -0
  14. data/spec/cassettes/teamsnap_rb/can_handle_an_error_with_bulk_load.yml +50 -0
  15. data/spec/cassettes/teamsnap_rb/can_handle_errors_generated_by_command.yml +50 -0
  16. data/spec/cassettes/teamsnap_rb/can_handle_links_with_no_data.yml +101 -0
  17. data/spec/cassettes/teamsnap_rb/can_use_bulk_load.yml +61 -0
  18. data/spec/cassettes/teamsnap_rb/handles_executing_an_action_via_commands.yml +54 -0
  19. data/spec/cassettes/teamsnap_rb/handles_fetching_data_via_queries.yml +56 -0
  20. data/spec/cassettes/teamsnap_rb/handles_queries_with_no_data.yml +53 -0
  21. data/spec/cassettes/teamsnap_rb/raises_an_exception_if_find_returns_nothing.yml +53 -0
  22. data/spec/spec_helper.rb +18 -13
  23. data/spec/teamsnap_spec.rb +125 -0
  24. data/teamsnap_rb.gemspec +17 -15
  25. metadata +100 -84
  26. data/lib/teamsnap_rb/client.rb +0 -8
  27. data/lib/teamsnap_rb/collection.rb +0 -179
  28. data/lib/teamsnap_rb/command.rb +0 -39
  29. data/lib/teamsnap_rb/commands.rb +0 -40
  30. data/lib/teamsnap_rb/config.rb +0 -14
  31. data/lib/teamsnap_rb/exceptions.rb +0 -3
  32. data/lib/teamsnap_rb/item.rb +0 -136
  33. data/lib/teamsnap_rb/link.rb +0 -24
  34. data/lib/teamsnap_rb/links_proxy.rb +0 -40
  35. data/lib/teamsnap_rb/models/event.rb +0 -4
  36. data/lib/teamsnap_rb/models/user.rb +0 -4
  37. data/lib/teamsnap_rb/queries_proxy.rb +0 -68
  38. data/lib/teamsnap_rb/request_builder.rb +0 -67
  39. data/lib/teamsnap_rb/template.rb +0 -37
  40. data/lib/teamsnap_rb/version.rb +0 -3
  41. data/lib/teamsnap_rb.rb +0 -22
  42. data/spec/client_spec.rb +0 -39
  43. data/spec/collection_spec.rb +0 -175
  44. data/spec/command_spec.rb +0 -60
  45. data/spec/commands_spec.rb +0 -35
  46. data/spec/config_spec.rb +0 -16
  47. data/spec/fixtures/cassettes/production_root.yml +0 -59
  48. data/spec/fixtures/cassettes/root.yml +0 -573
  49. data/spec/fixtures/cassettes/team.yml +0 -4858
  50. data/spec/fixtures/cassettes/teams.yml +0 -160
  51. data/spec/item_spec.rb +0 -133
  52. data/spec/link_spec.rb +0 -43
  53. data/spec/links_proxy_spec.rb +0 -32
  54. data/spec/queries_proxy_spec.rb +0 -31
  55. data/spec/template_spec.rb +0 -57
@@ -1,160 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://localhost:3003/teams
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Faraday v0.9.0
12
- Accept-Encoding:
13
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
- Accept:
15
- - "*/*"
16
- response:
17
- status:
18
- code: 200
19
- message: 'OK '
20
- headers:
21
- Content-Type:
22
- - application/vnd.collection+json
23
- Content-Length:
24
- - '2809'
25
- X-Content-Type-Options:
26
- - nosniff
27
- X-Ratelimit-Limit:
28
- - '5000'
29
- X-Ratelimit-Remaining:
30
- - '4999'
31
- X-Ratelimit-Reset:
32
- - '1415740100'
33
- Etag:
34
- - '"5daf3cf1d2f681f9ce53cdea0e70b9fb"'
35
- Cache-Control:
36
- - max-age=0, private, must-revalidate
37
- X-Request-Id:
38
- - b700c77f-a114-4cfb-b682-df629213ff22
39
- X-Runtime:
40
- - '0.062563'
41
- Server:
42
- - WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
43
- Date:
44
- - Tue, 11 Nov 2014 20:08:20 GMT
45
- Connection:
46
- - Keep-Alive
47
- body:
48
- encoding: UTF-8
49
- string: '{"collection":{"version":"3.1.1","href":"http://localhost:3003/teams","template":{"data":[{"name":"name","value":null},{"name":"location_country","value":null},{"name":"location_postal_code","value":null},{"name":"time_zone","value":null},{"name":"sport_id","value":null},{"name":"division_name","value":null},{"name":"season_name","value":null},{"name":"league_name","value":null},{"name":"league_url","value":null}]},"links":[{"rel":"active_season_team","href":"http://localhost:3003/teams"},{"rel":"assignments","href":"http://localhost:3003/assignments"},{"rel":"availabilities","href":"http://localhost:3003/availabilities"},{"rel":"contact_email_addresses","href":"http://localhost:3003/contact_email_addresses"},{"rel":"contact_phone_numbers","href":"http://localhost:3003/contact_phone_numbers"},{"rel":"contacts","href":"http://localhost:3003/contacts"},{"rel":"custom_data","href":"http://localhost:3003/custom_data"},{"rel":"custom_fields","href":"http://localhost:3003/custom_fields"},{"rel":"events","href":"http://localhost:3003/events"},{"rel":"locations","href":"http://localhost:3003/locations"},{"rel":"managers","href":"http://localhost:3003/members"},{"rel":"member_email_addresses","href":"http://localhost:3003/member_email_addresses"},{"rel":"member_files","href":"http://localhost:3003/member_files"},{"rel":"member_links","href":"http://localhost:3003/member_links"},{"rel":"member_phone_numbers","href":"http://localhost:3003/member_phone_numbers"},{"rel":"members","href":"http://localhost:3003/members"},{"rel":"members_preferences","href":"http://localhost:3003/members_preferences"},{"rel":"opponents","href":"http://localhost:3003/opponents"},{"rel":"owner","href":"http://localhost:3003/members"},{"rel":"plan","href":"http://localhost:3003/plans"},{"rel":"sport","href":"http://localhost:3003/sports"},{"rel":"team_preferences","href":"http://localhost:3003/teams_preferences"},{"rel":"team_public_site","href":"http://localhost:3003/team_public_sites"},{"rel":"team_results","href":"http://localhost:3003/teams_results"},{"rel":"tracked_item_statuses","href":"http://localhost:3003/tracked_item_statuses"},{"rel":"tracked_items","href":"http://localhost:3003/tracked_items"},{"rel":"root","href":"http://localhost:3003/"},{"rel":"self","href":"http://localhost:3003/teams"}],"queries":[{"rel":"search","href":"http://localhost:3003/teams/search","data":[{"name":"id","value":null},{"name":"team_id","value":null},{"name":"user_id","value":null}]}],"commands":[{"rel":"invite","href":"http://localhost:3003/teams/invite","prompt":"invite
50
- team members or contacts to join TeamSnap.","data":[{"name":"team_id","value":null},{"name":"contact_id","value":null},{"name":"member_id","value":null},{"name":"introduction","value":null},{"name":"notify_as_member_id","value":null}]}]}}'
51
- http_version:
52
- recorded_at: Tue, 11 Nov 2014 20:08:20 GMT
53
- - request:
54
- method: post
55
- uri: http://localhost:3003/teams
56
- body:
57
- encoding: UTF-8
58
- string: '{"template":{"data":[{"name":"name","value":"Teamsters"},{"name":"location_country","value":"United
59
- States"},{"name":"location_postal_code","value":"80951"},{"name":"time_zone","value":"America/Denver"},{"name":"sport_id","value":1}]}}'
60
- headers:
61
- User-Agent:
62
- - Faraday v0.9.0
63
- Content-Type:
64
- - application/json
65
- Accept-Encoding:
66
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
67
- Accept:
68
- - "*/*"
69
- response:
70
- status:
71
- code: 201
72
- message: 'Created '
73
- headers:
74
- Content-Type:
75
- - application/vnd.collection+json
76
- Location:
77
- - http://localhost:3003/teams/search?id=5
78
- Content-Length:
79
- - '6284'
80
- X-Content-Type-Options:
81
- - nosniff
82
- X-Ratelimit-Limit:
83
- - '5000'
84
- X-Ratelimit-Remaining:
85
- - '4991'
86
- X-Ratelimit-Reset:
87
- - '1415740100'
88
- Etag:
89
- - '"7685a9d4f241478253b29a4775bd305c"'
90
- Cache-Control:
91
- - max-age=0, private, must-revalidate
92
- X-Request-Id:
93
- - a9ae86e1-7d53-4cc5-a776-9bdefda9f871
94
- X-Runtime:
95
- - '0.090504'
96
- Server:
97
- - WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
98
- Date:
99
- - Tue, 11 Nov 2014 20:53:04 GMT
100
- Connection:
101
- - Keep-Alive
102
- body:
103
- encoding: UTF-8
104
- string: '{"collection":{"version":"3.1.1","href":"http://localhost:3003/teams","template":{"data":[{"name":"name","value":null},{"name":"location_country","value":null},{"name":"location_postal_code","value":null},{"name":"time_zone","value":null},{"name":"sport_id","value":null},{"name":"division_name","value":null},{"name":"season_name","value":null},{"name":"league_name","value":null},{"name":"league_url","value":null}]},"links":[{"rel":"active_season_team","href":"http://localhost:3003/teams"},{"rel":"assignments","href":"http://localhost:3003/assignments"},{"rel":"availabilities","href":"http://localhost:3003/availabilities"},{"rel":"contact_email_addresses","href":"http://localhost:3003/contact_email_addresses"},{"rel":"contact_phone_numbers","href":"http://localhost:3003/contact_phone_numbers"},{"rel":"contacts","href":"http://localhost:3003/contacts"},{"rel":"custom_data","href":"http://localhost:3003/custom_data"},{"rel":"custom_fields","href":"http://localhost:3003/custom_fields"},{"rel":"events","href":"http://localhost:3003/events"},{"rel":"locations","href":"http://localhost:3003/locations"},{"rel":"managers","href":"http://localhost:3003/members"},{"rel":"member_email_addresses","href":"http://localhost:3003/member_email_addresses"},{"rel":"member_files","href":"http://localhost:3003/member_files"},{"rel":"member_links","href":"http://localhost:3003/member_links"},{"rel":"member_phone_numbers","href":"http://localhost:3003/member_phone_numbers"},{"rel":"members","href":"http://localhost:3003/members"},{"rel":"members_preferences","href":"http://localhost:3003/members_preferences"},{"rel":"opponents","href":"http://localhost:3003/opponents"},{"rel":"owner","href":"http://localhost:3003/members"},{"rel":"plan","href":"http://localhost:3003/plans"},{"rel":"sport","href":"http://localhost:3003/sports"},{"rel":"team_preferences","href":"http://localhost:3003/teams_preferences"},{"rel":"team_public_site","href":"http://localhost:3003/team_public_sites"},{"rel":"team_results","href":"http://localhost:3003/teams_results"},{"rel":"tracked_item_statuses","href":"http://localhost:3003/tracked_item_statuses"},{"rel":"tracked_items","href":"http://localhost:3003/tracked_items"},{"rel":"root","href":"http://localhost:3003/"},{"rel":"self","href":"http://localhost:3003/teams"}],"queries":[{"rel":"search","href":"http://localhost:3003/teams/search","data":[{"name":"id","value":null},{"name":"team_id","value":null},{"name":"user_id","value":null}]}],"commands":[{"rel":"invite","href":"http://localhost:3003/teams/invite","prompt":"invite
105
- team members or contacts to join TeamSnap.","data":[{"name":"team_id","value":null},{"name":"contact_id","value":null},{"name":"member_id","value":null},{"name":"introduction","value":null},{"name":"notify_as_member_id","value":null}]}],"items":[{"href":"http://localhost:3003/teams/5","data":[{"name":"id","value":5},{"name":"type","value":"team"},{"name":"name","value":"Teamsters"},{"name":"time_zone_offset","value":"-07:00"},{"name":"time_zone_iana_name","value":"America/Denver"},{"name":"time_zone_description","value":"Mountain
106
- Time (US & Canada)"},{"name":"updated_at","value":"2014-11-11T20:53:04Z","type":"DateTime"},{"name":"created_at","value":"2014-11-11T20:53:04Z","type":"DateTime"},{"name":"league_name","value":null},{"name":"league_url","value":null},{"name":"division_name","value":null},{"name":"season_name","value":null},{"name":"location_country","value":"United
107
- States"},{"name":"location_postal_code","value":"80951"},{"name":"is_archived_season","value":false},{"name":"sport_id","value":1},{"name":"plan_id","value":14}],"links":[{"rel":"assignments","href":"http://localhost:3003/assignments/search?team_id=5"},{"rel":"availabilities","href":"http://localhost:3003/availabilities/search?team_id=5"},{"rel":"calendar_http","href":"http://86ed2e8eefaaee16c4b7-16391cffaf9272bff70e93998d553c16.r2.cf1.rackcdn.com/team_schedule/.ics"},{"rel":"calendar_http_games_only","href":"http://86ed2e8eefaaee16c4b7-16391cffaf9272bff70e93998d553c16.r2.cf1.rackcdn.com/team_schedule/filter/games/.ics"},{"rel":"calendar_webcal","href":"webcal://86ed2e8eefaaee16c4b7-16391cffaf9272bff70e93998d553c16.r2.cf1.rackcdn.com/team_schedule/.ics"},{"rel":"calendar_webcal_games_only","href":"webcal://86ed2e8eefaaee16c4b7-16391cffaf9272bff70e93998d553c16.r2.cf1.rackcdn.com/team_schedule/filter/games/.ics"},{"rel":"contact_email_addresses","href":"http://localhost:3003/contact_email_addresses/search?team_id=5"},{"rel":"contact_phone_numbers","href":"http://localhost:3003/contact_phone_numbers/search?team_id=5"},{"rel":"contacts","href":"http://localhost:3003/contacts/search?team_id=5"},{"rel":"custom_data","href":"http://localhost:3003/custom_data/search?team_id=5"},{"rel":"custom_fields","href":"http://localhost:3003/custom_fields/search?team_id=5"},{"rel":"events","href":"http://localhost:3003/events/search?team_id=5"},{"rel":"locations","href":"http://localhost:3003/locations/search?team_id=5"},{"rel":"managers","href":"http://localhost:3003/members/managers?team_id=5"},{"rel":"member_email_addresses","href":"http://localhost:3003/member_email_addresses/search?team_id=5"},{"rel":"member_files","href":"http://localhost:3003/member_files/search?team_id=5"},{"rel":"member_links","href":"http://localhost:3003/member_links/search?team_id=5"},{"rel":"member_phone_numbers","href":"http://localhost:3003/member_phone_numbers/search?team_id=5"},{"rel":"members","href":"http://localhost:3003/members/search?team_id=5"},{"rel":"members_preferences","href":"http://localhost:3003/members_preferences/search?team_id=5"},{"rel":"opponents","href":"http://localhost:3003/opponents/search?team_id=5"},{"rel":"owner","href":"http://localhost:3003/owner_members?team_id=5"},{"rel":"plan","href":"http://localhost:3003/plans/14"},{"rel":"sport","href":"http://localhost:3003/sports/1"},{"rel":"team_preferences","href":"http://localhost:3003/teams_preferences/5"},{"rel":"team_public_site","href":"http://localhost:3003/team_public_sites/5"},{"rel":"team_results","href":"http://localhost:3003/teams_results/5"},{"rel":"tracked_item_statuses","href":"http://localhost:3003/tracked_item_statuses/search?team_id=5"},{"rel":"tracked_items","href":"http://localhost:3003/tracked_items/search?team_id=5"}]}]}}'
108
- http_version:
109
- recorded_at: Tue, 11 Nov 2014 20:53:04 GMT
110
- - request:
111
- method: post
112
- uri: http://localhost:3003/teams
113
- body:
114
- encoding: UTF-8
115
- string: '{"template":{"data":[{"name":"name","value":"Teamsters"}]}}'
116
- headers:
117
- User-Agent:
118
- - Faraday v0.9.0
119
- Content-Type:
120
- - application/json
121
- Accept-Encoding:
122
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
123
- Accept:
124
- - "*/*"
125
- response:
126
- status:
127
- code: 400
128
- message: 'Bad Request '
129
- headers:
130
- Content-Type:
131
- - application/vnd.collection+json
132
- Content-Length:
133
- - '135'
134
- X-Content-Type-Options:
135
- - nosniff
136
- X-Ratelimit-Limit:
137
- - '5000'
138
- X-Ratelimit-Remaining:
139
- - '4990'
140
- X-Ratelimit-Reset:
141
- - '1415740100'
142
- Cache-Control:
143
- - no-cache
144
- X-Request-Id:
145
- - 206bb383-7b6b-40d7-9cb4-b0c5b4f825aa
146
- X-Runtime:
147
- - '0.024213'
148
- Server:
149
- - WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
150
- Date:
151
- - Tue, 11 Nov 2014 20:55:14 GMT
152
- Connection:
153
- - Keep-Alive
154
- body:
155
- encoding: UTF-8
156
- string: '{"collection":{"error":{"message":"sport_id can''t be blank; location_country
157
- can''t be blank; You must enter a valid IANA time zone."}}}'
158
- http_version:
159
- recorded_at: Tue, 11 Nov 2014 20:55:14 GMT
160
- recorded_with: VCR 2.9.3
data/spec/item_spec.rb DELETED
@@ -1,133 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe TeamsnapRb::Item do
4
- use_vcr_cassette "team", :allow_playback_repeats => true, :match_requests_on => [:host, :path, :body, :method]
5
- let(:team_collection) { TeamsnapRb::Collection.new("http://localhost:3003/teams/1", {}, TeamsnapRb::Config.new) }
6
- let(:team_item) { team_collection[0] }
7
-
8
- it "represents a single item and therefore does not include Enumerable" do
9
- expect(TeamsnapRb::Item).to_not include(Enumerable)
10
- end
11
-
12
- context "PATCH teams/1", :vcr do
13
- describe "#save" do
14
- it "successfully saves the item and returns it's collection" do
15
- expect(team_item.with(:name => "Danger Rangers").save).to be_a(TeamsnapRb::Collection)
16
- end
17
-
18
- it "includes the item in the returned collection" do
19
- expect(team_item.with(:name => "Danger Rangers").save.first.href).to eq(team_item.href)
20
- end
21
-
22
- it "includes the updated item's attributes in the returned collection" do
23
- expect(team_item.with(:name => "Danger Rangers").save.first.name).to eq("Danger Rangers")
24
- end
25
- end
26
- end
27
-
28
- context "DELETE teams/1", :vcr do
29
- describe "#delete" do
30
- it "successfully deletes the item and returns true" do
31
- expect(team_item.delete).to eq(true)
32
- end
33
- end
34
- end
35
-
36
- context "GET teams/1", :vcr do
37
- describe "#href" do
38
- it "returns 'teams/1' where 1 is the id of the item" do
39
- expect(team_item.href).to eq("http://localhost:3003/teams/1")
40
- end
41
- end
42
-
43
- describe "accessing item properties" do
44
- it "provides direct access to item properties" do
45
- expect(team_item.name).to eq("Test Mania")
46
- end
47
- end
48
-
49
- describe "#data" do
50
- let(:data) { team_item.data }
51
-
52
- it "returns a Conglomerate::Array of attributes from the collection response's data section" do
53
- expect(data).to be_a(Conglomerate::Array)
54
- end
55
-
56
- it "returns a Conglomerate::Datum for each data item in the Conglomerate::Array" do
57
- expect(data.first).to be_a(Conglomerate::Datum)
58
- end
59
-
60
- it "returns the correct value for a given datum" do
61
- expect(data.first.name).to eq("id")
62
- expect(data.first.value).to eq(1)
63
- end
64
- end
65
-
66
- describe "#commands" do
67
- it "returns a TeamsnapRb::CommandsProxy" do
68
- expect(team_item.commands).to be_a(TeamsnapRb::CommandsProxy)
69
- end
70
-
71
- it "returns a 400 when the command is executed without correct arguments" do
72
- expect(team_item.invite.status).to eq(400)
73
- end
74
-
75
- it "returns a 202 when the command is executed with correct arguments" do
76
- expect(
77
- team_item.invite(
78
- :team_id => 1, :member_id => 8, :notify_as_member_id => 1
79
- ).status
80
- ).to eq(202)
81
- end
82
- end
83
-
84
- describe "#template" do
85
- it "returns a TeamsnapRb::Template" do
86
- expect(team_item.template).to be_a(TeamsnapRb::Template)
87
- end
88
-
89
- it "caches the template on the Item class" do
90
- team_item.template
91
- expect(TeamsnapRb::Item.templates.keys).to include("team")
92
- end
93
- end
94
-
95
- describe "#this" do
96
- it "returns the collection this item belongs to" do
97
- expect(team_item.this).to be_a(TeamsnapRb::Collection)
98
- end
99
-
100
- it "returns a collection with an href that is the generalized form of the specific item href" do
101
- expect(team_item.href).to include(team_item.this.href)
102
- end
103
- end
104
-
105
- describe "#links" do
106
- it "returns a LinksProxy" do
107
- expect(team_item.links).to be_a(TeamsnapRb::LinksProxy)
108
- end
109
-
110
- it "consists of an array of Links" do
111
- expect(team_item.links.first).to be_a(TeamsnapRb::Link)
112
- end
113
-
114
- it "can be accessed like an array" do
115
- expect(team_item.links.first.href).to eq("http://localhost:3003/assignments/search?team_id=1")
116
- end
117
- end
118
-
119
- describe "#with(attrs)" do
120
- it "returns a new TeamsnapRb::Item" do
121
- expect(team_item.with(name: "Goofballs")).to be_a(TeamsnapRb::Item)
122
- end
123
-
124
- it "has the updated attributes on the new TeamsnapRb::Item" do
125
- expect(team_item.with(name: "Goofballs").name).to eq("Goofballs")
126
- end
127
-
128
- it "creates a new object rather than mutating the existing object" do
129
- expect{team_item.with(name: "Goofballs")}.to_not change(team_item, :name)
130
- end
131
- end
132
- end
133
- end
data/spec/link_spec.rb DELETED
@@ -1,43 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe TeamsnapRb::Link do
4
- let(:config) { TeamsnapRb::Config.new }
5
- let(:collection) { double(
6
- TeamsnapRb::Collection, :href => "http://localhost:3003/")
7
- }
8
- let(:conglomerate_link) { double(
9
- Conglomerate::Link, :rel => "team",
10
- :href => "http://localhost:3003/", :follow => collection
11
- ) }
12
- let(:link) { TeamsnapRb::Link.new(conglomerate_link, config) }
13
-
14
- describe "#new" do
15
- it "accepts a Conglomerate item as a link" do
16
- expect{link}.to_not raise_exception
17
- end
18
- end
19
-
20
- describe "#follow" do
21
- use_vcr_cassette "root"
22
-
23
- it "returns the Collection represented by that href" do
24
- expect(link.follow).to be_a(TeamsnapRb::Collection)
25
- end
26
-
27
- it "returns the Collection represented by that href" do
28
- expect(link.follow.href).to eq("http://localhost:3003/")
29
- end
30
- end
31
-
32
- describe "#rel" do
33
- it "returns the rel of the link passed in" do
34
- expect(link.rel).to eq("team")
35
- end
36
- end
37
-
38
- describe "#href" do
39
- it "returns the href of the link passed in" do
40
- expect(link.href).to eq("http://localhost:3003/")
41
- end
42
- end
43
- end
@@ -1,32 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe TeamsnapRb::LinksProxy do
4
- use_vcr_cassette "root"
5
- let(:links_proxy) { TeamsnapRb::Collection.new(
6
- "http://localhost:3003", {}, TeamsnapRb::Config.new
7
- ).links }
8
-
9
- describe "#new" do
10
- it "accepts an array of links from a collection+json response and a config" do
11
- expect(links_proxy).to be_a(TeamsnapRb::LinksProxy)
12
- end
13
- end
14
-
15
- describe "#rels" do
16
- it "returns an array of the link names represented as symbols" do
17
- expect(links_proxy.rels).to include(:teams, :members)
18
- end
19
- end
20
-
21
- describe "sending a link name to the LinksProxy" do
22
- use_vcr_cassette "teams"
23
-
24
- it "follows the link if a matching link rel is found" do
25
- expect(links_proxy.teams).to be_a(TeamsnapRb::Collection)
26
- end
27
-
28
- it "returns a TeamsnapRb::Collection of the matching rel as the link" do
29
- expect(links_proxy.teams.href).to include("/teams")
30
- end
31
- end
32
- end
@@ -1,31 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe TeamsnapRb::QueriesProxy do
4
- use_vcr_cassette "root"
5
-
6
- let(:queries_proxy) { TeamsnapRb::Collection.new(
7
- "http://localhost:3003", {}, TeamsnapRb::Config.new
8
- ).queries }
9
-
10
- describe "#new" do
11
- it "accepts an array of queries from a collection+json response and a config" do
12
- expect(queries_proxy).to be_a(TeamsnapRb::QueriesProxy)
13
- end
14
- end
15
-
16
- describe "#rels" do
17
- it "returns an array of the link names represented as symbols" do
18
- expect(queries_proxy.rels).to include(:bulk_load)
19
- end
20
- end
21
-
22
- describe "sending a link name to the QueriesProxy" do
23
- it "raises a MissingQueryParameter exception if params are missing from the query" do
24
- expect{queries_proxy.bulk_load}.to raise_exception(TeamsnapRb::Query::MissingQueryParameter)
25
- end
26
-
27
- it "returns a TeamsnapRB::Collection when the query executes successfully" do
28
- expect(queries_proxy.bulk_load(:team_id => 1)).to be_a(TeamsnapRb::Collection)
29
- end
30
- end
31
- end
@@ -1,57 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe TeamsnapRb::Template do
4
- use_vcr_cassette "teams", :match_requests_on => [:host, :path, :body]
5
-
6
- let(:template) { TeamsnapRb::Collection.new(
7
- "http://localhost:3003/teams", {}, TeamsnapRb::Config.new
8
- ).template }
9
-
10
- describe "#new" do
11
- it "returns a template object from Collection#template" do
12
- expect(template).to be_a(TeamsnapRb::Template)
13
- end
14
- end
15
-
16
- describe "#build" do
17
- it "returns an empty hash when no attributes are passed in" do
18
- expect(template.build).to eq("template" => {})
19
- end
20
-
21
- it "returns a properly serialized template hash when attrs are passed in" do
22
- expect(template.build("name" => "Teamsters")).to eq(
23
- {
24
- "template"=> {
25
- "data"=>[{
26
- "name"=>"name", "value"=>"Teamsters"
27
- }]
28
- }
29
- }
30
- )
31
- end
32
- end
33
-
34
- describe "#data" do
35
- it "returns a Conglomerate::Array of data that can be passed into the template" do
36
- expect(template.data).to be_a(Conglomerate::Array)
37
- end
38
- end
39
-
40
- describe "POST /teams via Template#push" do
41
- it "returns a bad response (400) when the template fails to post" do
42
- expect(template.push("name" => "Teamsters").status).to eq(400)
43
- end
44
-
45
- it "returns a success (200) when the template posts with all required data" do
46
- expect(
47
- template.push(
48
- "name" => "Teamsters",
49
- "sport_id" => 1,
50
- "location_country" => "United States",
51
- "location_postal_code" => "80951",
52
- "time_zone" => "America/Denver"
53
- ).status
54
- ).to eq(201)
55
- end
56
- end
57
- end