a few days ago, i tried cucumber, when i ran cucumber
versions:
- ruby 2.7.1
- rails 6.1.4
- cucumber 7.0.0
- cucumber-rails 2.4.0
i got below error:
undefined method `xmlschema' for class `Time' (NameError)
gems/activesupport-6.1.4/lib/active_support/core_ext/time/conversions.rb:73:in `alias_method'
gems/activesupport-6.1.4/lib/active_support/core_ext/time/conversions.rb:73:in `<class:Time>'
after i googled for a while, i found this, however the fixed version is my Rails current version 6.1.4, so unfortunately it's not the cause of my issue.
i try to down version cucumber 5.0.0 -> 6.1.0, rails 6.0.3.4 -> 6.1.4
but i got another error (it looks like cucumber could not load rails)
uninitialized constant ActiveRecord::Relation::QueryMethods
Did you mean? ActiveRecord::QueryMethods (NameError)
activerecord-6.0.3.7/lib/active_record/relation.rb:19:in `<class:Relation>'
i create a total new rails app, and cucumber-rails work fine.
so i dig into my source, i suspect an extension of class Time in the lib folder
# lib/time.rb
class Time
def self.hi
puts "hello I am Time, now is: #{now}"
end
end
but it works fine with my rails app, just broken with cucumber.
i tried to unload that file, still get the first error.
when i deleted that file, cucumber work.
i also tried another approach, i moved that file into a folder core_ext (or another), and keep load that file, now both rails and cucumber work.
maybe moving lib/time.rb into lib/core_ext is recommened. But i am not sure it's the better way to go and i still wonder how cucumber-rails load my lib source files.
any suggestion ?
thanks !