Skip to content

Instantly share code, notes, and snippets.

@BenJam
Created February 19, 2019 15:48
Show Gist options
  • Save BenJam/a8fd871bb39da44f506d7542795ba7d4 to your computer and use it in GitHub Desktop.
Save BenJam/a8fd871bb39da44f506d7542795ba7d4 to your computer and use it in GitHub Desktop.
Error:
PersonalAccessTokenValidatorTest#test_does_not_allow_setting_personal_access_token_without_being_enabled:
WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled. Unregistered request: GET https://api.github.com/user with headers {'Accept'=>'application/vnd.github.v3+json', 'Accept-Encoding'=>'gzip,deflate', 'Authorization'=>'token ce8c3fecd2c3a6cc7f75a2fbfca391a7674dadc9', 'Content-Type'=>'application/json', 'Expect'=>'', 'User-Agent'=>'Octokit Ruby Gem 4.13.0'}
You can stub this request with the following snippet:
stub_request(:get, "https://api.github.com/user").
with(
headers: {
'Accept'=>'application/vnd.github.v3+json',
'Accept-Encoding'=>'gzip,deflate',
'Authorization'=>'token ce8c3fecd2c3a6cc7f75a2fbfca391a7674dadc9',
'Content-Type'=>'application/json',
'Expect'=>'',
'User-Agent'=>'Octokit Ruby Gem 4.13.0'
}).
to_return(status: 200, body: "", headers: {})
registered request stubs:
stub_request(:get, "/https:\/\/api.github.com\/notifications/")
stub_request(:get, "https://api.github.com/repos/octobox/octobox/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e")
stub_request(:get, "https://api.github.com/repos/octobox/octobox/issues/57")
stub_request(:get, "https://api.github.com/repos/octobox/octobox/issues/56")
stub_request(:get, "/https:\/\/api.github.com\/user/").
with(
headers: {
'Authorization'=>'token 1234'
})
============================================================
app/validators/personal_access_token_validator.rb:29:in `validate_token_credentials'
app/validators/personal_access_token_validator.rb:14:in `validate'
test/validators/personal_access_token_validator_test.rb:13:in `assert_error_present'
test/validators/personal_access_token_validator_test.rb:24:in `block in <class:PersonalAccessTokenValidatorTest>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment