class Plok::Engine
Public Instance Methods
class_exists?(class_name)
click to toggle source
# File lib/plok/engine.rb, line 22 def class_exists?(class_name) klass = Module.const_get(class_name.to_s) klass.is_a?(Class) rescue NameError return false end
load_spec_supports()
click to toggle source
You can call this in your spec/rails_helper.rb file so you can make use of the spec supports to test concerns.
You cannot call it in the engine itself, because RSpec won’t have the same context available when tests are ran.
# File lib/plok/engine.rb, line 42 def load_spec_supports Dir.glob("#{root}/spec/{factories,support}/**/*.rb").sort.each { |f| require f } end
module_exists?(module_name)
click to toggle source
# File lib/plok/engine.rb, line 29 def module_exists?(module_name) # By casting to a string and making a constant, we can assume module_name # can be either one without it being a problem. module_name.to_s.constantize.is_a?(Module) rescue NameError return false end