Skip to content

Commit

Permalink
clean up constant warnings in specs
Browse files Browse the repository at this point in the history
  • Loading branch information
msimonborg committed Dec 9, 2018
1 parent 29ec052 commit 30878c2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,14 @@ def it_can_include_and_inherit(*classes, &block)
it_inherits_directly_from_lazy_record_base(*classes, &block)
end

def remove_const_if_const_defined(const)
Object.send(:remove_const, const) if Object.const_defined?(const)
end

def it_includes_lazy_record_base_module(*classes, &block)
context 'included in custom Base class' do
classes.each do |klass|
remove_const_if_const_defined(klass)
cls = Object.const_set(klass, Class.new)
cls.include(LazyRecord::BaseModule)
end
Expand All @@ -132,6 +137,7 @@ def it_includes_lazy_record_base_module(*classes, &block)
def it_inherits_directly_from_lazy_record_base(*classes, &block)
context 'inherited directly from LazyRecord::Base' do
classes.each do |klass|
remove_const_if_const_defined(klass)
Object.const_set(klass, Class.new(LazyRecord::Base))
end
module_eval(&block)
Expand Down

0 comments on commit 30878c2

Please sign in to comment.