{"action":"created","issue":{"url":"https://api.github.com/repos/bblimke/webmock/issues/701","repository_url":"https://api.github.com/repos/bblimke/webmock","labels_url":"https://api.github.com/repos/bblimke/webmock/issues/701/labels{/name}","comments_url":"https://api.github.com/repos/bblimke/webmock/issues/701/comments","events_url":"https://api.github.com/repos/bblimke/webmock/issues/701/events","html_url":"https://github.com/bblimke/webmock/issues/701","id":229493376,"number":701,"title":"Add support for detecting if WebMock is enabled","user":{"login":"redconfetti","id":746759,"avatar_url":"https://avatars2.githubusercontent.com/u/746759?v=3","gravatar_id":"","url":"https://api.github.com/users/redconfetti","html_url":"https://github.com/redconfetti","followers_url":"https://api.github.com/users/redconfetti/followers","following_url":"https://api.github.com/users/redconfetti/following{/other_user}","gists_url":"https://api.github.com/users/redconfetti/gists{/gist_id}","starred_url":"https://api.github.com/users/redconfetti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redconfetti/subscriptions","organizations_url":"https://api.github.com/users/redconfetti/orgs","repos_url":"https://api.github.com/users/redconfetti/repos","events_url":"https://api.github.com/users/redconfetti/events{/privacy}","received_events_url":"https://api.github.com/users/redconfetti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-05-17T21:31:24Z","updated_at":"2017-05-17T22:22:09Z","closed_at":null,"body":"# Feature Request\r\n\r\nI'm encountering a use case where we would like to check if WebMock is enabled or not.\r\n\r\n``` ruby\r\n> WebMock.enabled?\r\n=> false\r\n> WebMock.enable!\r\n> WebMock.enabled?\r\n=> true\r\n> WebMock.disable!\r\n> WebMock.enabled?\r\n=> false\r\n```\r\n\r\n## Use Case\r\n\r\nThe application I'm working on raises exceptions when HTTP 400+ response is received, and depending on the circumstance the exception is caught and logged with a stack trace.\r\n\r\nWhen we're using WebMock, these stack traces are not needed in our logs. They're really cluttering up the TravisCI logs unnecessarily. We'd like to exclude the error or stack traces from our logs when WebMock is being used. Support for `WebMock.enabled?` would really help with this.\r\n\r\n## Approach\r\n\r\nI'm thinking of making a pull request for this myself. A simple class variable boolean that is modified in [WebMock.enabled!](https://github.com/bblimke/webmock/blob/e3d0cd1c/lib/webmock/webmock.rb#L36,L42) and WebMock.disabled! is all that's needed.\r\n\r\n```\r\n@@enabled = true\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/bblimke/webmock/issues/comments/302248085","html_url":"https://github.com/bblimke/webmock/issues/701#issuecomment-302248085","issue_url":"https://api.github.com/repos/bblimke/webmock/issues/701","id":302248085,"user":{"login":"redconfetti","id":746759,"avatar_url":"https://avatars2.githubusercontent.com/u/746759?v=3","gravatar_id":"","url":"https://api.github.com/users/redconfetti","html_url":"https://github.com/redconfetti","followers_url":"https://api.github.com/users/redconfetti/followers","following_url":"https://api.github.com/users/redconfetti/following{/other_user}","gists_url":"https://api.github.com/users/redconfetti/gists{/gist_id}","starred_url":"https://api.github.com/users/redconfetti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redconfetti/subscriptions","organizations_url":"https://api.github.com/users/redconfetti/orgs","repos_url":"https://api.github.com/users/redconfetti/repos","events_url":"https://api.github.com/users/redconfetti/events{/privacy}","received_events_url":"https://api.github.com/users/redconfetti/received_events","type":"User","site_admin":false},"created_at":"2017-05-17T22:22:09Z","updated_at":"2017-05-17T22:22:09Z","body":"Yes. You have a point. \r\n\r\nI was also just thinking that some requests using the same adapter may be mocked, while others are not. It sounds like my request is too global to be practical for most others using this library.\r\n\r\nSomeone could use `WebMock::StubRegistry.instance.registered_request?` to check if the request is being stubbed. Even then, there isn't a true correlation between the raised exception and the request response.\r\n\r\n🤔 "}}
{"actor":{"display_login":"redconfetti"}}