hipchat / hipchat-rb

HipChat HTTP API Wrapper in Ruby with Capistrano hooks
https://www.hipchat.com/docs/apiv2
MIT License
336 stars 172 forks source link

Bump webmock requirement. #169

Closed balasankarc closed 7 years ago

balasankarc commented 8 years ago

Hi, I am a co-maintainer of hipchat package in Debian. Debian have webmock version 1.22.6 which breaks hipchat (that requires version 1.22.1 exactly). The errors seems to be of incorrect registration of stubs (check below).

Can you bump webmock dependency to support webmock version 1.22.6?

Test fail log
.............................FF...........................................

Failures:

  1) HipChat (API V2) #statistics is successful without custom options
     Failure/Error: expect(room.statistics()).to be_truthy
     WebMock::NetConnectNotAllowedError:
       Real HTTP connections are disabled. Unregistered request: GET https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date=&format=&room_id=Hipchat&timezone= with headers {'Accept'=>'application/json', 'Content-Type'=>'application/json'}

       You can stub this request with the following snippet:

       stub_request(:get, "https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date=&format=&room_id=Hipchat&timezone=").
         with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
         to_return(:status => 200, :body => "", :headers => {})

       registered request stubs:

       stub_request(:get, "https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date&format&room_id=Hipchat&timezone")

       ============================================================
     # ./lib/hipchat/room.rb:269:in `statistics'
     # ./spec/hipchat_api_v2_spec.rb:61:in `block (3 levels) in <top (required)>'

  2) HipChat (API V2) #statistics is successful from fetched room
     Failure/Error: expect(subject.rooms.first.statistics).to be_truthy
     WebMock::NetConnectNotAllowedError:
       Real HTTP connections are disabled. Unregistered request: GET https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date=&format=&room_id=Hipchat&timezone= with headers {'Accept'=>'application/json', 'Content-Type'=>'application/json'}

       You can stub this request with the following snippet:

       stub_request(:get, "https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date=&format=&room_id=Hipchat&timezone=").
         with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
         to_return(:status => 200, :body => "", :headers => {})

       registered request stubs:

       stub_request(:get, "https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date&format&room_id=Hipchat&timezone")
       stub_request(:get, "https://api.hipchat.com/v2/room?auth_token=blah").
         with(:body => "",
              :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'})

       ============================================================
     # ./lib/hipchat/room.rb:269:in `statistics'
     # ./spec/hipchat_api_v2_spec.rb:69:in `block (3 levels) in <top (required)>'

Finished in 0.26564 seconds (files took 1.85 seconds to load)
74 examples, 2 failures

Failed examples:

rspec ./spec/hipchat_api_v2_spec.rb:58 # HipChat (API V2) #statistics is successful without custom options
rspec ./spec/hipchat_api_v2_spec.rb:64 # HipChat (API V2) #statistics is successful from fetched room
rberrelleza commented 8 years ago

Will do, it looks like the stub didn't register the return headers (something that webmock 1.22.1 didn't enforce but 1.22.6 now does). Thanks for raising the issue.

rberrelleza commented 7 years ago

https://github.com/hipchat/hipchat-rb/pull/191 will bump up the dependency