I'm having a bit of truble with omniauth/openid.
When trying to authenticate, I found this in my logs:
OpenID::FetchingError: Error fetching https://www.google.com/accounts/o8/.well-known/host-meta?hd=profiles.google.com%2Fmy_username: undefined method `io' for nil:NilClass
The important thing there is undefined method io' for nil:NilClass which comes from openid/fetchers.rb, in the following snippet:
module Net
class HTTP
def post_connection_check(hostname)
check_common_name = true
cert = #socket.io.peer_cert
cert.extensions.each { |ext|
next if ext.oid != "subjectAltName"
ext.value.split(/,\s+/).each{ |general_name|
if /\ADNS:(.*)/ =~ general_name
check_common_name = false
...
That error is generated by #socket.io.peer_cert, #socket is not defined.
Have any of you encountered this before? Not quite sure what the cause is.
Versions I'm running:
ruby 1.9.3dev (2010-08-17 trunk 29020) [x86_64-darwin10.4.0]
ruby-openid (2.1.8)
ruby-openid-apps-discovery (1.2.0)
omniauth 0.2.0
We had this same problem and it was a direct result of Net::HTTP#connect never being invoked. Turns out we had the fakeweb gem scoped into the environment that was throwing the error (development, in our case).
Narrowing fakeweb's scope allows for normal processing of #connect and #socket is once again happy.
group :test do
gem 'fakeweb'
end
We came across the same / very similar problem with both fakeweb and webmock (when using the VCR gem). Switching from fakeweb to typhoeus seemed to have solved this problem for us.
Related
In a gem I'm working with I found the snippet:
#object.with(&block)
But the method with(&block) is not defined in the project. It looks like it's defined as a base method inside Ruby somwhere, but I'm not sure.
What does it mean? Can someone point to where that method is defined (like in Object or Class or some other Ruby class)?
Edit:
The code in question:
def self.redis(&block)
raise ArgumentError, "requires a block" if !block
#redis ||= Sidekiq::RedisConnection.create(#hash || {})
#redis.with(&block)
end
It's from the project Sidekiq (https://github.com/mperham/sidekiq). That project also includes the redis-rb gem (https://github.com/redis/redis-rb). I can't locate a with method defined in either.
Maybe I'm just missing something.
It's defined as part of the connection_pool gem which is used by sidekiq, and it's source is below. It looks like it's purpose is to obtain a connection from the pool, yield it to the provided block, and then release the connection back to the pool.
here's how I found that out:
pry> redis = Sidekiq::RedisConnection.create({})
pry> redis.method(:with).source
def with
conn = checkout
begin
yield conn
ensure
checkin
end
end
pry> redis.method(:with).source_location
["./ruby/gems/2.0.0/gems/connection_pool-1.1.0/lib/connection_pool.rb", 46]
And to identify the dependency:
~$ bundle exec gem dependency connection_pool --reverse-dependencies
Gem connection_pool-1.1.0
minitest (>= 5.0.0, development)
Used by
sidekiq-2.16.0 (connection_pool (>= 1.0.0))
I've tried running this with Ruby 1.9.3 as well as 2.0, but nothing seemed to work. Here's the code:
require 'sinatra'
before do
set :display_string, 'Welcome from Ruby!'
end
get '/' do
settings.display_string
end
The error is:
NoMethodError at /
undefined method `set' for (sinatra application code here)
This code:
set :display_string, 'Welcome from Ruby!'
seems to cause the issue. I'm running Thin 1.5.1 , latest version of Sinatra 1.4.3
EDIT: It seems that this works well if set is not inside the "before do/end" block. So it's something about the set being in the before do/end block.
I think you should set your configure with configure block:
before do
configure do
set :display_string, 'Welcome from Ruby!'
end
end
see more sinatra docs about the configure
I'm getting the above error in a gem with this code snippet
Savon.configure do |config|
config.log = false
config.log_level = :error
HTTPI.log = false
end
This code used to pass in past runs on Travis, so I'm not sure why this changed when I altered the Readme.
Part of this confusion comes from my situation--inheriting a gem to maintain--along with this line in the gemspec:
gem.add_dependency 'savon'
There's no version number specified, so the newest run switched over to using Savon 2, which ditched the Savon.configure global behavior. If you're in the same boat as me, changing this line to the last pre-2.0 version of Savon will resolve the issue:
gem.add_dependency 'savon', '~>1.2.0'
Then bundle install and you should be good.
Or you want to upgrade your code. I know I do.
Savon.configure was removed from Savon 2.0 because the "problem was global state". The quickest way to keep the behavior the same in your app would be to define a app-level global hash in the same place. You'd then pass this hash into every Savon.client call you make. For instance:
# Where Savon.configure was called
APP_OPTS = {
# disable request logging, silences HTTPI as well
log: false,
# Don't log Laundry xmls to STDOUT
log_level: :error,
#... etc
}
# Elsewhere
#client = Savon::Client.new(APP_OPTS)
I'd consider this a starting point to migrating to the 2.0 configuration style. Ideally, you should always consider the client-specific 2.0 options available when initializing each Savon client.
My web app is using Rack 1.4.0, Sinatra v1.2.6, Thin v1.2.11, Ruby v1.9.2p180
Navigating to a page I get this error in the log:
TypeError - can't convert nil into String:
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:152:in `hexdigest'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:152:in `generate_hmac'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:109:in `unpacked_cookie_data'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:99:in `extract_session_id'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:43:in `load_session_id!'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:32:in `[]'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:262:in `current_session_id'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:268:in `session_exists?'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:107:in `exists?'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:122:in `load_for_read!'
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:59:in `[]'
/var/www/phrogz.net/routes/test.rb:8:in `logged_in?'
The code in test.rb line 8 is:
session[ :foo ] == "BAR"
Any suggestions on what to upgrade/downgrade to fix this?
Looks like you run into this issue. The fix is in Rack 1.4.1 so simply upgrading should fix it.
I have this code in Ruby waitr ..
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'..') if $0 == __FILE__
require 'test/unit'
require 'Watir'
require 'Watir/contrib/enabled_popup'
class TC_Dialog_Test<Test::Unit::TestCase
$ie=Watir::IE.new
$ie.bring_to_front()
$myDir = File.expand_path(File.dirname(__FILE__))
def setup
$ie.goto "file://#{$myDir}/aa.html"
end
def test_confirm_OK
sleep(3)
$ie.button(:id, 'btnConfirm').click_no_wait
$hwnd = $ie.enable_popup(5)
if ($hwnd)
$popup =WinClicker.new
$popup.makeWindowsActive($hwnd)
sleep(3)
# $popup.clickWindowsButton($hwnd,"OK")
puts "you pressed Comfirm-ok"
sleep(3)
end
end
end
when runnung this code get this error results ...
test_confirm_OK(TC_Dialog_Test):
WIN32OLERuntimeError: unknown property or method `document'
HRESULT error code:0x800706b5
The interface is unknown.
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/ie.rb:417:in `method_missing'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/ie.rb:417:in `document'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/container.rb:767:in `ole_inner_elements'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/container.rb:838:in `locate_input_element'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/input_elements.rb:10:in `locate'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/element.rb:47:in `assert_exists'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/element.rb:278:in `enabled?'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/element.rb:53:in `assert_enabled'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/element.rb:214:in `click_no_wait'
Mo.rb:16:in `test_confirm_OK'
You are using Watir 1.5.3, but the current stable is 1.8.1. I suggest you to update your gem to the latest and try again. There is a good chance that the WIN32OLE object for IE has changed it's behavior and old gem is conflicting with it. (Have you updated IE or smth since last successful run?)
I got the same error using Watir 1.8.1. I don't know if there is anything wrong with your code, but in my case the tests ran fine on other machines.
I am running my tests in RubyMine 3.1.x. Running RubyMine as Administrator allowed Ruby to have the rights to interact with IE properly and the problem went away.
Edit:
Found the forum post which originally helped me solve the problem.