bugsnag-api 1.0.0 → 1.0.1

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +8 -0
  5. data/.yardopts +4 -0
  6. data/CHANGELOG.md +11 -0
  7. data/README.md +12 -4
  8. data/Rakefile +9 -0
  9. data/bugsnag-api.gemspec +5 -0
  10. data/lib/bugsnag/api.rb +20 -4
  11. data/lib/bugsnag/api/client.rb +47 -42
  12. data/lib/bugsnag/api/client/accounts.rb +8 -1
  13. data/lib/bugsnag/api/client/comments.rb +1 -1
  14. data/lib/bugsnag/api/client/errors.rb +1 -1
  15. data/lib/bugsnag/api/client/events.rb +3 -3
  16. data/lib/bugsnag/api/client/projects.rb +15 -4
  17. data/lib/bugsnag/api/client/users.rb +22 -4
  18. data/lib/bugsnag/api/configuration.rb +9 -6
  19. data/lib/bugsnag/api/error.rb +11 -1
  20. data/lib/bugsnag/api/version.rb +1 -1
  21. data/spec/bugsnag/api/client/accounts_spec.rb +45 -0
  22. data/spec/bugsnag/api/client/comments_spec.rb +58 -0
  23. data/spec/bugsnag/api/client/errors_spec.rb +69 -0
  24. data/spec/bugsnag/api/client/events_spec.rb +52 -0
  25. data/spec/bugsnag/api/client/projects_spec.rb +87 -0
  26. data/spec/bugsnag/api/client/users_spec.rb +105 -0
  27. data/spec/bugsnag/api/client_spec.rb +130 -0
  28. data/spec/bugsnag/api_spec.rb +44 -0
  29. data/spec/cassettes/Bugsnag_Api_Client/_get/handles_query_params.yml +56 -0
  30. data/spec/cassettes/Bugsnag_Api_Client/_last_response/caches_the_last_agent_response.yml +56 -0
  31. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_account/returns_the_requested_account.yml +49 -0
  32. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_account/when_using_account_credentials/returns_the_account.yml +51 -0
  33. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_accounts/returns_all_accounts.yml +49 -0
  34. data/spec/cassettes/Bugsnag_Api_Client_Comments/_comments/returns_all_comments_on_an_error.yml +107 -0
  35. data/spec/cassettes/Bugsnag_Api_Client_Comments/_create_comment/created_a_comment.yml +51 -0
  36. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_comment/returns_a_comment.yml +97 -0
  37. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_delete_comment/deletes_an_existing_comment.yml +92 -0
  38. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_update_comment/updates_an_existing_comment.yml +97 -0
  39. data/spec/cassettes/Bugsnag_Api_Client_Errors/_errors/returns_all_errors_on_an_project.yml +48 -0
  40. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_error/returns_an_error.yml +48 -0
  41. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_reopen_error/reopens_the_error.yml +48 -0
  42. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_resolve_error/resolves_the_error.yml +48 -0
  43. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_update_error/updates_the_error.yml +48 -0
  44. data/spec/cassettes/Bugsnag_Api_Client_Events/_error_events/returns_all_events_on_an_error.yml +64 -0
  45. data/spec/cassettes/Bugsnag_Api_Client_Events/_project_events/returns_all_events_on_a_project.yml +64 -0
  46. data/spec/cassettes/Bugsnag_Api_Client_Events/with_event/_event/returns_an_event.yml +56 -0
  47. data/spec/cassettes/Bugsnag_Api_Client_Projects/_account_projects/returns_all_projects_on_an_account.yml +61 -0
  48. data/spec/cassettes/Bugsnag_Api_Client_Projects/_account_projects/when_using_account_credentials/returns_all_projects.yml +63 -0
  49. data/spec/cassettes/Bugsnag_Api_Client_Projects/_create_project/creates_a_project_on_an_account.yml +50 -0
  50. data/spec/cassettes/Bugsnag_Api_Client_Projects/_user_projects/returns_all_projects_for_a_user.yml +61 -0
  51. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_delete_project/deletes_an_existing_project.yml +91 -0
  52. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_project/returns_a_project.yml +95 -0
  53. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_update_project/updates_an_existing_project.yml +95 -0
  54. data/spec/cassettes/Bugsnag_Api_Client_Users/_account_users/returns_all_users_on_an_account.yml +49 -0
  55. data/spec/cassettes/Bugsnag_Api_Client_Users/_account_users/when_using_account_credentials/returns_all_users.yml +51 -0
  56. data/spec/cassettes/Bugsnag_Api_Client_Users/_invite_user/invites_a_user_to_an_account.yml +48 -0
  57. data/spec/cassettes/Bugsnag_Api_Client_Users/_project_users/returns_all_users_for_a_project.yml +49 -0
  58. data/spec/cassettes/Bugsnag_Api_Client_Users/_user/returns_a_user.yml +48 -0
  59. data/spec/cassettes/Bugsnag_Api_Client_Users/_user/when_using_user_credentials/returns_the_authed_user.yml +48 -0
  60. data/spec/cassettes/Bugsnag_Api_Client_Users/with_user/_remove_user/removes_a_user_from_an_account.yml +89 -0
  61. data/spec/cassettes/Bugsnag_Api_Client_Users/with_user/_update_user_permissions/updates_a_users_permissions.yml +93 -0
  62. data/spec/spec_helper.rb +122 -0
  63. metadata +161 -4
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://<BUGSNAG_LOGIN>:<BUGSNAG_PASSWORD>@api.bugsnag.com/accounts/<BUGSNAG_ACCOUNT_ID>/users
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"email":"example@example.com"}'
9
+ headers:
10
+ User-Agent:
11
+ - Bugsnag API Ruby Gem 1.0.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - '*/*'
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Frame-Options:
24
+ - SAMEORIGIN
25
+ X-Xss-Protection:
26
+ - 1; mode=block
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Etag:
32
+ - '"9f7d538242c32229fd4e5e0c9f176a4f"'
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ X-Request-Id:
36
+ - 45ac04dd-eff0-4265-be6c-2e1a8dbdcdd9
37
+ X-Runtime:
38
+ - '0.127316'
39
+ Date:
40
+ - Tue, 02 Sep 2014 02:49:27 GMT
41
+ Connection:
42
+ - close
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"id":"5404dc9c64657377ae000009","email":"example@example.com","name":null,"gravatar_id":"23463b99b62a72f26ed677cc556c44e8","gravatar_url":"https://secure.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8","url":"https://api.bugsnag.com/users/5404dc9c64657377ae000009","projects_url":"https://api.bugsnag.com/users/5404dc9c64657377ae000009/projects","account_admin":false,"html_url":"http://bugsnag.dev/accounts/test-account/collaborators/5404dc9c64657377ae000009/edit"}'
46
+ http_version:
47
+ recorded_at: Tue, 02 Sep 2014 02:49:27 GMT
48
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://<BUGSNAG_LOGIN>:<BUGSNAG_PASSWORD>@api.bugsnag.com/projects/<BUGSNAG_PROJECT_ID>/users
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Bugsnag API Ruby Gem 1.0.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - '*/*'
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Frame-Options:
24
+ - SAMEORIGIN
25
+ X-Xss-Protection:
26
+ - 1; mode=block
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Etag:
32
+ - '"3a733fd3c2867b314fadd37f7c3ac1b5"'
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ X-Request-Id:
36
+ - 4d029297-01ea-4b52-8db2-0d8f20720fdf
37
+ X-Runtime:
38
+ - '0.134824'
39
+ Date:
40
+ - Tue, 02 Sep 2014 02:49:28 GMT
41
+ Connection:
42
+ - close
43
+ body:
44
+ encoding: UTF-8
45
+ string: '[{"id":"5404dc9c64657377ae000009","email":"example@example.com","name":null,"gravatar_id":"23463b99b62a72f26ed677cc556c44e8","gravatar_url":"https://secure.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8","url":"https://api.bugsnag.com/users/5404dc9c64657377ae000009","projects_url":"https://api.bugsnag.com/users/5404dc9c64657377ae000009/projects","account_admin":true,"html_url":"http://bugsnag.dev/accounts/test-account/collaborators/5404dc9c64657377ae000009/edit"},{"id":"<BUGSNAG_USER_ID>","email":"<BUGSNAG_EMAIL>","name":"James
46
+ Smith","gravatar_id":"8cbca651e77dc253a98e545590ed3387","gravatar_url":"https://secure.gravatar.com/avatar/8cbca651e77dc253a98e545590ed3387","url":"https://api.bugsnag.com/users/<BUGSNAG_USER_ID>","projects_url":"https://api.bugsnag.com/users/<BUGSNAG_USER_ID>/projects","account_admin":true,"html_url":"http://bugsnag.dev/accounts/test-account/collaborators/<BUGSNAG_USER_ID>/edit"}]'
47
+ http_version:
48
+ recorded_at: Tue, 02 Sep 2014 02:49:28 GMT
49
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://<BUGSNAG_LOGIN>:<BUGSNAG_PASSWORD>@api.bugsnag.com/users/<BUGSNAG_USER_ID>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Bugsnag API Ruby Gem 1.0.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - '*/*'
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Frame-Options:
24
+ - SAMEORIGIN
25
+ X-Xss-Protection:
26
+ - 1; mode=block
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Etag:
32
+ - '"605bcc250ebda765fc87a6401db995a1"'
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ X-Request-Id:
36
+ - 0b2bbee7-59ac-4b98-9391-990c68368a15
37
+ X-Runtime:
38
+ - '0.124337'
39
+ Date:
40
+ - Tue, 02 Sep 2014 02:49:28 GMT
41
+ Connection:
42
+ - close
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"id":"<BUGSNAG_USER_ID>","email":"<BUGSNAG_EMAIL>","name":"James Smith","gravatar_id":"8cbca651e77dc253a98e545590ed3387","gravatar_url":"https://secure.gravatar.com/avatar/8cbca651e77dc253a98e545590ed3387","url":"https://api.bugsnag.com/users/<BUGSNAG_USER_ID>","projects_url":"https://api.bugsnag.com/users/<BUGSNAG_USER_ID>/projects"}'
46
+ http_version:
47
+ recorded_at: Tue, 02 Sep 2014 02:49:28 GMT
48
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://<BUGSNAG_LOGIN>:<BUGSNAG_PASSWORD>@api.bugsnag.com/user
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Bugsnag API Ruby Gem 1.0.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - '*/*'
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Frame-Options:
24
+ - SAMEORIGIN
25
+ X-Xss-Protection:
26
+ - 1; mode=block
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Etag:
32
+ - '"605bcc250ebda765fc87a6401db995a1"'
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ X-Request-Id:
36
+ - 046d602f-58b8-4914-b443-fe429917b4d6
37
+ X-Runtime:
38
+ - '0.113503'
39
+ Date:
40
+ - Tue, 02 Sep 2014 02:49:27 GMT
41
+ Connection:
42
+ - close
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"id":"<BUGSNAG_USER_ID>","email":"<BUGSNAG_EMAIL>","name":"James Smith","gravatar_id":"8cbca651e77dc253a98e545590ed3387","gravatar_url":"https://secure.gravatar.com/avatar/8cbca651e77dc253a98e545590ed3387","url":"https://api.bugsnag.com/users/<BUGSNAG_USER_ID>","projects_url":"https://api.bugsnag.com/users/<BUGSNAG_USER_ID>/projects"}'
46
+ http_version:
47
+ recorded_at: Tue, 02 Sep 2014 02:49:27 GMT
48
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,89 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://<BUGSNAG_LOGIN>:<BUGSNAG_PASSWORD>@api.bugsnag.com/accounts/<BUGSNAG_ACCOUNT_ID>/users
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"admin":false,"email":"example@example.com"}'
9
+ headers:
10
+ User-Agent:
11
+ - Bugsnag API Ruby Gem 1.0.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - '*/*'
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Frame-Options:
24
+ - SAMEORIGIN
25
+ X-Xss-Protection:
26
+ - 1; mode=block
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Etag:
32
+ - '"9f7d538242c32229fd4e5e0c9f176a4f"'
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ X-Request-Id:
36
+ - 50f0158d-cd91-43f2-96c8-e4024291aa5f
37
+ X-Runtime:
38
+ - '0.129716'
39
+ Date:
40
+ - Tue, 02 Sep 2014 02:49:28 GMT
41
+ Connection:
42
+ - close
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"id":"5404dc9c64657377ae000009","email":"example@example.com","name":null,"gravatar_id":"23463b99b62a72f26ed677cc556c44e8","gravatar_url":"https://secure.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8","url":"https://api.bugsnag.com/users/5404dc9c64657377ae000009","projects_url":"https://api.bugsnag.com/users/5404dc9c64657377ae000009/projects","account_admin":false,"html_url":"http://bugsnag.dev/accounts/test-account/collaborators/5404dc9c64657377ae000009/edit"}'
46
+ http_version:
47
+ recorded_at: Tue, 02 Sep 2014 02:49:28 GMT
48
+ - request:
49
+ method: delete
50
+ uri: http://<BUGSNAG_LOGIN>:<BUGSNAG_PASSWORD>@api.bugsnag.com/accounts/<BUGSNAG_ACCOUNT_ID>/users/5404dc9c64657377ae000009
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{}'
54
+ headers:
55
+ User-Agent:
56
+ - Bugsnag API Ruby Gem 1.0.0
57
+ Content-Type:
58
+ - application/json
59
+ Accept-Encoding:
60
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
61
+ Accept:
62
+ - '*/*'
63
+ response:
64
+ status:
65
+ code: 204
66
+ message: No Content
67
+ headers:
68
+ X-Frame-Options:
69
+ - SAMEORIGIN
70
+ X-Xss-Protection:
71
+ - 1; mode=block
72
+ X-Content-Type-Options:
73
+ - nosniff
74
+ Cache-Control:
75
+ - no-cache
76
+ X-Request-Id:
77
+ - 2ab7722c-2d8d-4fe9-a30c-c6f3e18b3423
78
+ X-Runtime:
79
+ - '0.090745'
80
+ Date:
81
+ - Tue, 02 Sep 2014 02:49:28 GMT
82
+ Connection:
83
+ - close
84
+ body:
85
+ encoding: UTF-8
86
+ string: ''
87
+ http_version:
88
+ recorded_at: Tue, 02 Sep 2014 02:49:28 GMT
89
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,93 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://<BUGSNAG_LOGIN>:<BUGSNAG_PASSWORD>@api.bugsnag.com/accounts/<BUGSNAG_ACCOUNT_ID>/users
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"admin":false,"email":"example@example.com"}'
9
+ headers:
10
+ User-Agent:
11
+ - Bugsnag API Ruby Gem 1.0.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - '*/*'
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Frame-Options:
24
+ - SAMEORIGIN
25
+ X-Xss-Protection:
26
+ - 1; mode=block
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Etag:
32
+ - '"9f7d538242c32229fd4e5e0c9f176a4f"'
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ X-Request-Id:
36
+ - 47aadee0-c6c5-4d8f-9255-57a2765c40f6
37
+ X-Runtime:
38
+ - '0.136265'
39
+ Date:
40
+ - Tue, 02 Sep 2014 02:49:28 GMT
41
+ Connection:
42
+ - close
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"id":"5404dc9c64657377ae000009","email":"example@example.com","name":null,"gravatar_id":"23463b99b62a72f26ed677cc556c44e8","gravatar_url":"https://secure.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8","url":"https://api.bugsnag.com/users/5404dc9c64657377ae000009","projects_url":"https://api.bugsnag.com/users/5404dc9c64657377ae000009/projects","account_admin":false,"html_url":"http://bugsnag.dev/accounts/test-account/collaborators/5404dc9c64657377ae000009/edit"}'
46
+ http_version:
47
+ recorded_at: Tue, 02 Sep 2014 02:49:28 GMT
48
+ - request:
49
+ method: patch
50
+ uri: http://<BUGSNAG_LOGIN>:<BUGSNAG_PASSWORD>@api.bugsnag.com/accounts/<BUGSNAG_ACCOUNT_ID>/users/5404dc9c64657377ae000009
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"admin":true}'
54
+ headers:
55
+ User-Agent:
56
+ - Bugsnag API Ruby Gem 1.0.0
57
+ Content-Type:
58
+ - application/json
59
+ Accept-Encoding:
60
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
61
+ Accept:
62
+ - '*/*'
63
+ response:
64
+ status:
65
+ code: 200
66
+ message: OK
67
+ headers:
68
+ X-Frame-Options:
69
+ - SAMEORIGIN
70
+ X-Xss-Protection:
71
+ - 1; mode=block
72
+ X-Content-Type-Options:
73
+ - nosniff
74
+ Content-Type:
75
+ - application/json; charset=utf-8
76
+ Etag:
77
+ - '"196dacb6c6f0811ea84b72ac7a09e47c"'
78
+ Cache-Control:
79
+ - max-age=0, private, must-revalidate
80
+ X-Request-Id:
81
+ - 2a642fff-de2f-4912-b791-dd35cec9a8b5
82
+ X-Runtime:
83
+ - '0.139348'
84
+ Date:
85
+ - Tue, 02 Sep 2014 02:49:28 GMT
86
+ Connection:
87
+ - close
88
+ body:
89
+ encoding: UTF-8
90
+ string: '{"id":"5404dc9c64657377ae000009","email":"example@example.com","name":null,"gravatar_id":"23463b99b62a72f26ed677cc556c44e8","gravatar_url":"https://secure.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8","url":"https://api.bugsnag.com/users/5404dc9c64657377ae000009","projects_url":"https://api.bugsnag.com/users/5404dc9c64657377ae000009/projects","account_admin":true,"html_url":"http://bugsnag.dev/accounts/test-account/collaborators/5404dc9c64657377ae000009/edit"}'
91
+ http_version:
92
+ recorded_at: Tue, 02 Sep 2014 02:49:28 GMT
93
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,122 @@
1
+ require "bugsnag/api"
2
+ require "webmock/rspec"
3
+ require "faker"
4
+ require "vcr"
5
+ require "uri"
6
+
7
+ # This file was generated by the `rspec --init` command. Conventionally, all
8
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
9
+ # Require this file using `require "spec_helper"` to ensure that it is only
10
+ # loaded once.
11
+ #
12
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
13
+ RSpec.configure do |config|
14
+ config.expect_with :rspec do |c|
15
+ c.syntax = :expect
16
+ end
17
+ end
18
+
19
+ # VCR
20
+ VCR.configure do |c|
21
+ c.cassette_library_dir = "spec/cassettes"
22
+ c.hook_into :webmock
23
+ c.configure_rspec_metadata!
24
+ c.default_cassette_options = {
25
+ :record => ENV['TRAVIS'] ? :none : :once,
26
+ :match_requests_on => [:method, :path]
27
+ }
28
+
29
+ c.filter_sensitive_data("https://api.bugsnag.com") { Bugsnag::Api.configuration.endpoint }
30
+ c.filter_sensitive_data("api.bugsnag.com") { URI.parse(Bugsnag::Api.configuration.endpoint).host }
31
+ c.filter_sensitive_data("<BUGSNAG_AUTH_TOKEN>") { test_bugsnag_auth_token }
32
+ c.filter_sensitive_data("<BUGSNAG_LOGIN>") { CGI::escape(test_bugsnag_email) }
33
+ c.filter_sensitive_data("<BUGSNAG_EMAIL>") { test_bugsnag_email }
34
+ c.filter_sensitive_data("<BUGSNAG_PASSWORD>") { test_bugsnag_password }
35
+ c.filter_sensitive_data("<BUGSNAG_ACCOUNT_ID>") { test_bugsnag_account }
36
+ c.filter_sensitive_data("<BUGSNAG_COMMENT_ID>") { test_bugsnag_comment }
37
+ c.filter_sensitive_data("<BUGSNAG_ERROR_ID>") { test_bugsnag_error }
38
+ c.filter_sensitive_data("<BUGSNAG_EVENT_ID>") { test_bugsnag_event }
39
+ c.filter_sensitive_data("<BUGSNAG_PROJECT_ID>") { test_bugsnag_project }
40
+ c.filter_sensitive_data("<BUGSNAG_USER_ID>") { test_bugsnag_user }
41
+ end
42
+
43
+ def auth_token_client
44
+ Bugsnag::Api.configure do |config|
45
+ config.endpoint = test_bugsnag_endpoint
46
+ end
47
+
48
+ Bugsnag::Api::Client.new do |config|
49
+ config.endpoint = test_bugsnag_endpoint
50
+ config.auth_token = test_bugsnag_auth_token
51
+ end
52
+ end
53
+
54
+ def basic_auth_client
55
+ Bugsnag::Api.configure do |config|
56
+ config.endpoint = test_bugsnag_endpoint
57
+ end
58
+
59
+ Bugsnag::Api::Client.new do |config|
60
+ config.endpoint = test_bugsnag_endpoint
61
+ config.email = test_bugsnag_email
62
+ config.password = test_bugsnag_password
63
+ end
64
+ end
65
+
66
+ def bugsnag_url(path)
67
+ URI.join(Bugsnag::Api.configuration.endpoint, path).to_s
68
+ end
69
+
70
+ def basic_bugsnag_url(path, options = {})
71
+ url = File.join(Bugsnag::Api.configuration.endpoint, path)
72
+ uri = Addressable::URI.parse(url)
73
+
74
+ uri.user = options.fetch(:login, test_bugsnag_email)
75
+ uri.password = options.fetch(:password, test_bugsnag_password)
76
+
77
+ uri.to_s
78
+ end
79
+
80
+ def stub_get(url)
81
+ stub_request(:get, bugsnag_url(url))
82
+ end
83
+
84
+ def test_bugsnag_endpoint
85
+ ENV["BUGSNAG_TEST_ENDPOINT"] || Bugsnag::Api::Configuration::DEFAULT_ENDPOINT
86
+ end
87
+
88
+ def test_bugsnag_auth_token
89
+ ENV["BUGSNAG_TEST_AUTH_TOKEN"] || "x" * 32
90
+ end
91
+
92
+ def test_bugsnag_email
93
+ ENV["BUGSNAG_TEST_EMAIL"] || "example@bugsnag.com"
94
+ end
95
+
96
+ def test_bugsnag_password
97
+ ENV["BUGSNAG_TEST_PASSWORD"] || "password"
98
+ end
99
+
100
+ def test_bugsnag_account
101
+ ENV["BUGSNAG_TEST_ACCOUNT"] || "5404dc9064657377ae000002"
102
+ end
103
+
104
+ def test_bugsnag_comment
105
+ ENV["BUGSNAG_TEST_COMMENT"] || "5404e0ea64657377ae00000b"
106
+ end
107
+
108
+ def test_bugsnag_error
109
+ ENV["BUGSNAG_TEST_ERROR"] || "5404e0c435ec9cb116b13603"
110
+ end
111
+
112
+ def test_bugsnag_event
113
+ ENV["BUGSNAG_TEST_EVENT"] || "5404e0c4fd9c7c077b000001"
114
+ end
115
+
116
+ def test_bugsnag_project
117
+ ENV["BUGSNAG_TEST_PROJECT"] || "5404dc9c64657377ae000007"
118
+ end
119
+
120
+ def test_bugsnag_user
121
+ ENV["BUGSNAG_TEST_USER"] || "5404dc9064657377ae000001"
122
+ end