learn-co-students / rails-github-api-v-000

Other
2 stars 791 forks source link

create new repo test broken #332

Open kevinYCKim33 opened 6 years ago

kevinYCKim33 commented 6 years ago

Even when I copy the solutions down on creating a new Github repo, the last test fails with this message:

WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled. Unregistered request: POST https://api.github.com/user/repos with body '{"name":"a-new-repo"}' with headers {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'token 1', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.13.1'}

bhabig commented 6 years ago

this can be fixed by changing the post request stub to users/repos in spec_helper.rb

you can fix this by changing the stub to the following:

stub_request(:post, "https://api.github.com/user/repos").
      with(:body => {"{\"name\":\"a-new-repo\"}"=>nil},
      :headers => {'Authorization'=>'token 1'}).
      to_return(:status => 200, :body => "", :headers => {})
ecssiah commented 6 years ago

All of the tests are now broken due to the webmock issue. This thread on the webmock repo suggests a solution.

#163 (comment)