abrom / rocketchat-ruby

Ruby wrapper for RocketChat v1 REST API
MIT License
33 stars 24 forks source link

Logging in to a server causes error. #16

Closed simonv3 closed 7 years ago

simonv3 commented 7 years ago

Script:

require 'rocketchat'

rocket_server = RocketChat::Server.new('<server-name>')
session = rocket_server.login('<username>', '<password>')

Gemfile:

source 'https://rubygems.org'

gem 'rocketchat'

Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    rocketchat (0.1.10)

PLATFORMS
  ruby

DEPENDENCIES
  rocketchat (~> 0.1.10)

BUNDLED WITH
   1.15.3

Error:

/Users/simon/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rocketchat-0.1.10/lib/rocket_chat/request_helper.rb:82:in `create_http': uninitialized constant RocketChat::RequestHelper::Net (NameError)
    from /Users/simon/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rocketchat-0.1.10/lib/rocket_chat/request_helper.rb:43:in `request'
    from /Users/simon/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rocketchat-0.1.10/lib/rocket_chat/request_helper.rb:28:in `request_json'
    from /Users/simon/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rocketchat-0.1.10/lib/rocket_chat/server.rb:50:in `request_json'
    from /Users/simon/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rocketchat-0.1.10/lib/rocket_chat/server.rb:38:in `login'
    from script.rb:4:in `<main>'
abrom commented 7 years ago

Thanks for reporting @simonv3

I can see the issue here (missing require for net/http). Unfortunately it was being masked by some of the other gems we load in the specs (and which are loaded for me in my environment).

I'll push a fix, but in the short term you could get around this by adding require 'net/http' to the top of your code.

simonv3 commented 7 years ago

Thanks for the super quick response time!

abrom commented 7 years ago

Not a problem. I've pushed gem v0.1.11 out which includes the fix.